Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

create-your-own-lang-with-rust

> 设计协作
Open source

Create your own programming language with Rust

934 stars0 likes1 views
WebsiteGitHub

About

Create your own programming language with Rust

Create Your Own Programming Language with Rust

Learn compiler fundamentals by building four languages from scratch

Overview • Languages • Quick Start • Requirements • Book


Edition 1.0 Complete

Four languages covering interpretation, compilation, type systems, and object-oriented programming.

LLVM code generation, JIT compilation, type inference, and memory management.


Overview

This book arose from frustration with the lack of modern, clear, and concise teaching materials for beginners who want to learn how to create their own programming language.

"If you don't know how compilers work, then you don't know how computers work" 1

"If you can't explain something in simple terms, you don't understand it" 2

Languages

The book teaches programming language implementation through four progressively complex languages:

Language Type System Execution Features Rust Version
Calculator None Interpreter/VM/JIT Arithmetic expressions stable / nightly
Firstlang Dynamic Interpreter Variables, functions, recursion stable 1.70+
Secondlang Static LLVM JIT Type inference, compilation nightly + LLVM
Thirdlang Static LLVM JIT Classes, methods, OOP nightly + LLVM
create-your-own-lang-with-rust/
├── calculator/     # Simple arithmetic (interpreter, VM, JIT backends)
├── firstlang/      # Interpreted language with recursion
├── secondlang/     # Compiled language with type inference
├── thirdlang/      # Object-oriented with classes and methods
└── book/           # mdbook source for createlang.rs

Each language has its own README with detailed instructions.

Quick Start

Firstlang (stable Rust)

bash
cd firstlang
cargo run -- examples/fibonacci.fl    # Run a program
cargo run                              # Start REPL

Secondlang (nightly + LLVM)

bash
cd secondlang
rustup run nightly cargo run -- examples/fibonacci.sl
rustup run nightly cargo run -- --ir examples/fibonacci.sl   # View LLVM IR

Thirdlang (nightly + LLVM)

bash
cd thirdlang
rustup run nightly cargo run --bin thirdlang -- examples/point.tl
rustup run nightly cargo run --bin thirdlang -- examples/counter.tl

Calculator

bash
cd calculator
cargo run --bin main examples/simple.calc                                            # Interpreter
cargo run --bin main --no-default-features --features vm examples/simple.calc        # VM
rustup run nightly cargo run --bin main --no-default-features --features jit examples/simple.calc  # JIT

Requirements

Stable Rust (Calculator interpreter/VM, Firstlang)

bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Nightly Rust + LLVM (Calculator JIT, Secondlang, Thirdlang)

bash
# Install nightly
rustup toolchain install nightly

# Install LLVM
# macOS:
brew install llvm

# Debian/Ubuntu:
# See https://apt.llvm.org/

Check your LLVM version and update Cargo.toml accordingly:

LLVM Version inkwell feature
20.x llvm20-1
19.x llvm19-1
18.x llvm18-1

Running Tests

bash
# All projects
cargo test -p calculator -p firstlang
rustup run nightly cargo test -p secondlang -p thirdlang

Building the Book

bash
cd book
mdbook serve    # Local preview at http://localhost:3000
mdbook build    # Build static site

Support

If you found this project useful, please consider donating to:

Child Foundation • Black Lives Matter • Food Bank of Canada

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustbookcompilercompiler-designlanguage-design

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category设计协作
PricingOpen source

> Related tools

F
Figma
协作式界面设计工具
S
sketch-wakatime
Sketch plugin for automatic time tracking and metrics generated from your Sketch usage.
Q
QuickColor
Quickly apply fills from the global or document color palettes to selected elements - 🎨