Skip to content

YaoXiang Design Document ​

The Dao gives birth to One, One gives birth to Two, Two gives birth to Three, Three gives birth to the myriad things.

This directory contains design decisions, proposals, and discussions for the YaoXiang programming language.

Core Design Philosophy ​

PhilosophyDescription
Everything is a TypeValues, functions, and modules are all types; types are first-class citizens
Natural SyntaxPython-like readability, close to natural language
Ownership ModelZero-cost abstraction, no GC, high performance
Spawn ModelSynchronous syntax, asynchronous nature, automatic parallelism
AI-FriendlyStrictly structured, clear AST

Design Document Structure ​

design/
├── index.md              # This index
├── deprecated/           # Deprecated (replaced by new designs)
│   └── *.md
├── rejected/             # Rejected
│   └── *.md
├── rfc/
│   ├── draft/            # Draft (work in progress)
│   ├── review/           # Review (open for discussion)
│   ├── accepted/         # Accepted (design approved)
│   ├── deprecated/       # Deprecated (replaced)
│   └── rejected/         # Rejected (not approved)
└── discussion/           # Design discussion area (open for discussion)
    └── *.md

Accepted Design Proposals ​

DocumentStatusDescription
RFC-010 Unified Type Syntax✅ AcceptedUnified type definition syntax
RFC-011 Generic Type System✅ AcceptedGeneric type system design
RFC-009 Ownership Model✅ AcceptedOwnership and borrowing system
RFC-024 Concurrency Model✅ Acceptedspawn concurrency primitive semantics
RFC-027 Compile-Time Assertions✅ AcceptedCompile-time predicates and static verification

See the rfc/accepted/ directory for the full list (16 total), and rfc/index.md for the latest status.

RFC Proposals ​

RFC (Request for Comments) is the proposal process for new features and major changes.

Active Proposals ​

NumberTitleStatus
RFC-019Typed HomoiconicityDraft
RFC-028JIT CompilerDraft
RFC-029Module Semantic SystemDraft
RFC-031Optimization LevelsDraft
RFC-033^^ Reflection OperatorDraft
RFC-034Debug ToolchainDraft
RFC-035MCP ServerDraft
RFC-002Cross-Platform IO (libuv)Draft
RFC-026byx-bindgenDraft
RFC-011aInterface Implementation and Dynamic DispatchReview
RFC-014aRegistry ProtocolReview
RFC-014bBuild SystemReview
RFC-014cWorkspaceReview
RFC-026aExtensible FFIReview
RFC-032Unified spawn ExpressionReview

Accepted Proposals ​

NumberTitleStatus
RFC-004Curried Multi-Position BindingAccepted
RFC-006Documentation Site OptimizationAccepted
RFC-007Unified Function SyntaxAccepted
RFC-008Runtime Concurrency ModelAccepted
RFC-009Ownership ModelAccepted
RFC-009aToken Lifetime AnalysisAccepted
RFC-010Unified Type SyntaxAccepted
RFC-011Generics SystemAccepted
RFC-012f-stringAccepted
RFC-013Error Code SpecificationAccepted
RFC-014Package ManagerAccepted
RFC-015Configuration SystemAccepted
RFC-017LSP SupportAccepted
RFC-018LLVM AOT CompilerAccepted
RFC-024Concurrency ModelAccepted
RFC-026FFI Core MechanismAccepted
RFC-027Compile-Time AssertionsAccepted
RFC-030assert Assertion MechanismAccepted

Rejected Proposals ​

NumberTitleStatus
RFC-003Version PlanningRejected
RFC-005CVE ScanningRejected
RFC-016Quantum-Native SupportRejected
RFC-025Primitive Type ExtensionRejected

RFC Template ​

Before submitting a new proposal, please refer to:

Participate in Design Discussions ​

RFC Lifecycle ​

RFC proposals have 5 states:

StateMeaning
DraftWork in progress
ReviewOpen for discussion
AcceptedDesign approved
DeprecatedPreviously accepted, replaced by new design
RejectedNot approved

Full lifecycle:

Draft → Review → Accepted → Deprecated (replaced)
                    ↓
                Rejected (not approved)

Proposal Process ​

1. Draft proposal (using RFC template)
   → Place in rfc/draft/

2. Submit for review
   → Move to rfc/review/, open community discussion

3. Core team review
   → Accept → Move to rfc/accepted/
   → Reject → Move to rfc/rejected/

4. Subsequent maintenance
   → Replaced → Move to rfc/deprecated/

Design Principles ​

  • Clear Boundaries: Each design decision should have a clear scope of application
  • Practicality First: Solve real problems, not imaginary threats
  • User-Visible Behavior Unchanged: Never break userspace

Code Examples ​

yaoxiang
// Type definition
Point: Type = { x: Float, y: Float }
Result: (T: Type, E: Type) -> Type = { ok: (T) -> Result(T, E), err: (E) -> Result(T, E) }

// Function definition
add: (a: Int, b: Int) -> Int = a + b

// Main function
main: () -> Void = {
    print("Hello, YaoXiang!")
}

Key Design Decisions ​

1. Type System ​

  • Unified Type Syntax: Abolish enum, struct, union; unify with Name: Type = {...}
  • Constructors as Types: Eliminate the gap between "type" and "value"
  • Generic Support: Compile-time monomorphization, zero runtime overhead

2. Spawn Model ​

yaoxiang
// Spawn model: sequential execution by default, spawn introduces dataflow parallelism

// Default sequential execution
compute: (Int) -> Int = (n) => {
    a = heavy_calc(1)
    b = heavy_calc(2)  // Sequential execution, waits for a
    c = heavy_calc(3)  // Sequential execution, waits for b
    a + b + c
}

// spawn block introduces dataflow parallelism
process: () -> Void = () => {
    spawn {
        users = fetch_users()   // Parallel
        posts = fetch_posts()   // Parallel
    }
    // Caller synchronously blocks waiting for results
    render(users, posts)
}

3. Error Handling ​

yaoxiang
Result: (T: Type, E: Type) -> Type = { ok: (T) -> Result(T, E), err: (E) -> Result(T, E) }

process: () -> Result(Data, Error) = {
    data = fetch_data()?      // ? operator transparently propagates
    transformed = transform(data)?
    save(transformed)?
}

Historical Archives ​

Historical documents from the design process have been moved to the docs/old/ directory, including:

  • Early architecture design
  • Deprecated proposals
  • Outdated implementation plans