Skip to content

YaoXiang Design Document

One gives rise to two, two gives rise to three, three gives rise to all things.

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

Core Design Principles

PrincipleDescription
Everything is 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/           # Under review (open for discussion)
│   ├── accepted/         # Accepted (design passed)
│   ├── deprecated/       # Deprecated (replaced)
│   └── rejected/         # Rejected (did not pass)
└── 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 design
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 complete 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-033Reflection OperatorsDraft
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 BindingsAccepted
RFC-006Documentation Site OptimizationAccepted
RFC-007Unified Function SyntaxAccepted
RFC-008Runtime Concurrency ModelAccepted
RFC-009Ownership ModelAccepted
RFC-009aToken Lifetime AnalysisAccepted
RFC-010Unified Type SyntaxAccepted
RFC-011Generic 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 MechanismAccepted

Rejected Proposals

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

RFC Templates

Before submitting a new proposal, please refer to:

Participating in Design Discussion

RFC Lifecycle

RFC proposals have 5 statuses:

StatusMeaning
DraftWork in progress
ReviewOpen for discussion
AcceptedDesign passed
DeprecatedWas accepted, replaced by new design
RejectedDid not pass

Complete lifecycle:

Draft → Review → Accepted → Deprecated (replaced)

                 Rejected (did not pass)

Proposal Process

1. Draft proposal (use 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. Ongoing 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 imagined threats
  • User-Visible Behavior Invariant: 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 are Types: Bridge the gap between "type" and "value"
  • Generic Support: Compile-time monomorphization, zero runtime overhead

2. Spawn Model

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

// Sequential by default
compute: (Int) -> Int = (n) => {
    a = heavy_calc(1)
    b = heavy_calc(2)  // Sequential, wait for a
    c = heavy_calc(3)  // Sequential, wait for b
    a + b + c
}

// Spawn block introduces dataflow parallelism
process: () -> Void = () => {
    spawn {
        users = fetch_users()   // Parallel
        posts = fetch_posts()   // Parallel
    }
    // Caller blocks synchronously 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 propagates transparently
    transformed = transform(data)?
    save(transformed)?
}

Historical Archive

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

  • Early architecture design
  • Deprecated proposals
  • Outdated implementation plans