write-you-a-programming-language
write-you-a-programming-language copied to clipboard
List of small programming languages that you can implement in a relatively small amount of time for educational purposes.
Write you a programming language
List of small programming languages that you can implement in a relatively small amount of time for educational purposes. Read my blogpost about this list.
Tutorials
Host | Language | Type | Target | Features |
---|---|---|---|---|
(many) | Lisp (MAL) | Interpreter | - | TCO, macros, bootstrapping |
Assembly | Forth | Compiler | ||
C | C | Interpreter | - | no parser generator, bootstrapping |
C | LBaC | Compiler | x86 | |
C | C(SubC) | Compiler | Assembly | |
C (not free book) | C(SubC) | Compiler | x86-64 | It can compile itself and passes gcc -Wall -pedantic |
C (online book) | Lisp | Interpreter | - | macros |
C | Lisp | Interpreter | - | macros, TCO, continuations, GC |
C | Scheme | Interpreter | - | |
C++ | Kaleidoscope | Compiler, Interpreter | LLVM | procedural language that allows you to define functions, use conditionals, math, JIT |
C++, Flex, Bison | C-like | Compiler | LLVM | |
Go | C(SubC) | Compiler | x86-64 | It can compile itself and passes gcc -Wall -pedantic |
Haskell, parsec | Kaleidoscope | Compiler | LLVM | procedural language that allows you to define functions, use conditionals, math, JIT |
Haskell, Parsec (online book) | Scheme | Interpreter | - | |
Haskell, Parsec | Scheme | Interpreter | - | |
Haskell | LBaC | Compiler | ||
Haskell | MiniAgda | |||
Idris | TinyIdris | typechecking, evaluation, unification (video) | ||
Java | Enkel | Compiler | JVM | |
Java (online book) | Lox | Interpreter | - | |
JavaScript | λanguage | Compiler | JavaScript | |
JavaScript | Lisp | Interpreter | - | The code is 116 lines |
OCaml | Lisp | Interpreter | - | |
OCaml | C | Compiler | x86 | |
Python | Lisp | Interpreter | - | Lisp interpreter in 90 lines of Python |
Python | Python | Interpreter | - | Python interpreter fits easily into the 500-line size restriction |
Python | Interpreter | - | ||
Python | Lisp | Interpreter | - | |
Racket (online book) | ||||
Ruby | Compiler | |||
Ruby | Markdown | Compiler | HTML | |
Ruby | Ruby | Compiler | ||
Scheme | Scheme | Interpreter | - | First-class (run-time) macros and meta-circular evaluation |
Scheme | Scheme | Compiler | C | Compiling Scheme to C with closure conversion |
Scheme | Scheme | Compiler | Java | |
Scheme | Scheme | Compiler | Lambda Calc | |
Swift | Lisp | Interpreter | - | |
Turbo Pascal 4.0 | LBaC | Compiler | x8086 | |
TypeScript | Compiler | WebAssembly | ||
🚧 C | Lisp | Compiler | ||
🚧 Haskell | Haskell(fun) |
Toy languages
Toy languages, or mini languages, or tiny languages come with code but don't have explanations (unlike tutorials). So you are on your own.
Host | Language | Type | Target | Features |
---|---|---|---|---|
C | Lisp | Interpreter | - | GC |
C | Scheme | Interpreter | - | GC |
C | TCL | Interpreter | - | a Tcl interpreter in 550 lines of C code |
C | Lisp | Interpreter | - | Lisp In Less Than 200 Lines Of C |
C++ | Lisp | Interpreter | - | interpreter in 90 lines of C++ |
Haskell, parsec | Haskell(Duet) | Interpreter | - | type classes, non-strict, but is not lazy |
Idris | minihaskell | Interpreter | - | lazy, functional, integers, booleans, lists, recursion, statically typed |
JavaScript, babylon | JavaScript | Interpreter | - | |
OCaml, menhir | miniml | Compiler, Interpreter | Abstract | eager, functional, recursive functions, statically typed, compiler, abstract machine |
OCaml, menhir | miniml_error | Compiler, Interpreter | Abstract | like miniml that can also abort execution |
OCaml, menhir | minihaskell | Interpreter | - | lazy, functional, integers, booleans, lists, recursion, statically typed |
OCaml, menhir | miniprolog | Interpreter | - | logic programming, Horn clauses, unification |
OCaml, menhir | levy | Interpreter | - | call-by-push value, statically typed |
OCaml, menhir | comm | Compiler | Abstract | a simple procedural langauge |
OCaml, menhir | calc | Interpreter | - | integer arithmetic |
OCaml, menhir | sub | Interpreter | - | an eager purely functional language, mutable records, statically typed, subtyping |
OCaml, menhir | boa | Interpreter | - | object-oriented, eager, first-class functions, dynamic types, extensible objects |
OCaml, menhir | lambda | Interpreter | - | untyped λ-calculus, several evaluation strategies |
OCaml, menhir | poly | Interpreter | - | lazy, functional, statically typed, parametric polymorphism, type inference |
OCaml, menhir | poly | Interpreter | - | lazy, functional, statically typed, parametric polymorphism, type inference |
See also:
Type systems
- Cubiml is a simple ML-like programming language with subtyping and full type inference. You can try it out online in your browser here. Cubiml is not intended to be used in its own right, but rather to serve as a tutorial for implementing cubic biunification, and therefore has a deliberately minimal feature set.
- Tiny OutsideIn(X). This is a simple reference implementation of OutsideIn(X) type inference algorithm.
- Elaboration zoo. This repo includes a series of Haskell implementations for elaborating dependently typed languages, where packages add progressively more power and functionality. Currently, packages focus on basics of unification, inference and implicit argument handling, and we don't have any inductive types or modules (yet).
Courses & Books
- Utah Compilers, Spring 2011
- Programming languages and paradigms lecture
- Programming languages
- An Incremental Approach to Compiler Construction by Abdulaziz Ghuloum. Writing a Compiler in 24 Small Steps.
- A Simple Scheme Compiler
- CS 4410/6410: Compiler Design
Related
- awesome-compilers: tutorials
- Build your own Programming Language
- Programming languages resources
- nanopass. Clean Compiler Creation Language
- Bril: A Compiler Intermediate Representation for Learning
Quotes
Most likely you will find one of those quotes in tutorials
If you don't know how compilers work, then you don't know how computers work.
-- Steve Yegge
If you can’t explain something in simple terms, you don’t understand it
Dr. Hoenikker used to say that any scientist who couldn't explain to an eight-year-old what he was doing was a charlatan.
-- Kurt Vonnegut, Cat's Cradle (said by Dr. Asa Breed; chapter 15)
What I cannot create, I do not understand.
-- Richard Feynman