5 Mal is a Clojure inspired Lisp interpreter.
7 Mal is implemented in 31 different languages:
20 * JavaScript ([Online Demo](http://kanaka.github.io/mal))
26 * [miniMAL](https://github.com/kanaka/miniMAL)
42 Mal is a learning tool. See the [make-a-lisp process
43 guide](process/guide.md). Each implementation of mal is separated into
44 11 incremental, self-contained (and testable) steps that demonstrate
45 core concepts of Lisp. The last step is capable of self-hosting
46 (running the mal implementation of mal).
48 The mal (make a lisp) steps are:
50 * [step0_repl](process/guide.md#step0)
51 * [step1_read_print](process/guide.md#step1)
52 * [step2_eval](process/guide.md#step2)
53 * [step3_env](process/guide.md#step3)
54 * [step4_if_fn_do](process/guide.md#step4)
55 * [step5_tco](process/guide.md#step5)
56 * [step6_file](process/guide.md#step6)
57 * [step7_quote](process/guide.md#step7)
58 * [step8_macros](process/guide.md#step8)
59 * [step9_try](process/guide.md#step9)
60 * [stepA_mal](process/guide.md#stepA)
63 Mal was presented publicly for the first time in a lightning talk at
64 Clojure West 2014 (unfortunately there is no video). See
65 mal/clojurewest2014.mal for the presentation that was given at the
66 conference (yes the presentation is a mal program).
68 If you are interesting in creating a mal implementation (or just
69 interested in using mal for something), please drop by the #mal
70 channel on freenode. In addition to the [make-a-lisp process
71 guide](process/guide.md) there is also a [mal/make-a-lisp
72 FAQ](docs/FAQ.md) where I attempt to answer some common questions.
74 ## Building/running implementations
85 The C implementation of mal requires the following libraries (lib and
86 header packages): glib, libffi6 and either the libedit or GNU readline library.
96 *The C++ implementation was created by [Stephen Thirlwall (sdt)](https://github.com/sdt)*
98 The C++ implementation of mal requires g++-4.9 or clang++-3.5 and
99 a readline compatible library to build. See the `cpp/README.md` for
113 The C# implementation of mal has been tested on Linux using the Mono
114 C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
115 required to build and run the C# implementation.
128 lein with-profile +stepX trampoline run
134 sudo npm install -g coffee-script
141 *The Factor implementation was created by [Jordan Lewis (jordanlewis)](https://github.com/jordanlewis)*
143 The Factor implementation of mal has been tested with Factor 0.97
144 ([factorcode.org](factorcode.org)).
148 FACTOR_ROOTS=src factor -run=stepX_YYY
153 *The Forth implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
162 The Go implementation of mal requires that go is installed on on the
163 path. The implementation has been tested with Go 1.3.1.
174 Install the Haskell compiler (ghc/ghci), the Haskell platform and
175 either the editline package (BSD) or the readline package (GPL). On
176 Ubuntu these packages are: ghc, haskell-platform,
177 libghc-readline-dev/libghc-editline-dev
188 The Java implementation of mal requires maven2 to build.
193 mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
195 mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
208 The Julia implementation of mal has been tested with Julia 0.3.7.
217 Running the Lua implementation of mal requires lua 5.1 or later,
218 luarocks and the lua-rex-pcre library installed.
222 make # to build and link linenoise.so
228 Running the mal implementation of mal involves running stepA of one of
229 the other implementations and passing the mal step to run as a command
234 IMPL_STEPA_CMD ../mal/stepX_YYY.mal
247 *The Nim implementation was created by [Dennis Felsing (def-)](https://github.com/def-)*
249 Running the Nim implementation of mal requires Nim's current devel branch
250 (0.10.3) or later, and the nre library installed.
262 *The OCaml implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
272 The MATLAB implementation of mal has been tested with MATLAB version
273 R2014a on Linux. Note that MATLAB is a commercial product. It should
274 be fairly simple to support GNU Octave once it support classdef object
280 matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
281 # OR with command line arguments
282 matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
287 [miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
288 implemented in less than 1024 bytes of JavaScript. To run the miniMAL
289 implementation of mal you need to download/install the miniMAL
290 interpreter (which requires Node.js).
293 # Download miniMAL and dependencies
295 export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
296 # Now run mal implementation in miniMAL
302 For readline line editing support, install Term::ReadLine::Perl or
303 Term::ReadLine::Gnu from CPAN.
313 The PHP implementation of mal requires the php command line interface
321 ### Postscript Level 2/3
323 The Postscript implementation of mal requires ghostscript to run. It
324 has been tested with ghostscript 9.10.
328 gs -q -dNODISPLAY -I./ stepX_YYY.ps
340 The R implementation of mal requires R (r-base-core) to run.
344 make libs # to download and build rdyncall
350 The Racket implementation of mal requires the Racket
351 compiler/interpreter to run.
365 ### Rust (1.0.0 nightly)
367 The rust implementation of mal requires the rust compiler and build
368 tool (cargo) to build.
372 cargo run --release --bin stepX_YYY
377 Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
381 sbt 'run-main stepX_YYY'
384 scala -classpath target/scala*/classes stepX_YYY
389 *The Swift implementation was created by [Keith Rollin](https://github.com/keith-rollin)*
391 The Swift implemenation of mal requires the Swift compiler (XCode) to
400 ### Visual Basic.NET ###
402 The VB.NET implementation of mal has been tested on Linux using the Mono
403 VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
404 required to build and run the VB.NET implementation.
418 The are nearly 500 generic functional tests (for all implementations)
419 in the `tests/` directory. Each step has a corresponding test file
420 containing tests specific to that step. The `runtest.py` test harness
421 launches a Mal step implementation and then feeds the tests one at
422 a time to the implementation and compares the output/return value to
423 the expected output/return value.
425 To simplify the process of running tests, a top level Makefile is
426 provided with convenient test targets.
428 * To run all the tests across all implementations (be prepared to wait):
434 * To run all tests against a single implementation:
444 * To run tests for a single step against all implementations:
454 * To run tests for a specifc step against a single implementation:
464 ### Self-hosted functional tests
466 * To run the functional tests in self-hosted mode, you specify `mal`
467 as the test implementation and use the `MAL_IMPL` make variable
468 to change the underlying host language (default is JavaScript):
470 make MAL_IMPL=IMPL test^mal^step2
473 make test^mal^step2 # js is default
474 make MAL_IMPL=ruby test^mal^step2
475 make MAL_IMPL=python test^mal^step2
479 ### Performance tests
481 Warning: These performance tests are neither statistically valid nor
482 comprehensive; runtime performance is a not a primary goal of mal. If
483 you draw any serious conclusions from these performance tests, then
484 please contact me about some amazing oceanfront property in Kansas
485 that I'm willing to sell you for cheap.
487 * To run performance tests against a single implementation:
495 * To run performance tests against all implementations:
500 ### Generating language statistics
502 * To report line and byte stastics for a single implementation:
510 * To report line and bytes stastics for general Lisp code (env, core
519 ## Docker test environment
521 There is a Dockerfile included in the `tests/docker` directory that
522 builds a docker image based on Ubuntu Utopic that contains everything
523 needed to run tests against all the implementations (except for MATLAB
524 which is proprietary/licensed).
526 Build the the docker image using a provided script. WARNING: this will
527 likely take over an hour to build from scratch and use more 3 GB of disk:
529 ./tests/docker-build.sh
532 Launch a docker container from that image built above. This will
533 volume mount the mal directory to `/mal` and then give you a bash
534 prompt in the container. You can then run individual mal
535 implementations and tests:
537 ./tests/docker-run.sh
540 You can also specify a command to run within the container. For
541 example, to run step2 tests for every implementation (except MATLAB):
543 ./tests/docker-run.sh make SKIP_IMPLS="matlab" test^step2
547 * JVM-based language implementations (Java, Clojure, Scala): you will
548 need to run these implementations once manually first before you can
549 run tests because runtime dependencies need to be downloaded to
550 avoid the tests timing out. These dependencies are download to
551 dot-files in the /mal directory so they will persist between runs.
552 * Compiled languages: if your host system is different enough from
553 Ubuntu Utopic then you may need to re-compile your compiled
554 languages from within the container to avoid linker version
560 Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
561 License 2.0). See LICENSE.txt for more details.