5 Mal is a Clojure inspired Lisp interpreter.
7 Mal is implemented in 30 different languages:
19 * JavaScript ([Online Demo](http://kanaka.github.io/mal))
25 * [miniMAL](https://github.com/kanaka/miniMAL)
41 Mal is a learning tool. See the [make-a-lisp process
42 guide](process/guide.md). Each implementation of mal is separated into
43 11 incremental, self-contained (and testable) steps that demonstrate
44 core concepts of Lisp. The last step is capable of self-hosting
45 (running the mal implementation of mal).
47 The mal (make a lisp) steps are:
49 * [step0_repl](process/guide.md#step0)
50 * [step1_read_print](process/guide.md#step1)
51 * [step2_eval](process/guide.md#step2)
52 * [step3_env](process/guide.md#step3)
53 * [step4_if_fn_do](process/guide.md#step4)
54 * [step5_tco](process/guide.md#step5)
55 * [step6_file](process/guide.md#step6)
56 * [step7_quote](process/guide.md#step7)
57 * [step8_macros](process/guide.md#step8)
58 * [step9_try](process/guide.md#step9)
59 * [stepA_mal](process/guide.md#stepA)
62 Mal was presented publicly for the first time in a lightning talk at
63 Clojure West 2014 (unfortunately there is no video). See
64 mal/clojurewest2014.mal for the presentation that was given at the
65 conference (yes the presentation is a mal program).
67 If you are interesting in creating a mal implementation (or just
68 interested in using mal for something), please drop by the #mal
69 channel on freenode. In addition to the [make-a-lisp process
70 guide](process/guide.md) there is also a [mal/make-a-lisp
71 FAQ](docs/FAQ.md) where I attempt to answer some common questions.
73 ## Building/running implementations
84 The C implementation of mal requires the following libraries (lib and
85 header packages): glib, libffi6 and either the libedit or GNU readline library.
95 *The C++ implementation was created by [Stephen Thirlwall (sdt)](https://github.com/sdt)*
97 The C++ implementation of mal requires g++-4.9 or clang++-3.5 and
98 a readline compatible library to build. See the `cpp/README.md` for
112 The C# implementation of mal has been tested on Linux using the Mono
113 C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
114 required to build and run the C# implementation.
127 lein with-profile +stepX trampoline run
133 sudo npm install -g coffee-script
140 *The Nim implementation was created by [Jordan Lewis (jordanlewis)](https://github.com/jordanlewis)*
144 FACTOR_ROOTS=src factor -run=stepX_YYY
149 *The Forth implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
158 You Go implementation of mal requires that go is installed on on the
159 path. The implementation has been tested with Go 1.3.1.
170 Install the Haskell compiler (ghc/ghci), the Haskell platform and
171 either the editline package (BSD) or the readline package (GPL). On
172 Ubuntu these packages are: ghc, haskell-platform,
173 libghc-readline-dev/libghc-editline-dev
184 The Java implementation of mal requires maven2 to build.
189 mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
191 mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
204 The Julia implementation of mal has been tested with Julia 0.3.7.
213 Running the Lua implementation of mal requires lua 5.1 or later,
214 luarocks and the lua-rex-pcre library installed.
218 make # to build and link linenoise.so
224 Running the mal implementation of mal involves running stepA of one of
225 the other implementations and passing the mal step to run as a command
230 IMPL_STEPA_CMD ../mal/stepX_YYY.mal
243 *The Nim implementation was created by [Dennis Felsing (def-)](https://github.com/def-)*
245 Running the Nim implementation of mal requires Nim's current devel branch
246 (0.10.3) or later, and the nre library installed.
258 *The OCaml implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
268 The MATLAB implementation of mal has been tested with MATLAB version
269 R2014a on Linux. Note that MATLAB is a commercial product. It should
270 be fairly simple to support GNU Octave once it support classdef object
276 matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
277 # OR with command line arguments
278 matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
283 [miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
284 implemented in less than 1024 bytes of JavaScript. To run the miniMAL
285 implementation of mal you need to download/install the miniMAL
286 interpreter (which requires Node.js).
289 # Download miniMAL and dependencies
291 export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
292 # Now run mal implementation in miniMAL
298 For readline line editing support, install Term::ReadLine::Perl or
299 Term::ReadLine::Gnu from CPAN.
309 The PHP implementation of mal requires the php command line interface
317 ### Postscript Level 2/3
319 The Postscript implementation of mal requires ghostscript to run. It
320 has been tested with ghostscript 9.10.
324 gs -q -dNODISPLAY -I./ stepX_YYY.ps
336 The R implementation of mal requires R (r-base-core) to run.
340 make libs # to download and build rdyncall
346 The Racket implementation of mal requires the Racket
347 compiler/interpreter to run.
361 ### Rust (1.0.0 nightly)
363 The rust implementation of mal requires the rust compiler and build
364 tool (cargo) to build.
368 cargo run --release --bin stepX_YYY
373 Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
377 sbt 'run-main stepX_YYY'
380 scala -classpath target/scala*/classes stepX_YYY
385 *The Swift implementation was created by [Keith Rollin](https://github.com/keith-rollin)*
387 The Swift implemenation of mal requires the Swift compiler (XCode) to
396 ### Visual Basic.NET ###
398 The VB.NET implementation of mal has been tested on Linux using the Mono
399 VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
400 required to build and run the VB.NET implementation.
414 The are nearly 500 generic functional tests (for all implementations)
415 in the `tests/` directory. Each step has a corresponding test file
416 containing tests specific to that step. The `runtest.py` test harness
417 launches a Mal step implementation and then feeds the tests one at
418 a time to the implementation and compares the output/return value to
419 the expected output/return value.
421 To simplify the process of running tests, a top level Makefile is
422 provided with convenient test targets.
424 * To run all the tests across all implementations (be prepared to wait):
430 * To run all tests against a single implementation:
440 * To run tests for a single step against all implementations:
450 * To run tests for a specifc step against a single implementation:
460 ### Self-hosted functional tests
462 * To run the functional tests in self-hosted mode, you specify `mal`
463 as the test implementation and use the `MAL_IMPL` make variable
464 to change the underlying host language (default is JavaScript):
466 make MAL_IMPL=IMPL test^mal^step2
469 make test^mal^step2 # js is default
470 make MAL_IMPL=ruby test^mal^step2
471 make MAL_IMPL=python test^mal^step2
475 ### Performance tests
477 Warning: These performance tests are neither statistically valid nor
478 comprehensive; runtime performance is a not a primary goal of mal. If
479 you draw any serious conclusions from these performance tests, then
480 please contact me about some amazing oceanfront property in Kansas
481 that I'm willing to sell you for cheap.
483 * To run performance tests against a single implementation:
491 * To run performance tests against all implementations:
496 ### Generating language statistics
498 * To report line and byte stastics for a single implementation:
506 * To report line and bytes stastics for general Lisp code (env, core
515 ## Docker test environment
517 There is a Dockerfile included in the `tests/docker` directory that
518 builds a docker image based on Ubuntu Utopic that contains everything
519 needed to run tests against all the implementations (except for MATLAB
520 which is proprietary/licensed).
522 Build the the docker image using a provided script. WARNING: this will
523 likely take over an hour to build from scratch and use more 3 GB of disk:
525 ./tests/docker-build.sh
528 Launch a docker container from that image built above. This will
529 volume mount the mal directory to `/mal` and then give you a bash
530 prompt in the container. You can then run individual mal
531 implementations and tests:
533 ./tests/docker-run.sh
536 You can also specify a command to run within the container. For
537 example, to run step2 tests for every implementation (except MATLAB):
539 ./tests/docker-run.sh make SKIP_IMPLS="matlab" test^step2
543 * JVM-based language implementations (Java, Clojure, Scala): you will
544 need to run these implementations once manually first before you can
545 run tests because runtime dependencies need to be downloaded to
546 avoid the tests timing out. These dependencies are download to
547 dot-files in the /mal directory so they will persist between runs.
548 * Compiled languages: if your host system is different enough from
549 Ubuntu Utopic then you may need to re-compile your compiled
550 languages from within the container to avoid linker version
556 Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
557 License 2.0). See LICENSE.txt for more details.