elematic/zena

A new programming language for WebAssembly GC

TypeScript

65

1,417 commits

updated Sep 26, 2026

See the code

See what people are saying

SourceMessageScoreDate

Evolving programming languages in the AI era

This part: --- - Correct by construction: the language makes invalid states or programs hard or impossible to express. - Statically established: types, proofs, and static analysis establish properties before execution. - Runtime-enforced: memory management, isolation, capability boundaries, and…

0

Sep 27, 2026

README

The Zena Programming Language

Zena is a statically typed programming language designed from the ground up to compile to compact, high-performance WebAssembly GC binaries with a fast, self-hosted toolchain.

Zena takes TypeScript's syntax and ergonomics as a starting point, pairing them with a sound static type system and consistent semantics free from JavaScript's historical quirks. It integrates proven features from modern languages—Dart, Swift, Scala, Rust, and Kotlin—along with novel systems for resource ownership, asynchronous cancellation, and native WebAssembly Component Model support.

// Variables are immutable by default; primitive types are strict
let maxRetries: i32 = 3;
var attempts = 0;

// Sealed class hierarchies for algebraic data types
sealed class Shape {
  case Circle(radius: f64)
  case Rect(width: f64, height: f64)
}

// Pattern matching expressions with exhaustiveness checking
let area = (shape: Shape): f64 => match (shape) {
  case Circle {radius}: 3.14159 * radius * radius
  case Rect {width, height}: width * height
};

// Classes with Dart-style constructors and private fields
class Counter {
  #step: i32;
  var count: i32 = 0;

  new(this.#step);

  increment() {
    this.count += this.#step;
  }
}

// Pipelines for readable data flow
let formatted = "  hello world  "
  |> trim($)
  |> toUpperCase($);

[!WARNING] Zena is under active development and is not ready for production use. Syntax, semantics, and standard libraries are changing rapidly, and breaking changes occur frequently.

Key Features

Familiar Syntax, Sound Semantics

Zena builds on TypeScript-like syntax while enforcing strict static guarantees:

  • Sound type system: No any type, no unchecked casts, and no implicit type coercion.
  • Strict primitives & nullability: Dedicated numeric types (i32, i64, u32, u64, f32, f64). References are non-nullable by default.
  • Immutability by default: Variables (let) and class fields are immutable by default; var marks mutable state.
  • Expression-oriented control flow: if, match, and try evaluate directly to values.

Ideas from Modern Languages

  • Dart: Constructors with initializer lists and this. parameter shorthand; class mixins for flexible code reuse.
  • Swift: Immutability defaults, var/let distinction, compound assignment operators (no ++ or --).
  • Scala: Sealed class hierarchies, case classes, and exhaustive pattern matching with destructuring.
  • Rust & Kotlin: Algebraic data types, pipeline operator (|>), and structured control expressions.

Language Innovations

  • Affine Resource & Ownership System: Deterministic lifecycle management for non-GC resources (WASI file descriptors, Component Model handles, linear memory). resource class, Own<T>, and Borrow<T> enforce move semantics and stack-bound borrows at compile time without complex lifetime annotations.
  • First-Class Async Cancellation: Asynchronous cancellation flows through a dedicated language channel. Dedicated cancel blocks in try/catch/cancel/finally handle interruption cleanly, while shielded blocks ensure critical cleanup runs to completion.
  • Native WIT & Component Model Integration (In Progress): Direct compiler support for WebAssembly Interface Type (.wit) files and WASI interfaces without external code generators or intermediate bindgen tools.
  • Unboxed Value Types & Multi-Value Returns: Functions can return multiple values as unboxed inline tuples on the stack with no heap allocation (used in standard APIs like Map.get()), expanding toward unboxed composite types and Struct-of-Arrays (SoA) layouts.

WebAssembly GC Native

  • Direct mapping: Primitives, references, records, tuples, and arrays compile directly to native Wasm GC types and instructions. Modules ship without an allocator or garbage collector.
  • Zero-boxing generics: Generics are monomorphized to concrete Wasm types, avoiding runtime wrapper objects.
  • Compact binaries: Aggressive dead-code elimination and optimization passes remove unused functions, classes, and types.

Toolchain & Runtimes

Zena provides a self-hosted toolchain and specialized execution runtimes on Wasmtime:

  • zena-cli (zena): The primary developer tool, bundling the self-hosted compiler, test runner, benchmark runner, and documentation generator (zena doc).
  • zena-run: A lightweight standalone runner that executes compiled Zena modules (zena-cli target) on Wasmtime without compiler overhead.
  • zfx (zenafx): An experimental graphical runtime for WebAssembly components, providing GPU-accelerated rendering (wasi:webgpu) and OS window presentation (wasi-gfx:surface).
  • Integrated tools: Language server (LSP), CodeMirror 6 support, VS Code extension, and an interactive online playground.

Status

Zena is in active development and experimental. The core language (classes, interfaces, mixins, generics, pattern matching, records, tuples, exceptions, SIMD, and async functions) is implemented in the self-hosted compiler. Work is ongoing on the ZIR optimization pipeline, async cancellation, the affine ownership system, and native WIT integration.

Development with Generative AI

Zena is implemented primarily through generative AI paired with human architecture, engineering guidance, and code review. It serves as both an active language project targeting modern WebAssembly environments and an exploration of AI-assisted language engineering and toolchain development.

Documentation

Getting Started

Prerequisites

  • Node.js v25+
  • npm
  • wasmtime (for running standalone or WASI binaries)

Building from Source

git clone https://github.com/elematic/zena.git
cd zena
npm install
npm run build
npm test

License

MIT

Contributors

justinfagnani

1,388 commits

Copilot

27 commits

rictic

2 commits

elematic/zena

A new programming language for WebAssembly GC

TypeScript

65

1,417 commits

updated Sep 26, 2026

See the code

See what people are saying

SourceMessageScoreDate

Evolving programming languages in the AI era

This part: --- - Correct by construction: the language makes invalid states or programs hard or impossible to express. - Statically established: types, proofs, and static analysis establish properties before execution. - Runtime-enforced: memory management, isolation, capability boundaries, and…

0

Sep 27, 2026

README

The Zena Programming Language

Zena is a statically typed programming language designed from the ground up to compile to compact, high-performance WebAssembly GC binaries with a fast, self-hosted toolchain.

Zena takes TypeScript's syntax and ergonomics as a starting point, pairing them with a sound static type system and consistent semantics free from JavaScript's historical quirks. It integrates proven features from modern languages—Dart, Swift, Scala, Rust, and Kotlin—along with novel systems for resource ownership, asynchronous cancellation, and native WebAssembly Component Model support.

// Variables are immutable by default; primitive types are strict
let maxRetries: i32 = 3;
var attempts = 0;

// Sealed class hierarchies for algebraic data types
sealed class Shape {
  case Circle(radius: f64)
  case Rect(width: f64, height: f64)
}

// Pattern matching expressions with exhaustiveness checking
let area = (shape: Shape): f64 => match (shape) {
  case Circle {radius}: 3.14159 * radius * radius
  case Rect {width, height}: width * height
};

// Classes with Dart-style constructors and private fields
class Counter {
  #step: i32;
  var count: i32 = 0;

  new(this.#step);

  increment() {
    this.count += this.#step;
  }
}

// Pipelines for readable data flow
let formatted = "  hello world  "
  |> trim($)
  |> toUpperCase($);

[!WARNING] Zena is under active development and is not ready for production use. Syntax, semantics, and standard libraries are changing rapidly, and breaking changes occur frequently.

Key Features

Familiar Syntax, Sound Semantics

Zena builds on TypeScript-like syntax while enforcing strict static guarantees:

  • Sound type system: No any type, no unchecked casts, and no implicit type coercion.
  • Strict primitives & nullability: Dedicated numeric types (i32, i64, u32, u64, f32, f64). References are non-nullable by default.
  • Immutability by default: Variables (let) and class fields are immutable by default; var marks mutable state.
  • Expression-oriented control flow: if, match, and try evaluate directly to values.

Ideas from Modern Languages

  • Dart: Constructors with initializer lists and this. parameter shorthand; class mixins for flexible code reuse.
  • Swift: Immutability defaults, var/let distinction, compound assignment operators (no ++ or --).
  • Scala: Sealed class hierarchies, case classes, and exhaustive pattern matching with destructuring.
  • Rust & Kotlin: Algebraic data types, pipeline operator (|>), and structured control expressions.

Language Innovations

  • Affine Resource & Ownership System: Deterministic lifecycle management for non-GC resources (WASI file descriptors, Component Model handles, linear memory). resource class, Own<T>, and Borrow<T> enforce move semantics and stack-bound borrows at compile time without complex lifetime annotations.
  • First-Class Async Cancellation: Asynchronous cancellation flows through a dedicated language channel. Dedicated cancel blocks in try/catch/cancel/finally handle interruption cleanly, while shielded blocks ensure critical cleanup runs to completion.
  • Native WIT & Component Model Integration (In Progress): Direct compiler support for WebAssembly Interface Type (.wit) files and WASI interfaces without external code generators or intermediate bindgen tools.
  • Unboxed Value Types & Multi-Value Returns: Functions can return multiple values as unboxed inline tuples on the stack with no heap allocation (used in standard APIs like Map.get()), expanding toward unboxed composite types and Struct-of-Arrays (SoA) layouts.

WebAssembly GC Native

  • Direct mapping: Primitives, references, records, tuples, and arrays compile directly to native Wasm GC types and instructions. Modules ship without an allocator or garbage collector.
  • Zero-boxing generics: Generics are monomorphized to concrete Wasm types, avoiding runtime wrapper objects.
  • Compact binaries: Aggressive dead-code elimination and optimization passes remove unused functions, classes, and types.

Toolchain & Runtimes

Zena provides a self-hosted toolchain and specialized execution runtimes on Wasmtime:

  • zena-cli (zena): The primary developer tool, bundling the self-hosted compiler, test runner, benchmark runner, and documentation generator (zena doc).
  • zena-run: A lightweight standalone runner that executes compiled Zena modules (zena-cli target) on Wasmtime without compiler overhead.
  • zfx (zenafx): An experimental graphical runtime for WebAssembly components, providing GPU-accelerated rendering (wasi:webgpu) and OS window presentation (wasi-gfx:surface).
  • Integrated tools: Language server (LSP), CodeMirror 6 support, VS Code extension, and an interactive online playground.

Status

Zena is in active development and experimental. The core language (classes, interfaces, mixins, generics, pattern matching, records, tuples, exceptions, SIMD, and async functions) is implemented in the self-hosted compiler. Work is ongoing on the ZIR optimization pipeline, async cancellation, the affine ownership system, and native WIT integration.

Development with Generative AI

Zena is implemented primarily through generative AI paired with human architecture, engineering guidance, and code review. It serves as both an active language project targeting modern WebAssembly environments and an exploration of AI-assisted language engineering and toolchain development.

Documentation

Getting Started

Prerequisites

  • Node.js v25+
  • npm
  • wasmtime (for running standalone or WASI binaries)

Building from Source

git clone https://github.com/elematic/zena.git
cd zena
npm install
npm run build
npm test

License

MIT

Contributors

justinfagnani

1,388 commits

Copilot

27 commits

rictic

2 commits

Languages

TypeScript

47.3%

JavaScript

23.4%

CSS

11.2%

Rust

10.2%

Nunjucks

4.4%

Shell

1.5%