Maru is a tiny self-hosting lisp dialect: a symbolic expression evaluator that can compile its own implementation language.
The architecture is described in Ian Piumarta's paper: Open, extensible composition models.
it is a sketch of how Maru's generalised eval works, which is entirely accurate in intent and approach, if a little different in some implementation details
-
eval.c
(in branchstage-0.c99
) contains a reader/evaluator for a simple s-expression language, written in C (C99). -
eval.l
contains the same evaluator, written in the s-expression language. In other words, eval.l is a metacircular evaluator for the language it is written in. -
emit.l
contains a compiler from s-expressions to IA-32 (x86) machine code, written in the s-expression language. This compiler can be thought of as a semantics-preserving "level shift" from s-expressions to IA-32 machine code, letting the metacircular evaluator ineval.l
escape from "infinite metacircular regression" to a language grounded in hardware. -
boot.l
contains the data structures, algorithms and paradigms that are needed byemit.l
, written in the s-expression language.
The recursive implementation and compiler (in the .l files) is split into three parts for clarity, but it could all be in a single source file.
The bootstrap stages are in separate git branches called stage-n
;
i.e. stage-0-c99
holds the bootstrap implementation written in C,
and each successive stage uses the eval
executable compiled from the
source code of the previous stage.
During the build the bootstrap stages are git checkout
'ed into build/stage-n
,
and they are built there. A new stage needs to be opened when you want to use a new feature
of the language in the code implementing the language itself.
The master
branch holds the upcoming next bootstrap stage ("symlinked" by git symbolic-ref
).
From the master
branch invoke make bootstrap
.
Initially written by Ian Piumarta.
This repo is maintained by attila@lendvai.name.
-
Programming badly needs better foundations, and Maru is part of this exploration.
-
Maru is very small: in about 1700 lines of code it can self-host (with about 2300 LoC of C for stage 0).
-
Ian seems to have stopped working on Maru, but it's an interesting piece of code that deserves a repo and a maintainer.
Maru was developed as part of Alan Kay's Fundamentals of New Computing project, by the Viewpoints Research Institute. The goal of the project was to implement an entirely new, self-hosting computing system, with GUI, in 20.000 lines of code.
Their annual reports: 2007, 2008, 2009, 2010, 2011, 2012.
This git repo is a conversion of Ian Piumarta's mercurial repo that was once available at http://piumarta.com/hg/maru/, whose contents are preserved in the branch called piumarta
. The plan is to eventually revive most of the goodies available there in a more organized/approachable manner.