InkdownInkdown
Start writing

Study

59 filesยท8 subfolders

Shared Workspace

Study
core

zero-language-explanation

Shared from "Study" on Inkdown

Zero Programming Language - Core Working

What is Zero?

Zero is a new programming language created by Vercel, specifically designed for AI agents. It's a compiled language that produces native binaries (like Rust/C++), not an interpreted language like Python or JavaScript.

Key Characteristics

Core Design Principles:

  • Static dispatch
  • Explicit capabilities
  • No mandatory garbage collection
  • No hidden runtime tax
  • JSON-native for structured diagnostics

Architecture Diagram

Plain text
Traditional Languages (Rust, Swift):
Source Code -> Frontend -> LLVM IR -> Binaries
(.rs/.swift)  (Parser/   (Optimized)  (Multi-arch)
               Checker)
                     ^
                     | LLVM Backend
                     | (Heavy, slow)

Zero Language:
Source Code -> Frontend -> Custom C -> Binaries
(.zero)       (Parser/    Compiler    (Manual per
               Checker)   (Handwritten arch)
                          or LLM)
                     ^
                     | No LLVM
                     | (Faster, but
                     |  less stable)
programming-language-concepts.md
zero-language-explanation.md
DB
01-introduction.md
02-relational-databases.md
03-database-design.md
04-indexing.md
05-transactions-acid.md
06-nosql-databases.md
07-query-optimization.md
08-replication-ha.md
09-sharding-partitioning.md
10-caching-strategies.md
11-cap-theorem.md
12-connection-pooling.md
13-backup-recovery.md
14-monitoring.md
15-database-selection.md
README.md
JS
Event loop
Merlin Backend
01-Orchestration.md
02-DeepResearch.md
03-Search.md
04-Scraping.md
05-Streaming.md
06-MultiProviderLLM.md
07-MemoryAndContext.md
08-ErrorHandling.md
09-RateLimiting.md
10-TaskQueue.md
11-SecurityAndAuth.md
Orchestration-2nd-draft
OpenAI Agents Python
00_OVERVIEW.md
01_AGENT_SYSTEM.md
02_RUNNER_SYSTEM.md
03_TOOL_SYSTEM.md
04_ITEMS_SYSTEM.md
05_GUARDRAILS.md
06_HANDOFFS.md
07_MEMORY_SESSIONS.md
08_MODEL_PROVIDERS.md
09_SANDBOX_SYSTEM.md
10_TRACING.md
11_RUN_STATE.md
12_CONTEXT.md
13_LIFECYCLE_HOOKS.md
14_CONFIGURATION.md
15_ERROR_HANDLING.md
16_STREAMING.md
17_EXTENSIONS.md
18_MCP_INTEGRATION.md
19_BEST_PRACTICES.md
20_ARCHITECTURE_PATTERNS.md
opencode-study
context-handling
core
Python
Alembic
Basics
sqlalchemy - fastapi
SQLAlchemy overview
tweets
system_design_for_agentic_apps.md

Why No LLVM? (The Core Trade-off)

LLVM Advantages:

  • Decades of optimization work
  • Automatic multi-architecture support (x86, ARM, etc.)
  • Battle-tested stability
  • Edge case handling

LLVM Disadvantages:

  • Slow compilation time (contributes to Rust's slow builds)
  • Heavy runtime overhead during compilation

Zero's Approach:

  • Custom C compiler written by hand (likely with LLM assistance)
  • Manual binary generation for each CPU architecture
  • Faster compilation, but:
    • Less stable (currently buggy on Mac M1/ARM64)
    • Manual architecture support
    • More maintenance burden

Borrow Checker (Rust-like)

Zero includes a borrow checker similar to Rust (though less powerful):

Plain text
C/C++ (Unsafe):
  int p = 42;           // Memory location 0x42
  int* shared = &p;      // Pointer to p
  int* mut = &p;         // Mutable pointer to p
  *mut = 84;             // Modify through mut
  print(*shared);        // Could be garbage or segfault!
                         // (if memory moved by OS)

Rust/Zero (Safe):
  let p = 42;           // Immutable by default
  let shared = &p;       // Shared reference (readonly)
  let mut = &mut p;      // COMPILE ERROR!
                         // Cannot have mutable reference
                         // while immutable reference exists

AI-Focused Features

This is Zero's unique selling point - designed for AI agents:

Traditional Compiler Error:

Plain text
error: borrow checker error
  --> test.zero:5:10
   |
5  | let mut = &mut p;
   |          ^^^^^^ borrow conflicts with active borrow

Hard for AI to parse and understand

Zero AI-Friendly Error:

JSON
{
  "ok": false,
  "error_code": "B001",
  "error_type": "borrow_conflict",
  "expected": "lexical_borrow",
  "actual": "mutable_borrow",
  "location": {"file": "test.zero", "line": 5, "col": 10},
  "explain": "B001",
  "help_fix": {},
  "type_repair_metadata": {}
}

AI can easily parse, understand, and fix this

Current State

Bootstrapping Problem:

Mature Languages (GCC, Rust):

Plain text
C Compiler -> C becomes stable -> Rewrite compiler in C
(written in ASM)  (self-hosting)    (self-compiling)

Zero (Current):

Plain text
C Compiler -> Zero is buggy -> Cannot bootstrap yet
(written in C)  (too new)       (not stable enough)

Known Issues:

  • Darwin ARM64 (Mac M1) not working
  • Various bugs due to custom compiler implementation
  • Limited architecture support (manual per-arch compilation)

Summary

Zero's Core Innovation: A systems programming language optimized for AI agents through:

  1. JSON-native toolchain output
  2. Structured error codes for LLM consumption
  3. Type repair metadata
  4. AI-friendly diagnostics

Trade-offs:

  • Faster compilation (no LLVM)
  • AI-optimized output
  • Less stable (custom compiler)
  • Manual architecture support
  • Currently buggy

The language is experimental and in early stages, but represents an interesting approach to making programming languages more accessible to AI agents through structured, machine-readable toolchain output.