Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Irken is a statically typed variant of Scheme. Or a lisp-like variant of ML.
C Scheme Python HTML GAP C++ Other

The Irken Compiler

irken logo

Irken is a statically-typed, simplified variant of Scheme. Or... a lisp-like variant of ML, depending on your point of view. If you're not familiar with either family of languages, Irken is a strongly typed, compiled language with a lisp-like syntax extensible with macros. It uses type inference along with a powerful type system to give you the speed of a compiled language with high-level data types and a higher degree of safety than languages like C/C++.


20151013: I'm working on a generational garbage collector. Also hoping to add compile-time info that will let me use untagged immediates.

20130301: The 'ctailfun/noreg-ssa' branch has been merged into master. This is a fairly radical rearchitecting of the compiler that will enable lots of fun new stuff like an LLVM backend, JIT, separate compilation, etc...


The best way to get familiar with the language is to read the source code in the 'self' directory, and browse over the files in "tests".


Irken is now written in itself, so you need to bootstrap it. You can do this via the python script, or manually. [see]

Just run the script "util/":

$ python util/
[the default compiler is 'clang', to use gcc:
  $ CC=gcc python util/ ]

Which does the following:

  1. compile the distributed version of self/compile.c
  2. this binary will be used to recompile the compiler.
  3. that binary will recompile the compiler again.
  4. the output from steps 2 and 3 are compared, they should be identical.

Note: It is not possible to compile with optimization off, because this disables the tail call optimization that Irken relies on - otherwise the stack will overflow instantly.

At this time (early 2013), clang builds -O3 in about 30 seconds. gcc 4.8 seems to do a better of job of optimizing than clang 3.2, but takes about twice as long to compile.


$ python util/

This will install support files into /usr/local/lib/irken and the binary as /usr/local/bin/irken. If you want to use a different prefix (like /usr), edit util/ and self/context.scm, and rebuild self/compile before installing:

$ self/compile self/compile.scm


Here's a sample - build the toy VM and test it out:

$ cd vm
$ irken vm.scm
$ ./vm tests/t11.byc

The VM executes some bytecode that runs the 'tak' benchmark 20 times.

You might want to try looking at and understanding the 'verbose' output from the compiler, using a relatively small example:

$ irken -v tests/t_while.scm

Irken will use the CC and CFLAGS environment variables when compiling the C output. You may try out another compiler like this:

$ CC="gcc" CFLAGS="-std=c99 -O2 -I." irken ...
Something went wrong with that request. Please try again.