A functional programming language that compiles to TypeScript, featuring Rust-inspired syntax, Elixir-style pattern matching, and seamless TypeScript interoperability.
- Functional Programming: Immutable by default with
letbindings - Pipe Operations: Data transformation with
|>operator - Pattern Matching: Powerful
matchexpressions with guards - Atoms: Symbolic constants like Elixir (
:ok,:error) - Struct & Trait System: Similar to Rust's type system
- Zero Runtime Overhead: Compiles to clean TypeScript
- Mixed Syntax: Use alongside existing TypeScript/JavaScript
# Install globally
npm install -g zenoscript
# Or using bun
bun install -g zenoscript
# Or using yarn
yarn global add zenoscript# Clone the repository
git clone https://github.com/wess/zenoscript.git
cd zenoscript
# Install dependencies and build
bun install
bun run build# Transpile a file
zeno input.zs output.ts
# Output to stdout
zeno input.zs
# Show help
zeno --help
# Show tokens (debugging)
zeno --tokens input.zs
# Show AST (debugging)
zeno --ast input.zs# Using bun directly
bun src/index.ts input.zs output.tsZenoscript includes a Bun plugin for seamless .zs file integration:
// Import .zs files directly in TypeScript!
import { User, createUser } from "./types.zs";
import { processData } from "./handlers.zs";
// The .zs files are automatically transpiled to TypeScript
const user = createUser("Alice", "[email protected]", 25);The plugin is automatically loaded via bunfig.toml. Just run:
bun run examples/usage.tsstruct User {
name: string;
email: string;
age: number;
}
struct Container<T> {
value: T;
}
Compiles to:
type User = {
name: string;
email: string;
age: number;
};
type Container<T> = {
value: T;
};trait Serializable {
serialize(): string;
deserialize(data: string): Self;
}
Compiles to:
interface Serializable {
serialize(): string;
deserialize(data: string): Self;
}impl User {
new(name: string, email: string, age: number) {
return { name, email, age };
}
}
impl Serializable for User {
serialize() {
return JSON.stringify(this);
}
}
let message = "Hello World"
let count = 42
Compiles to:
const message = "Hello World";
const count = 42;" hello " |> trim |> toUpperCase |> console.log
data |> processData |> validateResult |> saveToDatabase
Compiles to:
console.log(" hello ".trim().toUpperCase());
saveToDatabase(validateResult(processData(data)));let status = :loading
let message = match status {
:idle => "Ready to start"
:loading => "Please wait..."
:success => "Operation completed"
:error when isRetryable => "Retrying..."
:error => "Failed permanently"
_ => "Unknown status"
}
See the examples/ directory for complete examples:
examples/basic.zs- Basic language featuresexamples/advanced.zs- Advanced functional programming patterns
The transpiler is written in C and compiled to build/zeno:
bun run build
# or manually:
cd src/transpiler && makebun testbun run build # Build the C transpiler
bun run clean # Clean build artifacts
bun run test # Run test suite
bun run dev # Development mode with hot reloadThe transpiler follows a traditional compilation pipeline:
- Lexer (
lexer.c) - Tokenizes Zenoscript source code - Parser (
parser.c) - Builds Abstract Syntax Tree (AST) - Code Generator (
codegen.c) - Emits TypeScript code - CLI (
cli.c) - Command-line interface
The Bun wrapper (src/index.ts) provides a seamless interface that automatically builds and runs the C transpiler.
- Mixed syntax support: Seamless integration with TypeScript/JavaScript
- Functional patterns: Inspired by Rust, Elixir, and functional programming
- Type safety: Leverages TypeScript's type system
- Immutability by default: Uses
letfor immutable bindings - Zero runtime overhead: Compiles to native TypeScript constructs
- Fork the repository
- Create your feature branch
- Add tests for new functionality
- Ensure all tests pass:
bun test - Submit a pull request
MIT License - see LICENSE file for details.