kanaka/mal
{ "createdAt": "2014-03-24T21:33:23Z", "defaultBranch": "master", "description": "mal - Make a Lisp", "fullName": "kanaka/mal", "homepage": "", "language": "Assembly", "name": "mal", "pushedAt": "2025-10-22T16:42:57Z", "stargazersCount": 10511, "topics": [ "bash", "c", "c-plus-plus", "c-sharp", "clojure", "docker", "java", "javascript", "learn-to-code", "lisp", "lisp-interpreter", "makefile", "mal", "php", "python", "r", "ruby", "scala", "swift", "webassembly" ], "updatedAt": "2025-11-24T23:59:43Z", "url": "https://github.com/kanaka/mal"}mal - Make a Lisp
Section titled “mal - Make a Lisp”Description
Section titled “Description”1. Mal is a Clojure inspired Lisp interpreter
2. Mal is a learning tool
Each implementation of mal is separated into 11 incremental, self-contained (and testable) steps that demonstrate core concepts of Lisp. The last step is capable of self-hosting (running the mal implementation of mal). See the [make-a-lisp process guide]!(process/guide.md).
The make-a-lisp steps are:
- [step0_repl]!(process/guide.md#step-0-the-repl)
- [step1_read_print]!(process/guide.md#step-1-read-and-print)
- [step2_eval]!(process/guide.md#step-2-eval)
- [step3_env]!(process/guide.md#step-3-environments)
- [step4_if_fn_do]!(process/guide.md#step-4-if-fn-do)
- [step5_tco]!(process/guide.md#step-5-tail-call-optimization)
- [step6_file]!(process/guide.md#step-6-files-mutation-and-evil)
- [step7_quote]!(process/guide.md#step-7-quoting)
- [step8_macros]!(process/guide.md#step-8-macros)
- [step9_try]!(process/guide.md#step-9-try)
- [stepA_mal]!(process/guide.md#step-a-metadata-self-hosting-and-interop)
Each make-a-lisp step has an associated architectural diagram. That elements that are new for that step are highlighted in red. Here is the final architecture once [step A]!(process/guide.md#stepA) is complete:
![stepA_mal architecture]!(process/steps.png)
If you are interested in creating a mal implementation (or just interested in using mal for something) you are welcome to to join our Discord. In addition to the [make-a-lisp process guide]!(process/guide.md) there is also a [mal/make-a-lisp FAQ]!(docs/FAQ.md) where I attempt to answer some common questions.
3. Mal is implemented in 89 languages (95 different implementations and 118 runtime modes)
| Language | Creator |
|---|---|
| [Ada]!(#ada) | Chris Moore |
| [Ada #2]!(#ada2) | Nicolas Boulenguez |
| [GNU Awk]!(#gnu-awk) | Mitsuru Kariya |
| [Bash 4]!(#bash-4) | Joel Martin |
| [BASIC]!(#basic-c64-and-qbasic) (C64 & QBasic) | Joel Martin |
| [BBC BASIC V]!(#bbc-basic-v) | Ben Harris |
| [C]!(#c) | Joel Martin |
| [C #2]!(#c2) | Duncan Watts |
| [C++]!(#c-1) | Stephen Thirlwall |
| [C#]!(#c-2) | Joel Martin |
| [ChucK]!(#chuck) | Vasilij Schneidermann |
| [Clojure]!(#clojure) (Clojure & ClojureScript) | Joel Martin |
| [CoffeeScript]!(#coffeescript) | Joel Martin |
| [Common Lisp]!(#common-lisp) | Iqbal Ansari |
| [Crystal]!(#crystal) | Linda_pp |
| [D]!(#d) | Dov Murik |
| [Dart]!(#dart) | Harry Terkelsen |
| [Elixir]!(#elixir) | Martin Ek |
| [Elm]!(#elm) | Jos van Bakel |
| [Emacs Lisp]!(#emacs-lisp) | Vasilij Schneidermann |
| [Erlang]!(#erlang) | Nathan Fiedler |
| [ES6]!(#es6-ecmascript-2015) (ECMAScript 2015) | Joel Martin |
| [F#]!(#f) | Peter Stephens |
| [Factor]!(#factor) | Jordan Lewis |
| [Fantom]!(#fantom) | Dov Murik |
| [Fennel]!(#fennel) | sogaiu |
| [Forth]!(#forth) | Chris Houser |
| [GNU Guile]!(#gnu-guile-21) | Mu Lei |
| [GNU Smalltalk]!(#gnu-smalltalk) | Vasilij Schneidermann |
| [Go]!(#go) | Joel Martin |
| [Groovy]!(#groovy) | Joel Martin |
| [Hare]!(#hare) | Lou Woell |
| [Haskell]!(#haskell) | Joel Martin |
| [Haxe]!(#haxe-neko-python-c-and-javascript) (Neko, Python, C++, & JS) | Joel Martin |
| [Hy]!(#hy) | Joel Martin |
| [Io]!(#io) | Dov Murik |
| [Janet]!(#janet) | sogaiu |
| [Java]!(#java-17) | Joel Martin |
| [Java Truffle]!(#java-using-truffle-for-graalvm) (Truffle/GraalVM) | Matt McGill |
| [JavaScript]!(#javascriptnode) (Demo) | Joel Martin |
| [jq]!(#jq) | Ali MohammadPur |
| [Julia]!(#julia) | Joel Martin |
| [Kotlin]!(#kotlin) | Javier Fernandez-Ivern |
| [LaTeX3]!(#latex3) | Nicolas Boulenguez |
| [LiveScript]!(#livescript) | Jos van Bakel |
| [Logo]!(#logo) | Dov Murik |
| [Lua]!(#lua) | Joel Martin |
| [GNU Make]!(#gnu-make-381) | Joel Martin |
| [mal itself]!(#mal) | Joel Martin |
| [MATLAB]!(#matlab-gnu-octave-and-matlab) (GNU Octave & MATLAB) | Joel Martin |
| [miniMAL]!(#minimal) (Repo, Demo) | Joel Martin |
| [NASM]!(#nasm) | Ben Dudson |
| [Nim]!(#nim-104) | Dennis Felsing |
| [Object Pascal]!(#object-pascal) | Joel Martin |
| [Objective C]!(#objective-c) | Joel Martin |
| [OCaml]!(#ocaml-4010) | Chris Houser |
| [Perl]!(#perl-5) | Joel Martin |
| [Perl 6]!(#perl-6) | Hinrik Örn Sigurðsson |
| [PHP]!(#php-53) | Joel Martin |
| [Picolisp]!(#picolisp) | Vasilij Schneidermann |
| [Pike]!(#pike) | Dov Murik |
| [PL/pgSQL]!(#plpgsql-postgresql-sql-procedural-language) (PostgreSQL) | Joel Martin |
| [PL/SQL]!(#plsql-oracle-sql-procedural-language) (Oracle) | Joel Martin |
| [PostScript]!(#postscript-level-23) | Joel Martin |
| [PowerShell]!(#powershell) | Joel Martin |
| [Prolog]!(#prolog-logical-language) | Nicolas Boulenguez |
| [PureScript]!(#purescript) | mrsekut |
| [Python2]!(#python2) | Joel Martin |
| [Python3]!(#python3) | Gavin Lewis |
| [RPython]!(#rpython) | Joel Martin |
| [R]!(#r) | Joel Martin |
| [Racket]!(#racket-53) | Joel Martin |
| [Rexx]!(#rexx) | Dov Murik |
| [Ruby]!(#ruby-19) | Joel Martin |
| [Ruby #2]!(#ruby) | Ryan Cook |
| [Rust]!(#rust-138) | Joel Martin |
| [Scala]!(#scala) | Joel Martin |
| [Scheme (R7RS)]!(#scheme-r7rs) | Vasilij Schneidermann |
| [Skew]!(#skew) | Dov Murik |
| [Standard ML]!(#sml) | Fabian Bergström |
| [Swift 3]!(#swift-3) | Joel Martin |
| [Swift 4]!(#swift-4) | 陆遥 |
| [Swift 6]!(#swift-6) | Oleg Montak |
| [Tcl]!(#tcl-86) | Dov Murik |
| [TypeScript]!(#typescript) | Masahiro Wakame |
| [Vala]!(#vala) | Simon Tatham |
| [VHDL]!(#vhdl) | Dov Murik |
| [Vimscript]!(#vimscript) | Dov Murik |
| [Visual Basic.NET]!(#visual-basicnet) | Joel Martin |
| [Visual Basic Script]!(#visual-basic-script) | 刘百超 |
| [WebAssembly]!(#webassembly-wasm) (wasm) | Joel Martin |
| [Wren]!(#wren) | Dov Murik |
| [XSLT]!(#xslt) | Ali MohammadPur |
| [Yorick]!(#yorick) | Dov Murik |
| [Zig]!(#zig) | Josh Tobin |
Presentations
Section titled “Presentations”Mal was presented publicly for the first time in a lightning talk at Clojure West 2014 (unfortunately there is no video). See examples/clojurewest2014.mal for the presentation that was given at the conference (yes, the presentation is a mal program).
At Midwest.io 2015, Joel Martin gave a presentation on Mal titled “Achievement Unlocked: A Better Path to Language Learning”. Video, Slides.
More recently Joel gave a presentation on “Make Your Own Lisp Interpreter in 10 Incremental Steps” at LambdaConf 2016: Part 1, Part 2, Part 3, Part 4, Slides.
Building/running implementations
Section titled “Building/running implementations”The simplest way to run any given implementation is to use docker. Every implementation has a docker image pre-built with language dependencies installed. You can launch the REPL using a convenient target in the top level Makefile (where IMPL is the implementation directory name and stepX is the step to run):
make DOCKERIZE=1 "repl^IMPL^stepX" # OR stepA is the default step:make DOCKERIZE=1 "repl^IMPL"External / Alternate Implementations
Section titled “External / Alternate Implementations”The following implementations are maintained as separate projects:
- by Tim Morgan
- by vi - using Pest grammar, not using typical Mal infrastructure (cargo-ized steps and built-in converted tests).
Swift 2
Section titled “Swift 2”- by Keith Rollin - This implementation used to be in the repo. However, Swift 2 is no longer easily buildable/testable.
- by Ali Mohammad Pur - The Q implementation works fine but it requires a proprietary manual download that can’t be Dockerized (or integrated into the mal CI pipeline) so for now it remains a separate project.
Other mal Projects
Section titled “Other mal Projects”- malc - Mal (Make A Lisp) compiler. Compiles a Mal program to LLVM assembly language, then binary.
- malcc - malcc is an incremental compiler implementation for the Mal language. It uses the Tiny C Compiler as the compiler backend and has full support for the Mal language, including macros, tail-call elimination, and even run-time eval. “I Built a Lisp Compiler” post about the process.
- frock - Clojure-flavoured PHP. Uses mal/php to run programs.
- flk - A LISP that runs wherever Bash is
- glisp - Self-bootstrapping graphic design tool on Lisp. Live Demo
- mal2py-compiler - MAL-to-Python. A fork of the python3 implementation that compiles mal to python with a 16x performance improvement on the perf3 synthetic benchmark.
Implementation Details
Section titled “Implementation Details”The Ada implementation was developed with GNAT 4.9 on debian. It also compiles unchanged on windows if you have windows versions of git, GNAT and (optionally) make. There are no external dependencies (readline not implemented).
cd impls/adamake./stepX_YYYThe second Ada implementation was developed with GNAT 8 and links with the GNU readline library.
cd impls/adamake./stepX_YYYGNU awk
Section titled “GNU awk”The GNU awk implementation of mal has been tested with GNU awk 4.1.1.
cd impls/gawkgawk -O -f stepX_YYY.awkBash 4
Section titled “Bash 4”cd impls/bashbash stepX_YYY.shBASIC (C64 and QBasic)
Section titled “BASIC (C64 and QBasic)”The BASIC implementation uses a preprocessor that can generate BASIC code that is compatible with both C64 BASIC (CBM v2) or QBasic. The C64 mode has been tested with cbmbasic (the patched version is currently required to fix issues with line input) and the QBasic mode has been tested with [FreeBASIC]!(freebasic.net).
Generate C64 code and run it using cbmbasic:
cd impls/basicmake MODE=cbm stepX_YYY.basSTEP=stepX_YYY basic_MODE=cbm ./runGenerate QBasic code, compile using FreeBASIC, and execute it:
cd impls/basicmake MODE=qbasic stepX_YYY.basmake MODE=qbasic stepX_YYY./stepX_YYYThanks to Steven Syrek for the original inspiration for this implementation.
BBC BASIC V
Section titled “BBC BASIC V”The BBC BASIC V implementation can run in the Brandy interpreter:
cd impls/bbc-basicbrandy -quit stepX_YYY.bbcOr in ARM BBC BASIC V under RISC OS 3 or later:
*Dir bbc-basic.riscos*Run setup*Run stepX_YYYThe C implementation of mal requires the following libraries (lib and header packages): glib, libffi6, libgc, and either the libedit or GNU readline library.
cd impls/cmake./stepX_YYYThe second C implementation of mal requires the following libraries (lib and header packages): libedit, libgc, libdl, and libffi.
cd impls/c.2make./stepX_YYYThe C++ implementation of mal requires g++-4.9 or clang++-3.5 and
a readline compatible library to build. See the cpp/README.md for
more details:
cd impls/cppmake # ORmake CXX=clang++-3.5./stepX_YYYThe C# implementation of mal has been tested on Linux using the Mono C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are required to build and run the C# implementation.
cd impls/csmakemono ./stepX_YYY.exeThe ChucK implementation has been tested with ChucK 1.3.5.2.
cd impls/chuck./runClojure
Section titled “Clojure”For the most part the Clojure implementation requires Clojure 1.5, however, to pass all tests, Clojure 1.8.0-RC4 is required.
cd impls/clojurelein with-profile +stepX trampoline runCoffeeScript
Section titled “CoffeeScript”sudo npm install -g coffee-scriptcd impls/coffeecoffee ./stepX_YYYCommon Lisp
Section titled “Common Lisp”The implementation has been tested with SBCL, CCL, CMUCL, GNU CLISP, ECL and Allegro CL on Ubuntu 16.04 and Ubuntu 12.04, see the [README]!(impls/common-lisp/README.org) for more details. Provided you have the dependencies mentioned installed, do the following to run the implementation
cd impls/common-lispmake./runCrystal
Section titled “Crystal”The Crystal implementation of mal has been tested with Crystal 0.26.1.
cd impls/crystalcrystal run ./stepX_YYY.cr # ORmake # needed to run tests./stepX_YYYThe D implementation of mal was tested with GDC 4.8. It requires the GNU readline library.
cd impls/dmake./stepX_YYYThe Dart implementation has been tested with Dart 1.20.
cd impls/dartdart ./stepX_YYYEmacs Lisp
Section titled “Emacs Lisp”The Emacs Lisp implementation of mal has been tested with Emacs 24.3
and 24.5. While there is very basic readline editing (<backspace>
and C-d work, C-c cancels the process), it is recommended to use
rlwrap.
cd impls/elispemacs -Q --batch --load stepX_YYY.el# with full readline supportrlwrap emacs -Q --batch --load stepX_YYY.elElixir
Section titled “Elixir”The Elixir implementation of mal has been tested with Elixir 1.0.5.
cd impls/elixirmix stepX_YYY# Or with readline/line editing functionality:iex -S mix stepX_YYYThe Elm implementation of mal has been tested with Elm 0.18.0
cd impls/elmmake stepX_YYY.jsSTEP=stepX_YYY ./runErlang
Section titled “Erlang”The Erlang implementation of mal requires Erlang/OTP R17 and rebar to build.
cd impls/erlangmake # ORMAL_STEP=stepX_YYY rebar compile escriptize # build individual step./stepX_YYYES6 (ECMAScript 2015)
Section titled “ES6 (ECMAScript 2015)”The ES6 / ECMAScript 2015 implementation uses the babel compiler to generate ES5 compatible JavaScript. The generated code has been tested with Node 0.12.4.
cd impls/es6makenode build/stepX_YYY.jsThe F# implementation of mal has been tested on Linux using the Mono F# compiler (fsharpc) and the Mono runtime (version 3.12.1). The mono C# compiler (mcs) is also necessary to compile the readline dependency. All are required to build and run the F# implementation.
cd impls/fsharpmakemono ./stepX_YYY.exeFactor
Section titled “Factor”The Factor implementation of mal has been tested with Factor 0.97 (factorcode.org).
cd impls/factorFACTOR_ROOTS=. factor -run=stepX_YYYFantom
Section titled “Fantom”The Fantom implementation of mal has been tested with Fantom 1.0.70.
cd impls/fantommake lib/fan/stepX_YYY.podSTEP=stepX_YYY ./runFennel
Section titled “Fennel”The Fennel implementation of mal has been tested with Fennel version 0.9.1 on Lua 5.4.
cd impls/fennelfennel ./stepX_YYY.fnlcd impls/forthgforth stepX_YYY.fsGNU Guile 2.1+
Section titled “GNU Guile 2.1+”cd impls/guileguile -L ./ stepX_YYY.scmGNU Smalltalk
Section titled “GNU Smalltalk”The Smalltalk implementation of mal has been tested with GNU Smalltalk 3.2.91.
cd impls/gnu-smalltalk./runThe Go implementation of mal requires that go is installed on on the path. The implementation has been tested with Go 1.3.1.
cd impls/gomake./stepX_YYYGroovy
Section titled “Groovy”The Groovy implementation of mal requires Groovy to run and has been tested with Groovy 1.8.6.
cd impls/groovymakegroovy ./stepX_YYY.groovyThe hare implementation was tested against Hare 0.25.2.
cd impls/haremake./stepX_YYYHaskell
Section titled “Haskell”The Haskell implementation requires the ghc compiler version 7.10.1 or later and also the Haskell parsec and readline (or editline) packages.
cd impls/haskellmake./stepX_YYYHaxe (Neko, Python, C++ and JavaScript)
Section titled “Haxe (Neko, Python, C++ and JavaScript)”The Haxe implementation of mal requires Haxe version 3.2 to compile. Four different Haxe targets are supported: Neko, Python, C++, and JavaScript.
cd impls/haxe# Nekomake all-nekoneko ./stepX_YYY.n# Pythonmake all-pythonpython3 ./stepX_YYY.py# C++make all-cpp./cpp/stepX_YYY# JavaScriptmake all-jsnode ./stepX_YYY.jsThe Hy implementation of mal has been tested with Hy 0.13.0.
cd impls/hy./stepX_YYY.hyThe Io implementation of mal has been tested with Io version 20110905.
cd impls/ioio ./stepX_YYY.ioThe Janet implementation of mal has been tested with Janet version 1.12.2.
cd impls/janetjanet ./stepX_YYY.janetJava 1.7
Section titled “Java 1.7”The Java implementation of mal requires maven2 to build.
cd impls/javamvn compilemvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY # ORmvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"Java, using Truffle for GraalVM
Section titled “Java, using Truffle for GraalVM”This Java implementation will run on OpenJDK, but can run as much as 30x faster on GraalVM thanks to the Truffle framework. It’s been tested with OpenJDK 11, GraalVM CE 20.1.0, and GraalVM CE 21.1.0.
cd impls/java-truffle./gradlew buildSTEP=stepX_YYY ./runJavaScript/Node
Section titled “JavaScript/Node”cd impls/jsnpm installnode stepX_YYY.jsThe Julia implementation of mal requires Julia 0.4.
cd impls/juliajulia stepX_YYY.jlTested against version 1.6, with a lot of cheating in the IO department
cd impls/jqSTEP=stepA_YYY ./run # with DebugDEBUG=true STEP=stepA_YYY ./runKotlin
Section titled “Kotlin”The Kotlin implementation of mal has been tested with Kotlin 1.0.
cd impls/kotlinmakejava -jar stepX_YYY.jarLaTeX3
Section titled “LaTeX3”The LaTeX3 implementation of mal has been tested with pdfTeX 3.141592653-2.6-1.40.24.
Self hosting is too slow for any sensible timeout, and crashes in step4, apparently because of hard-coded limitations.
Anybody working on this should uncomment the two lines of (slow) debugging options in the step file, and export DEBUG=1 (for more output than tests accept).
LiveScript
Section titled “LiveScript”The LiveScript implementation of mal has been tested with LiveScript 1.5.
cd impls/livescriptmakenode_modules/.bin/lsc stepX_YYY.lsThe Logo implementation of mal has been tested with UCBLogo 6.0.
cd impls/logologo stepX_YYY.lgThe Lua implementation of mal has been tested with Lua 5.3.5 The implementation requires luarocks to be installed.
cd impls/luamake # to build and link linenoise.so and rex_pcre.so./stepX_YYY.luaRunning the mal implementation of mal involves running stepA of one of the other implementations and passing the mal step to run as a command line argument.
cd impls/IMPLIMPL_STEPA_CMD ../mal/stepX_YYY.malGNU Make 3.81
Section titled “GNU Make 3.81”cd impls/makemake -f stepX_YYY.mkThe NASM implementation of mal is written for x86-64 Linux, and has been tested with Linux 3.16.0-4-amd64 and NASM version 2.11.05.
cd impls/nasmmake./stepX_YYYNim 1.0.4
Section titled “Nim 1.0.4”The Nim implementation of mal has been tested with Nim 1.0.4.
cd impls/nimmake # ORnimble build./stepX_YYYObject Pascal
Section titled “Object Pascal”The Object Pascal implementation of mal has been built and tested on Linux using the Free Pascal compiler version 2.6.2 and 2.6.4.
cd impls/objpascalmake./stepX_YYYObjective C
Section titled “Objective C”The Objective C implementation of mal has been built and tested on Linux using clang/LLVM 3.6. It has also been built and tested on OS X using Xcode 7.
cd impls/objcmake./stepX_YYYOCaml 4.01.0
Section titled “OCaml 4.01.0”cd impls/ocamlmake./stepX_YYYMATLAB (GNU Octave and MATLAB)
Section titled “MATLAB (GNU Octave and MATLAB)”The MatLab implementation has been tested with GNU Octave 4.2.1. It has also been tested with MATLAB version R2014a on Linux. Note that MATLAB is a commercial product.
cd impls/matlab./stepX_YYYoctave -q --no-gui --no-history --eval "stepX_YYY();quit;"matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;" # OR with command line argumentsoctave -q --no-gui --no-history --eval "stepX_YYY('arg1','arg2');quit;"matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"miniMAL
Section titled “miniMAL”miniMAL is small Lisp interpreter implemented in less than 1024 bytes of JavaScript. To run the miniMAL implementation of mal you need to download/install the miniMAL interpreter (which requires Node.js).
cd impls/miniMAL# Download miniMAL and dependenciesnpm installexport PATH=`pwd`/node_modules/minimal-lisp/:$PATH# Now run mal implementation in miniMALminiMAL ./stepX_YYYPerl 5
Section titled “Perl 5”The Perl 5 implementation should work with perl 5.19.3 and later.
For readline line editing support, install Term::ReadLine::Perl or Term::ReadLine::Gnu from CPAN.
cd impls/perlperl stepX_YYY.plPerl 6
Section titled “Perl 6”The Perl 6 implementation was tested on Rakudo Perl 6 2016.04.
cd impls/perl6perl6 stepX_YYY.plPHP 5.3
Section titled “PHP 5.3”The PHP implementation of mal requires the php command line interface to run.
cd impls/phpphp stepX_YYY.phpPicolisp
Section titled “Picolisp”The Picolisp implementation requires libreadline and Picolisp 3.1.11 or later.
cd impls/picolisp./runThe Pike implementation was tested on Pike 8.0.
cd impls/pikepike stepX_YYY.pikePL/pgSQL (PostgreSQL SQL Procedural Language)
Section titled “PL/pgSQL (PostgreSQL SQL Procedural Language)”The PL/pgSQL implementation of mal requires a running PostgreSQL server (the “kanaka/mal-test-plpgsql” docker image automatically starts a PostgreSQL server). The implementation connects to the PostgreSQL server and create a database named “mal” to store tables and stored procedures. The wrapper script uses the psql command to connect to the server and defaults to the user “postgres” but this can be overridden with the PSQL_USER environment variable. A password can be specified using the PGPASSWORD environment variable. The implementation has been tested with PostgreSQL 9.4.
cd impls/plpgsql./wrap.sh stepX_YYY.sql # ORPSQL_USER=myuser PGPASSWORD=mypass ./wrap.sh stepX_YYY.sqlPL/SQL (Oracle SQL Procedural Language)
Section titled “PL/SQL (Oracle SQL Procedural Language)”The PL/SQL implementation of mal requires a running Oracle DB server (the “kanaka/mal-test-plsql” docker image automatically starts an Oracle Express server). The implementation connects to the Oracle server to create types, tables and stored procedures. The default SQL*Plus logon value (username/password@connect_identifier) is “system/oracle” but this can be overridden with the ORACLE_LOGON environment variable. The implementation has been tested with Oracle Express Edition 11g Release 2. Note that any SQL*Plus connection warnings (user password expiration, etc) will interfere with the ability of the wrapper script to communicate with the DB.
cd impls/plsql./wrap.sh stepX_YYY.sql # ORORACLE_LOGON=myuser/mypass@ORCL ./wrap.sh stepX_YYY.sqlPostScript Level 2/3
Section titled “PostScript Level 2/3”The PostScript implementation of mal requires Ghostscript to run. It has been tested with Ghostscript 9.10.
cd impls/psgs -q -dNODISPLAY -I./ stepX_YYY.psPowerShell
Section titled “PowerShell”The PowerShell implementation of mal requires the PowerShell script language. It has been tested with PowerShell 6.0.0 Alpha 9 on Linux.
cd impls/powershellpowershell ./stepX_YYY.ps1Prolog
Section titled “Prolog”The Prolog implementation uses some constructs specific to SWI-Prolog, includes readline support and has been tested on Debian GNU/Linux with version 8.2.1.
cd impls/prologswipl stepX_YYYPureScript
Section titled “PureScript”The PureScript implementation requires the spago compiler version 0.20.2.
cd impls/pursmakenode ./stepX_YYY.jsPython2
Section titled “Python2”This implementation only uses python2 features, but avoids incompatibilities with python3.
Python3
Section titled “Python3”This implementation is checked for style and types (flake8, pylint, mypy). It reports all errors with details. It demonstrates iterators, decorators, functional tools, chain maps, dataclasses, introspection, match statements, assignement expressions.
RPython
Section titled “RPython”You must have rpython on your path (included with pypy).
cd impls/rpythonmake # this takes a very long time./stepX_YYYThe R implementation of mal requires R (r-base-core) to run.
cd impls/rmake libs # to download and build rdyncallRscript stepX_YYY.rRacket (5.3)
Section titled “Racket (5.3)”The Racket implementation of mal requires the Racket compiler/interpreter to run.
cd impls/racket./stepX_YYY.rktThe Rexx implementation of mal has been tested with Regina Rexx 3.6.
cd impls/rexxmakerexx -a ./stepX_YYY.rexxppRuby (1.9+)
Section titled “Ruby (1.9+)”cd impls/rubyruby stepX_YYY.rbRuby #2
Section titled “Ruby #2”A second Ruby implementation with the following goals:
- No global variables
- No modification (monkey-patching) of core Ruby classes
- Modularized into the
Malmodule namespace
cd impls/ruby.2ruby stepX_YYY.rbRust (1.38+)
Section titled “Rust (1.38+)”The rust implementation of mal requires the rust compiler and build tool (cargo) to build.
cd impls/rustcargo run --release --bin stepX_YYYInstall scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
cd impls/scalasbt 'run-main stepX_YYY' # ORsbt compilescala -classpath target/scala*/classes stepX_YYYScheme (R7RS)
Section titled “Scheme (R7RS)”The Scheme implementation of MAL has been tested with Chibi-Scheme
0.10, Kawa 3.1.1, Gauche 0.9.6, CHICKEN 5.1.0, Sagittarius 0.9.7,
Cyclone 0.32.0 (Git version) and Foment 0.4 (Git version). You should
be able to get it running on other conforming R7RS implementations
after figuring out how libraries are loaded and adjusting the
Makefile and run script accordingly.
cd impls/scheme# chibischeme_MODE=chibi ./run# kawamake kawascheme_MODE=kawa ./run# gauchescheme_MODE=gauche ./run# chickenmake chickenscheme_MODE=chicken ./run# sagittariusscheme_MODE=sagittarius ./run# cyclonemake cyclonescheme_MODE=cyclone ./run# fomentscheme_MODE=foment ./runThe Skew implementation of mal has been tested with Skew 0.7.42.
cd impls/skewmakenode stepX_YYY.jsStandard ML (Poly/ML, MLton, Moscow ML)
Section titled “Standard ML (Poly/ML, MLton, Moscow ML)”The Standard ML implementation of mal requires an SML97 implementation. The Makefile supports Poly/ML, MLton, Moscow ML, and has been tested with Poly/ML 5.8.1, MLton 20210117, and Moscow ML version 2.10.
cd impls/sml# Poly/MLmake sml_MODE=polyml./stepX_YYY# MLtonmake sml_MODE=mlton./stepX_YYY# Moscow MLmake sml_MODE=mosml./stepX_YYYSwift 3
Section titled “Swift 3”The Swift 3 implementation of mal requires the Swift 3.0 compiler. It has been tested with Swift 3 Preview 3.
cd impls/swift3make./stepX_YYYSwift 4
Section titled “Swift 4”The Swift 4 implementation of mal requires the Swift 4.0 compiler. It has been tested with Swift 4.2.3 release.
cd impls/swift4make./stepX_YYYSwift 5
Section titled “Swift 5”The Swift 5 implementation of mal requires the Swift 5.0 compiler. It has been tested with Swift 5.1.1 release.
cd impls/swift6swift run stepX_YYYTcl 8.6
Section titled “Tcl 8.6”The Tcl implementation of mal requires Tcl 8.6 to run. For readline line editing support, install tclreadline.
cd impls/tcltclsh ./stepX_YYY.tclTypeScript
Section titled “TypeScript”The TypeScript implementation of mal requires the TypeScript 2.2 compiler. It has been tested with Node.js v6.
cd impls/tsmakenode ./stepX_YYY.jsThe Vala implementation of mal has been tested with the Vala 0.40.8
compiler. You will need to install valac and libreadline-dev or
equivalent.
cd impls/valamake./stepX_YYYThe VHDL implementation of mal has been tested with GHDL 0.29.
cd impls/vhdlmake./run_vhdl.sh ./stepX_YYYVimscript
Section titled “Vimscript”The Vimscript implementation of mal requires Vim 8.0 to run.
cd impls/vimscript./run_vimscript.sh ./stepX_YYY.vimVisual Basic.NET
Section titled “Visual Basic.NET”The VB.NET implementation of mal has been tested on Linux using the Mono VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are required to build and run the VB.NET implementation.
cd impls/vbmakemono ./stepX_YYY.exeVisual Basic Script
Section titled “Visual Basic Script”The VBScript implementation of mal has been tested on Windows 10 1909.
install.vbs can help you install the requirements (.NET 2.0 3.0 3.5).
If you havn’t install .NET 2.0 3.0 3.5, it will popup a window for installation.
If you already installed that, it will do nothing.
cd impls\vbsinstall.vbscscript -nologo stepX_YYY.vbsWebAssembly (wasm)
Section titled “WebAssembly (wasm)”The WebAssembly implementation is written in Wam (WebAssembly Macro language) and runs under several different non-web embeddings (runtimes): node, wasmtime, wasmer, wax, wace, warpy.
cd impls/wasm# nodemake wasm_MODE=node./run.js ./stepX_YYY.wasm# wasmtimemake wasm_MODE=wasmtimewasmtime --dir=./ --dir=../ --dir=/ ./stepX_YYY.wasm# wasmermake wasm_MODE=wasmerwasmer run --dir=./ --dir=../ --dir=/ ./stepX_YYY.wasm# waxmake wasm_MODE=waxwax ./stepX_YYY.wasm# wacemake wasm_MODE=wace_libcwace ./stepX_YYY.wasm# warpymake wasm_MODE=warpywarpy --argv --memory-pages 256 ./stepX_YYY.wasmThe XSLT implementation of mal is written with XSLT 3 and tested on Saxon 9.9.1.6 Home Edition.
cd impls/xsltSTEP=stepX_YY ./runThe Wren implementation of mal was tested on Wren 0.2.0.
cd impls/wrenwren ./stepX_YYY.wrenYorick
Section titled “Yorick”The Yorick implementation of mal was tested on Yorick 2.2.04.
cd impls/yorickyorick -batch ./stepX_YYY.iThe Zig implementation of mal was tested on Zig 0.5.
cd impls/zigzig build stepX_YYYRunning tests
Section titled “Running tests”The top level Makefile has a number of useful targets to assist with
implementation development and testing. The help target provides
a list of the targets and options:
make helpFunctional tests
Section titled “Functional tests”The are almost 800 generic functional tests (for all implementations)
in the tests/ directory. Each step has a corresponding test file
containing tests specific to that step. The runtest.py test harness
launches a Mal step implementation and then feeds the tests one at
a time to the implementation and compares the output/return value to
the expected output/return value.
- To run all the tests across all implementations (be prepared to wait):
make test- To run all tests against a single implementation:
make "test^IMPL"
# e.g.make "test^clojure"make "test^js"- To run tests for a single step against all implementations:
make "test^stepX"
# e.g.make "test^step2"make "test^step7"- To run tests for a specific step against a single implementation:
make "test^IMPL^stepX"
make "test^ruby^step3"make "test^ps^step4"Self-hosted functional tests
Section titled “Self-hosted functional tests”- To run the functional tests in self-hosted mode, you specify
malas the test implementation and use theMAL_IMPLmake variable to change the underlying host language (default is JavaScript):
make MAL_IMPL=IMPL "test^mal^step2"
# e.g.make "test^mal^step2" # js is defaultmake MAL_IMPL=ruby "test^mal^step2"make MAL_IMPL=python3 "test^mal^step2"Starting the REPL
Section titled “Starting the REPL”- To start the REPL of an implementation in a specific step:
make "repl^IMPL^stepX"
make "repl^ruby^step3"make "repl^ps^step4"- If you omit the step, then
stepAis used:
make "repl^IMPL"
make "repl^ruby"make "repl^ps"- To start the REPL of the self-hosted implementation, specify
malas the REPL implementation and use theMAL_IMPLmake variable to change the underlying host language (default is JavaScript):
make MAL_IMPL=IMPL "repl^mal^stepX"
# e.g.make "repl^mal^step2" # js is defaultmake MAL_IMPL=ruby "repl^mal^step2"make MAL_IMPL=python3 "repl^mal"Performance tests
Section titled “Performance tests”Warning: These performance tests are neither statistically valid nor comprehensive; runtime performance is a not a primary goal of mal. If you draw any serious conclusions from these performance tests, then please contact me about some amazing oceanfront property in Kansas that I’m willing to sell you for cheap.
- To run performance tests against a single implementation:
make "perf^IMPL"
# e.g.make "perf^js"- To run performance tests against all implementations:
make "perf"Generating language statistics
Section titled “Generating language statistics”- To report line and byte statistics for a single implementation:
make "stats^IMPL"
# e.g.make "stats^js"Dockerized testing
Section titled “Dockerized testing”Every implementation directory contains a Dockerfile to create a docker image containing all the dependencies for that implementation. In addition, the top-level Makefile contains support for running the tests target (and perf, stats, repl, etc) within a docker container for that implementation by passing “DOCKERIZE=1” on the make command line. For example:
make DOCKERIZE=1 "test^js^step3"Existing implementations already have docker images built and pushed to the docker registry. However, if you wish to build or rebuild a docker image locally, the toplevel Makefile provides a rule for building docker images:
make "docker-build^IMPL"Notes:
- Docker images are named “ghcr.io/kanaka/mal-test-IMPL”
- JVM-based language implementations (Groovy, Java, Clojure, Scala):
you will probably need to run this command once manually
first
make DOCKERIZE=1 "repl^IMPL"before you can run tests because runtime dependencies need to be downloaded to avoid the tests timing out. These dependencies are downloaded to dot-files in the /mal directory so they will persist between runs.
License
Section titled “License”Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public License 2.0). See LICENSE.txt for more details.