Skip to content

jdhenke/x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

167 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x

A minimal, eXecutable, self hosted lisp.

About

x is a programming language. This repo makes x code eXecutable in a few ways.

It is a subset of MIT Scheme's syntax and has its own minimal standard library.

  • ./xs adapts MIT scheme to match the x runtime.

Further, x itself is sufficient to:

  • write its own interpreter (xi.x)
  • write its own compiler (xc.x)
  • pass unit tests for each language feature (test.x)
  • solve Advent of Code puzzles (aoc/)

Setup

Scheme

Download MIT Scheme.

You should be able to run:

scheme

And get a prompt back.

Bootstrap

Run:

./bootstrap

You should now have three x runtimes:

  • ./xs a wrapper around scheme
  • ./xi a native x interpreter
  • ./xc a native x compiler

All accept x code from stdin and run it.

for x in ./xs ./xi ./xc; do
    echo "(println (+ 1 2))" | $x
done

To have xc only compile and not run, use -o <path> e.g.

./xc -o /tmp/output.bin < code.x

Note: all three runtimes support tail recursion.

Verify

Because the x interpreter and compiler are written in x themselves, one can chain them together after bootstrapping with the scheme runtime.

To verify that chaining the runtimes together in different orders reproduces the same results, including the "fixed point" that the compiler can reproduce itself byte-for-byte, run:

./verify

Note: for performance reasons, this limits to chains that do not run nested interpeters, and even then, the Ic* checks still take a minute. See the nesting experiment to explore this further for the x runtime or the minimal eval to explore several levels of nesting for a simpler runtime.

Examples: Advent of Code

See aoc/ for solutions to Advent of Code puzzles written in x.

You can run with any runtime e.g.:

./xs < ./aoc/2025/day1.x
./xi < ./aoc/2025/day1.x
./xc < ./aoc/2025/day1.x

Experiments

See exp/ for some motivating or follow-on experiments to x.

  1. See how the null solution actually passes verification.
  2. See a minimal eval that can evaluate itself.
  3. See how nesting runtimes works.
  4. See how a trusting trust attack is implemented in x.
  5. See how to reify control flow with call/cc in x.

About

A minimal, eXecutable, self hosted lisp.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages