Merge pull request #474 from denisidoro/patch-1
[jackhill/mal.git] / README.md
CommitLineData
60154d24
JM
1# mal - Make a Lisp
2
f9e6bb80
JM
3[![Build Status](https://travis-ci.org/kanaka/mal.svg?branch=master)](https://travis-ci.org/kanaka/mal)
4
bcddc3e4
JM
5## Description
6
5b6498bc 7**1. Mal is a Clojure inspired Lisp interpreter**
b76aa73b 8
6aa9c258 9**2. Mal is implemented in 79 languages (82 different implementations and 102 runtime modes)**
bcddc3e4 10
c5cd05ae
JM
11| Language | Creator |
12| -------- | ------- |
13| [Ada](#ada) | [Chris Moore](https://github.com/zmower) |
6d9e1684 14| [Ada #2](#ada2) | [Nicolas Boulenguez](https://github.com/asarhaddon) |
833fc8cc 15| [GNU Awk](#gnu-awk) | [Miutsuru Kariya](https://github.com/kariya-mitsuru) |
c5cd05ae
JM
16| [Bash 4](#bash-4) | [Joel Martin](https://github.com/kanaka) |
17| [BASIC](#basic-c64-and-qbasic) (C64 & QBasic) | [Joel Martin](https://github.com/kanaka) |
45c103e6 18| [BBC BASIC V](#bbc-basic-v) | [Ben Harris](https://github.com/bjh21) |
c5cd05ae
JM
19| [C](#c) | [Joel Martin](https://github.com/kanaka) |
20| [C++](#c-1) | [Stephen Thirlwall](https://github.com/sdt) |
21| [C#](#c-2) | [Joel Martin](https://github.com/kanaka) |
22| [ChucK](#chuck) | [Vasilij Schneidermann](https://github.com/wasamasa) |
c5cd05ae
JM
23| [Clojure](#clojure) (Clojure & ClojureScript) | [Joel Martin](https://github.com/kanaka) |
24| [CoffeeScript](#coffeescript) | [Joel Martin](https://github.com/kanaka) |
833fc8cc 25| [Common Lisp](#common-lisp) | [Iqbal Ansari](https://github.com/iqbalansari) |
c5cd05ae
JM
26| [Crystal](#crystal) | [Linda_pp](https://github.com/rhysd) |
27| [D](#d) | [Dov Murik](https://github.com/dubek) |
28| [Dart](#dart) | [Harry Terkelsen](https://github.com/hterkelsen) |
29| [Elixir](#elixir) | [Martin Ek](https://github.com/ekmartin) |
30| [Elm](#elm) | [Jos van Bakel](https://github.com/c0deaddict) |
31| [Emacs Lisp](#emacs-lisp) | [Vasilij Schneidermann](https://github.com/wasamasa) |
32| [Erlang](#erlang) | [Nathan Fiedler](https://github.com/nlfiedler) |
33| [ES6](#es6-ecmascript-2015) (ECMAScript 2015) | [Joel Martin](https://github.com/kanaka) |
34| [F#](#f) | [Peter Stephens](https://github.com/pstephens) |
35| [Factor](#factor) | [Jordan Lewis](https://github.com/jordanlewis) |
36| [Fantom](#fantom) | [Dov Murik](https://github.com/dubek) |
37| [Forth](#forth) | [Chris Houser](https://github.com/chouser) |
c5cd05ae
JM
38| [GNU Guile](#gnu-guile-21) | [Mu Lei](https://github.com/NalaGinrut) |
39| [GNU Smalltalk](#gnu-smalltalk) | [Vasilij Schneidermann](https://github.com/wasamasa) |
833fc8cc
JM
40| [Go](#go) | [Joel Martin](https://github.com/kanaka) |
41| [Groovy](#groovy) | [Joel Martin](https://github.com/kanaka) |
c5cd05ae
JM
42| [Haskell](#haskell) | [Joel Martin](https://github.com/kanaka) |
43| [Haxe](#haxe-neko-python-c-and-javascript) (Neko, Python, C++, & JS) | [Joel Martin](https://github.com/kanaka) |
44| [Hy](#hy) | [Joel Martin](https://github.com/kanaka) |
45| [Io](#io) | [Dov Murik](https://github.com/dubek) |
46| [Java](#java-17) | [Joel Martin](https://github.com/kanaka) |
47| [JavaScript](#javascriptnode) ([Demo](http://kanaka.github.io/mal)) | [Joel Martin](https://github.com/kanaka) |
48| [Julia](#julia) | [Joel Martin](https://github.com/kanaka) |
49| [Kotlin](#kotlin) | [Javier Fernandez-Ivern](https://github.com/ivern) |
50| [LiveScript](#livescript) | [Jos van Bakel](https://github.com/c0deaddict) |
51| [Logo](#logo) | [Dov Murik](https://github.com/dubek) |
52| [Lua](#lua) | [Joel Martin](https://github.com/kanaka) |
53| [GNU Make](#gnu-make-381) | [Joel Martin](https://github.com/kanaka) |
54| [mal itself](#mal) | [Joel Martin](https://github.com/kanaka) |
833fc8cc 55| [MATLAB](#matlab-gnu-octave-and-matlab) (GNU Octave & MATLAB) | [Joel Martin](https://github.com/kanaka) |
c5cd05ae
JM
56| [miniMAL](#minimal) ([Repo](https://github.com/kanaka/miniMAL), [Demo](https://kanaka.github.io/miniMAL/)) | [Joel Martin](https://github.com/kanaka) |
57| [NASM](#nasm) | [Ben Dudson](https://github.com/bendudson) |
58| [Nim](#nim-0170) | [Dennis Felsing](https://github.com/def-) |
59| [Object Pascal](#object-pascal) | [Joel Martin](https://github.com/kanaka) |
60| [Objective C](#objective-c) | [Joel Martin](https://github.com/kanaka) |
61| [OCaml](#ocaml-4010) | [Chris Houser](https://github.com/chouser) |
23e3304b 62| [Perl](#perl-5) | [Joel Martin](https://github.com/kanaka) |
c5cd05ae
JM
63| [Perl 6](#perl-6) | [Hinrik Örn Sigurðsson](https://github.com/hinrik) |
64| [PHP](#php-53) | [Joel Martin](https://github.com/kanaka) |
65| [Picolisp](#picolisp) | [Vasilij Schneidermann](https://github.com/wasamasa) |
742af2bb 66| [Pike](#pike) | [Dov Murik](https://github.com/dubek) |
33102dd1 67| [PL/pgSQL](#plpgsql-postgresql-sql-procedural-language) (PostgreSQL) | [Joel Martin](https://github.com/kanaka) |
c5cd05ae 68| [PL/SQL](#plsql-oracle-sql-procedural-language) (Oracle) | [Joel Martin](https://github.com/kanaka) |
833fc8cc 69| [PostScript](#postscript-level-23) | [Joel Martin](https://github.com/kanaka) |
c5cd05ae
JM
70| [PowerShell](#powershell) | [Joel Martin](https://github.com/kanaka) |
71| [Python](#python-2x-and-3x) (2.X & 3.X) | [Joel Martin](https://github.com/kanaka) |
8501fcab 72| [Python #2](#python2-3x) (3.X) | [Gavin Lewis](https://github.com/epylar) |
c5cd05ae
JM
73| [RPython](#rpython) | [Joel Martin](https://github.com/kanaka) |
74| [R](#r) | [Joel Martin](https://github.com/kanaka) |
75| [Racket](#racket-53) | [Joel Martin](https://github.com/kanaka) |
76| [Rexx](#rexx) | [Dov Murik](https://github.com/dubek) |
77| [Ruby](#ruby-19) | [Joel Martin](https://github.com/kanaka) |
bcb7af31 78| [Rust](#rust-138) | [Joel Martin](https://github.com/kanaka) |
c5cd05ae
JM
79| [Scala](#scala) | [Joel Martin](https://github.com/kanaka) |
80| [Scheme (R7RS)](#scheme-r7rs) | [Vasilij Schneidermann](https://github.com/wasamasa) |
81| [Skew](#skew) | [Dov Murik](https://github.com/dubek) |
833fc8cc 82| [Swift 2](#swift) | [Keith Rollin](https://github.com/keith-rollin) |
c5cd05ae 83| [Swift 3](#swift-3) | [Joel Martin](https://github.com/kanaka) |
2c1c2660 84| [Swift 4](#swift-4) | [陆遥](https://github.com/LispLY) |
6aa9c258 85| [Swift 5](#swift-5) | [Oleg Montak](https://github.com/MontakOleg) |
c5cd05ae
JM
86| [Tcl](#tcl-86) | [Dov Murik](https://github.com/dubek) |
87| [TypeScript](#typescript) | [Masahiro Wakame](https://github.com/vvakame) |
213a3288 88| [Vala](#vala) | [Simon Tatham](https://github.com/sgtatham) |
c5cd05ae
JM
89| [VHDL](#vhdl) | [Dov Murik](https://github.com/dubek) |
90| [Vimscript](#vimscript) | [Dov Murik](https://github.com/dubek) |
91| [Visual Basic.NET](#visual-basicnet) | [Joel Martin](https://github.com/kanaka) |
92| [WebAssembly](#webassembly-wasm) (wasm) | [Joel Martin](https://github.com/kanaka) |
84eaa11c 93| [Wren](#wren) | [Dov Murik](https://github.com/dubek) |
c5cd05ae 94| [Yorick](#yorick) | [Dov Murik](https://github.com/dubek) |
bcddc3e4
JM
95
96
5b6498bc
JM
97**3. Mal is a learning tool**
98
99Each implementation of mal is separated into
bd08422d
JM
10011 incremental, self-contained (and testable) steps that demonstrate
101core concepts of Lisp. The last step is capable of self-hosting
5b6498bc
JM
102(running the mal implementation of mal). See the [make-a-lisp process
103guide](process/guide.md).
bcddc3e4 104
5b6498bc 105The make-a-lisp steps are:
bcddc3e4 106
0f4ca9d1
JM
107* [step0_repl](process/guide.md#step0)
108* [step1_read_print](process/guide.md#step1)
109* [step2_eval](process/guide.md#step2)
110* [step3_env](process/guide.md#step3)
111* [step4_if_fn_do](process/guide.md#step4)
112* [step5_tco](process/guide.md#step5)
113* [step6_file](process/guide.md#step6)
114* [step7_quote](process/guide.md#step7)
115* [step8_macros](process/guide.md#step8)
116* [step9_try](process/guide.md#step9)
90f618cb 117* [stepA_mal](process/guide.md#stepA)
bcddc3e4 118
138cbb9c
JM
119Each make-a-lisp step has an associated architectural diagram. That elements
120that are new for that step are highlighted in red.
121Here is the final diagram for [step A](process/guide.md#stepA):
5b6498bc
JM
122
123![stepA_mal architecture](process/stepA_mal.png)
124
98a83a87 125If you are interested in creating a mal implementation (or just
5b6498bc
JM
126interested in using mal for something), please drop by the #mal
127channel on freenode. In addition to the [make-a-lisp process
128guide](process/guide.md) there is also a [mal/make-a-lisp
129FAQ](docs/FAQ.md) where I attempt to answer some common questions.
130
131
132## Presentations
bcddc3e4
JM
133
134Mal was presented publicly for the first time in a lightning talk at
135Clojure West 2014 (unfortunately there is no video). See
dede32ba 136examples/clojurewest2014.mal for the presentation that was given at the
5b6498bc
JM
137conference (yes, the presentation is a mal program).
138
139At Midwest.io 2015, Joel Martin gave a presentation on Mal titled
140"Achievement Unlocked: A Better Path to Language Learning".
dede32ba 141[Video](https://www.youtube.com/watch?v=lgyOAiRtZGw),
5b6498bc
JM
142[Slides](http://kanaka.github.io/midwest.io.mal/).
143
144More recently Joel gave a presentation on "Make Your Own Lisp Interpreter
145in 10 Incremental Steps" at LambdaConf 2016:
86633b33
JM
146[Part 1](https://www.youtube.com/watch?v=jVhupfthTEk),
147[Part 2](https://www.youtube.com/watch?v=X5OQBMGpaTU),
148[Part 3](https://www.youtube.com/watch?v=6mARZzGgX4U),
149[Part 4](https://www.youtube.com/watch?v=dCO1SYR5kDU),
9ed75afd 150[Slides](http://kanaka.github.io/lambdaconf/).
60154d24
JM
151
152## Building/running implementations
153
5b207de7
JM
154The simplest way to run any given implementation is to use docker.
155Every implementation has a docker image pre-built with language
70cefa38 156dependencies installed. You can launch the REPL using a convenient
5b207de7
JM
157target in the top level Makefile (where IMPL is the implementation
158directory name and stepX is the step to run):
159
160```
161make DOCKERIZE=1 "repl^IMPL^stepX"
162 # OR stepA is the default step:
163make DOCKERIZE=1 "repl^IMPL"
164```
165
d4dec75b
JM
166## External Implementations
167
168The following implementations are maintained as separate projects:
169
170### HolyC
171
172* [by Alexander Bagnalla](https://github.com/bagnalla/holyc_mal)
173
174### Rust
175
176* [by Tim Morgan](https://github.com/seven1m/mal-rust)
177* [by vi](https://github.com/vi/mal-rust-vi) - using [Pest](https://pest.rs/) grammar, not using typical Mal infrastructure (cargo-ized steps and built-in converted tests).
178
179
180## Other mal Projects
181
182 * [malc](https://github.com/dubek/malc) - Mal (Make A Lisp) compiler. Compiles a Mal program to LLVM assembly language, then binary.
343c6332 183 * [malcc](https://github.com/seven1m/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"](https://mpov.timmorgan.org/i-built-a-lisp-compiler/) post about the process.
d4dec75b 184 * [frock](https://github.com/chr15m/frock) - Clojure-flavoured PHP. Uses mal/php to run programs.
1bdee167 185 * [flk](https://github.com/chr15m/flk) - A LISP that runs wherever Bash is
d4dec75b
JM
186
187
188## Implementation Details
5b207de7 189
6faafa00
CM
190### Ada
191
7b458a65
JM
192The Ada implementation was developed with GNAT 4.9 on debian. It also
193compiles unchanged on windows if you have windows versions of git,
194GNAT and (optionally) make. There are no external dependencies
195(readline not implemented).
6faafa00
CM
196
197```
198cd ada
199make
200./stepX_YYY
201```
202
d387f26e
JM
203### Ada.2
204
205The second Ada implementation was developed with GNAT 8 and links with
206the GNU readline library.
207
208```
209cd ada
210make
211./stepX_YYY
212```
213
8c7587af
MK
214### GNU awk
215
216The GNU awk implementation of mal has been tested with GNU awk 4.1.1.
217
218```
219cd gawk
220gawk -O -f stepX_YYY.awk
221```
222
bcddc3e4 223### Bash 4
60154d24
JM
224
225```
226cd bash
227bash stepX_YYY.sh
228```
229
2bcc46af 230### BASIC (C64 and QBasic)
1b245300 231
2bcc46af
JM
232The BASIC implementation uses a preprocessor that can generate BASIC
233code that is compatible with both C64 BASIC (CBM v2) and QBasic. The
1b245300
JM
234C64 mode has been tested with
235[cbmbasic](https://github.com/kanaka/cbmbasic) (the patched version is
236currently required to fix issues with line input) and the QBasic mode
237has been tested with [qb64](http://www.qb64.net/).
238
239Generate C64 code and run it using cbmbasic:
240
241```
242cd basic
243make stepX_YYY.bas
244STEP=stepX_YYY ./run
245```
246
247Generate QBasic code and load it into qb64:
248
249```
250cd basic
251make MODE=qbasic stepX_YYY.bas
252./qb64 stepX_YYY.bas
253```
254
255Thanks to [Steven Syrek](https://github.com/sjsyrek) for the original
256inspiration for this implementation.
257
45c103e6
BH
258### BBC BASIC V
259
260The BBC BASIC V implementation can run in the Brandy interpreter:
261
262```
263cd bbc-basic
264brandy -quit stepX_YYY.bbc
265```
266
267Or in ARM BBC BASIC V under RISC OS 3 or later:
268
269```
270*Dir bbc-basic.riscos
271*Run setup
272*Run stepX_YYY
273```
1b245300 274
bcddc3e4 275### C
60154d24 276
01c97316 277The C implementation of mal requires the following libraries (lib and
6b3ecaa7
DM
278header packages): glib, libffi6, libgc, and either the libedit or GNU readline
279library.
54c75382 280
60154d24
JM
281```
282cd c
283make
284./stepX_YYY
285```
286
73fc9366
JM
287### C++
288
289The C++ implementation of mal requires g++-4.9 or clang++-3.5 and
290a readline compatible library to build. See the `cpp/README.md` for
291more details:
292
293```
294cd cpp
295make
296 # OR
297make CXX=clang++-3.5
298./stepX_YYY
299```
300
301
9b1563a3 302### C# ###
edc3b064
JM
303
304The C# implementation of mal has been tested on Linux using the Mono
305C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
306required to build and run the C# implementation.
307
308```
309cd cs
310make
ee7cd585 311mono ./stepX_YYY.exe
edc3b064
JM
312```
313
385a08eb
VS
314### ChucK
315
332611f5 316The ChucK implementation has been tested with ChucK 1.3.5.2.
385a08eb
VS
317
318```
319cd chuck
320./run
321```
edc3b064 322
bcddc3e4 323### Clojure
60154d24 324
aa716df6
JM
325For the most part the Clojure implementation requires Clojure 1.5,
326however, to pass all tests, Clojure 1.8.0-RC4 is required.
327
60154d24
JM
328```
329cd clojure
330lein with-profile +stepX trampoline run
331```
332
891c3f3b
JM
333### CoffeeScript
334
335```
336sudo npm install -g coffee-script
337cd coffee
338coffee ./stepX_YYY
339```
340
833fc8cc
JM
341### Common Lisp
342
343The implementation has been tested with SBCL, CCL, CMUCL, GNU CLISP, ECL and
344Allegro CL on Ubuntu 16.04 and Ubuntu 12.04, see
345the [README](common-lisp/README.org) for more details. Provided you have the
346dependencies mentioned installed, do the following to run the implementation
347
348```
349cd common-lisp
350make
351./run
352```
353
58b84dd5 354### Crystal
355
5185c56e 356The Crystal implementation of mal has been tested with Crystal 0.26.1.
6c4dede1 357
58b84dd5 358```
359cd crystal
360crystal run ./stepX_YYY.cr
6c4dede1
JM
361 # OR
362make # needed to run tests
363./stepX_YYY
58b84dd5 364```
365
f82cb965
DM
366### D
367
f82cb965
DM
368The D implementation of mal was tested with GDC 4.8. It requires the GNU
369readline library.
370
371```
372cd d
373make
374./stepX_YYY
375```
376
bcf95720
HT
377### Dart
378
bcf95720
HT
379The Dart implementation has been tested with Dart 1.20.
380
381```
382cd dart
383dart ./stepX_YYY
384```
385
e0b7f668
VS
386### Emacs Lisp
387
e0b7f668
VS
388The Emacs Lisp implementation of mal has been tested with Emacs 24.3
389and 24.5. While there is very basic readline editing (`<backspace>`
390and `C-d` work, `C-c` cancels the process), it is recommended to use
391`rlwrap`.
392
393```
394cd elisp
395emacs -Q --batch --load stepX_YYY.el
396# with full readline support
397rlwrap emacs -Q --batch --load stepX_YYY.el
398```
399
bb526975 400### Elixir
401
bb526975 402The Elixir implementation of mal has been tested with Elixir 1.0.5.
403
404```
405cd elixir
df2ca97b 406mix stepX_YYY
407# Or with readline/line editing functionality:
bb526975 408iex -S mix stepX_YYY
409```
410
f38c7ffa
JB
411### Elm
412
f38c7ffa
JB
413The Elm implementation of mal has been tested with Elm 0.18.0
414
415```
416cd elm
417make stepX_YYY.js
418STEP=stepX_YYY ./run
419```
420
2cc3804b
NF
421### Erlang
422
82484631
JM
423The Erlang implementation of mal requires [Erlang/OTP R17](http://www.erlang.org/download.html)
424and [rebar](https://github.com/rebar/rebar) to build.
2cc3804b
NF
425
426```
427cd erlang
425ef3d7
JM
428make
429 # OR
430MAL_STEP=stepX_YYY rebar compile escriptize # build individual step
2cc3804b
NF
431./stepX_YYY
432```
433
c5cd05ae 434### ES6 (ECMAScript 2015)
88e934b6 435
c5cd05ae
JM
436The ES6 / ECMAScript 2015 implementation uses the
437[babel](https://babeljs.io) compiler to generate ES5 compatible
438JavaScript. The generated code has been tested with Node 0.12.4.
88e934b6
JM
439
440```
441cd es6
442make
443node build/stepX_YYY.js
444```
445
446
6f78381f
PS
447### F# ###
448
6f78381f
PS
449The F# implementation of mal has been tested on Linux using the Mono
450F# compiler (fsharpc) and the Mono runtime (version 3.12.1). The mono C#
206a1657 451compiler (mcs) is also necessary to compile the readline dependency. All are
6f78381f
PS
452required to build and run the F# implementation.
453
454```
455cd fsharp
456make
457mono ./stepX_YYY.exe
458```
459
5a53c643
JL
460### Factor
461
0fe47e88 462The Factor implementation of mal has been tested with Factor 0.97
07eb827b 463([factorcode.org](http://factorcode.org)).
0fe47e88 464
5a53c643
JL
465```
466cd factor
199b1ce7 467FACTOR_ROOTS=. factor -run=stepX_YYY
5a53c643
JL
468```
469
92708e34
DM
470### Fantom
471
92708e34
DM
472The Fantom implementation of mal has been tested with Fantom 1.0.70.
473
474```
475cd fantom
476make lib/fan/stepX_YYY.pod
477STEP=stepX_YYY ./run
478```
479
96032890
C
480### Forth
481
482```
483cd forth
484gforth stepX_YYY.fs
485```
486
833fc8cc
JM
487### GNU Guile 2.1+
488
489```
490cd guile
491guile -L ./ stepX_YYY.scm
492```
493
494### GNU Smalltalk
495
496The Smalltalk implementation of mal has been tested with GNU Smalltalk 3.2.91.
497
498```
499cd gnu-smalltalk
500./run
501```
502
1771ab50
JM
503### Go
504
0fe47e88 505The Go implementation of mal requires that go is installed on on the
fd888612
JM
506path. The implementation has been tested with Go 1.3.1.
507
1771ab50
JM
508```
509cd go
510make
511./stepX_YYY
512```
513
514
7ab0f63e
JM
515### Groovy
516
517The Groovy implementation of mal requires Groovy to run and has been
518tested with Groovy 1.8.6.
519
520```
521cd groovy
522make
523groovy ./stepX_YYY.groovy
524```
525
b76aa73b
JM
526### Haskell
527
f60f33e0
JM
528The Haskell implementation requires the ghc compiler version 7.10.1 or
529later and also the Haskell parsec and readline (or editline) packages.
b76aa73b
JM
530
531```
532cd haskell
533make
534./stepX_YYY
535```
536
2d76e877 537### Haxe (Neko, Python, C++ and JavaScript)
33dec7af
JM
538
539The Haxe implementation of mal requires Haxe version 3.2 to compile.
540Four different Haxe targets are supported: Neko, Python, C++, and
541JavaScript.
542
543```
544cd haxe
545# Neko
546make all-neko
547neko ./stepX_YYY.n
548# Python
549make all-python
550python3 ./stepX_YYY.py
551# C++
552make all-cpp
553./cpp/stepX_YYY
554# JavaScript
555make all-js
556node ./stepX_YYY.js
557```
558
ccab8f59
JM
559### Hy
560
561The Hy implementation of mal has been tested with Hy 0.13.0.
562
563```
564cd hy
565./stepX_YYY.hy
566```
567
61f69fba
DM
568### Io
569
61f69fba
DM
570The Io implementation of mal has been tested with Io version 20110905.
571
572```
573cd io
574io ./stepX_YYY.io
575```
b76aa73b 576
bcddc3e4 577### Java 1.7
60154d24 578
01c97316
JM
579The Java implementation of mal requires maven2 to build.
580
60154d24
JM
581```
582cd java
583mvn compile
584mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
585 # OR
586mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
587```
588
39381792 589### JavaScript/Node
60154d24
JM
590
591```
592cd js
54c75382 593npm update
60154d24
JM
594node stepX_YYY.js
595```
596
39381792
JM
597### Julia
598
82484631 599The Julia implementation of mal requires Julia 0.4.
39381792
JM
600
601```
602cd julia
603julia stepX_YYY.jl
604```
605
53c2ea70
JFI
606### Kotlin
607
75787d77 608The Kotlin implementation of mal has been tested with Kotlin 1.0.
53c2ea70
JFI
609
610```
611cd kotlin
612make
613java -jar stepX_YYY.jar
614```
615
0af8fd20
JB
616### LiveScript
617
0af8fd20
JB
618The LiveScript implementation of mal has been tested with LiveScript 1.5.
619
620```
621cd livescript
622make
623node_modules/.bin/lsc stepX_YYY.ls
624```
625
4eb88ef2
DM
626### Logo
627
4eb88ef2
DM
628The Logo implementation of mal has been tested with UCBLogo 6.0.
629
630```
631cd logo
632logo stepX_YYY.lg
633```
634
9d42904e
JM
635### Lua
636
45a71498
JM
637The Lua implementation of mal has been tested with Lua 5.2. The
638implementation requires that luarocks and the lua-rex-pcre library
639are installed.
9d42904e
JM
640
641```
642cd lua
643make # to build and link linenoise.so
644./stepX_YYY.lua
645```
646
bcddc3e4 647### Mal
60154d24
JM
648
649Running the mal implementation of mal involves running stepA of one of
650the other implementations and passing the mal step to run as a command
5d446bd8 651line argument.
60154d24
JM
652
653```
654cd IMPL
655IMPL_STEPA_CMD ../mal/stepX_YYY.mal
656
657```
658
bcddc3e4 659### GNU Make 3.81
60154d24
JM
660
661```
662cd make
663make -f stepX_YYY.mk
664```
665
331ddfed
BD
666### NASM
667
331ddfed
BD
668The NASM implementation of mal is written for x86-64 Linux, and has been tested
669with Linux 3.16.0-4-amd64 and NASM version 2.11.05.
670
671```
672cd nasm
673make
674./stepX_YYY
675```
676
4603f2a9 677### Nim 0.17.0
a2cd0a3a 678
4603f2a9 679The Nim implementation of mal has been tested with Nim 0.17.0.
a2cd0a3a 680
681```
682cd nim
683make
684 # OR
685nimble build
686./stepX_YYY
687```
688
0067158f
JM
689### Object Pascal
690
691The Object Pascal implementation of mal has been built and tested on
692Linux using the Free Pascal compiler version 2.6.2 and 2.6.4.
693
694```
695cd objpascal
696make
697./stepX_YYY
698```
699
7cae6e6f
JM
700### Objective C
701
702The Objective C implementation of mal has been built and tested on
2faae94c
JM
703Linux using clang/LLVM 3.6. It has also been built and tested on OS
704X using XCode 7.
7cae6e6f
JM
705
706```
707cd objc
708make
709./stepX_YYY
710```
711
bc6448bc
C
712### OCaml 4.01.0
713
714```
715cd ocaml
716make
717./stepX_YYY
718```
719
833fc8cc 720### MATLAB (GNU Octave and MATLAB)
8a9d0a8a 721
4bb2ab37
JM
722The MatLab implementation has been tested with GNU Octave 4.2.1.
723It has also been tested with MATLAB version R2014a on Linux. Note that
724MATLAB is a commercial product.
8a9d0a8a
JM
725
726```
727cd matlab
728./stepX_YYY
4bb2ab37 729octave -q --no-gui --no-history --eval "stepX_YYY();quit;"
8a9d0a8a
JM
730matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
731 # OR with command line arguments
4bb2ab37 732octave -q --no-gui --no-history --eval "stepX_YYY('arg1','arg2');quit;"
8a9d0a8a
JM
733matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
734```
735
1218ce98
JM
736### miniMAL
737
738[miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
739implemented in less than 1024 bytes of JavaScript. To run the miniMAL
740implementation of mal you need to download/install the miniMAL
741interpreter (which requires Node.js).
742```
1218ce98 743cd miniMAL
478fd9ce
JM
744# Download miniMAL and dependencies
745npm install
746export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
747# Now run mal implementation in miniMAL
1218ce98
JM
748miniMAL ./stepX_YYY
749```
750
23e3304b
BH
751### Perl 5
752
753The Perl 5 implementation should work with perl 5.19.3 and later.
9e5b2151
JM
754
755For readline line editing support, install Term::ReadLine::Perl or
756Term::ReadLine::Gnu from CPAN.
757
758```
759cd perl
760perl stepX_YYY.pl
761```
762
a7081401
HÖS
763### Perl 6
764
a7081401
HÖS
765The Perl 6 implementation was tested on Rakudo Perl 6 2016.04.
766
767```
768cd perl6
769perl6 stepX_YYY.pl
770```
9e5b2151 771
bcddc3e4 772### PHP 5.3
60154d24 773
01c97316
JM
774The PHP implementation of mal requires the php command line interface
775to run.
776
60154d24
JM
777```
778cd php
779php stepX_YYY.php
780```
781
b6263859
VS
782### Picolisp
783
b6263859
VS
784The Picolisp implementation requires libreadline and Picolisp 3.1.11
785or later.
786
787```
b440380f 788cd picolisp
b6263859
VS
789./run
790```
791
742af2bb
DM
792### Pike
793
794The Pike implementation was tested on Pike 8.0.
795
796```
797cd pike
798pike stepX_YYY.pike
799```
800
33102dd1 801### PL/pgSQL (PostgreSQL SQL Procedural Language)
b25bf8d8 802
33102dd1 803The PL/pgSQL implementation of mal requires a running PostgreSQL server
b88bb764 804(the "kanaka/mal-test-plpgsql" docker image automatically starts
33102dd1 805a PostgreSQL server). The implementation connects to the PostgreSQL server
b88bb764
JM
806and create a database named "mal" to store tables and stored
807procedures. The wrapper script uses the psql command to connect to the
808server and defaults to the user "postgres" but this can be overridden
809with the PSQL_USER environment variable. A password can be specified
810using the PGPASSWORD environment variable. The implementation has been
33102dd1 811tested with PostgreSQL 9.4.
b25bf8d8
JM
812
813```
814cd plpgsql
815./wrap.sh stepX_YYY.sql
b88bb764
JM
816 # OR
817PSQL_USER=myuser PGPASSWORD=mypass ./wrap.sh stepX_YYY.sql
818```
819
820### PL/SQL (Oracle SQL Procedural Language)
821
26460a25 822The PL/SQL implementation of mal requires a running Oracle DB
b88bb764
JM
823server (the "kanaka/mal-test-plsql" docker image automatically
824starts an Oracle Express server). The implementation connects to the
825Oracle server to create types, tables and stored procedures. The
69990448 826default SQL\*Plus logon value (username/password@connect_identifier) is
b88bb764
JM
827"system/oracle" but this can be overridden with the ORACLE_LOGON
828environment variable. The implementation has been tested with Oracle
69990448 829Express Edition 11g Release 2. Note that any SQL\*Plus connection
b88bb764
JM
830warnings (user password expiration, etc) will interfere with the
831ability of the wrapper script to communicate with the DB.
832
833```
834cd plsql
835./wrap.sh stepX_YYY.sql
836 # OR
837ORACLE_LOGON=myuser/mypass@ORCL ./wrap.sh stepX_YYY.sql
b25bf8d8
JM
838```
839
e007416e 840### PostScript Level 2/3
5c34565f 841
e007416e
BH
842The PostScript implementation of mal requires Ghostscript to run. It
843has been tested with Ghostscript 9.10.
5c34565f
JM
844
845```
846cd ps
847gs -q -dNODISPLAY -I./ stepX_YYY.ps
848```
849
850### PowerShell
851
852The PowerShell implementation of mal requires the PowerShell script
853language. It has been tested with PowerShell 6.0.0 Alpha 9 on Linux.
854
855```
856cd powershell
857powershell ./stepX_YYY.ps1
858```
859
2d76e877 860### Python (2.X and 3.X)
60154d24
JM
861
862```
863cd python
864python stepX_YYY.py
865```
8adb0827 866
791052af
G
867### Python.2 (3.X)
868
869The second Python implementation makes heavy use of type annotations and uses the Arpeggio parser library.
870
871```
872# Recommended: do these steps in a Python virtual environment.
873pip3 install Arpeggio==1.9.0
874python3 stepX_YYY.py
875```
876
23e38cd2
JM
877### RPython
878
879You must have [rpython](https://rpython.readthedocs.org/) on your path
880(included with [pypy](https://bitbucket.org/pypy/pypy/)).
881
882```
883cd rpython
4e8d7c28 884make # this takes a very long time
23e38cd2
JM
885./stepX_YYY
886```
887
9b3362e8
JM
888### R
889
890The R implementation of mal requires R (r-base-core) to run.
891
892```
893cd r
9d42904e 894make libs # to download and build rdyncall
f5223195
JM
895Rscript stepX_YYY.r
896```
897
898### Racket (5.3)
899
900The Racket implementation of mal requires the Racket
901compiler/interpreter to run.
902
903```
904cd racket
3796240a 905./stepX_YYY.rkt
9b3362e8
JM
906```
907
44a3e2ef
DM
908### Rexx
909
44a3e2ef
DM
910The Rexx implementation of mal has been tested with Regina Rexx 3.6.
911
912```
913cd rexx
914make
915rexx -a ./stepX_YYY.rexxpp
916```
917
107d9694 918### Ruby (1.9+)
8adb0827
JM
919
920```
921cd ruby
922ruby stepX_YYY.rb
923```
592eb5cf 924
bcb7af31 925### Rust (1.38+)
abdd56eb
JM
926
927The rust implementation of mal requires the rust compiler and build
928tool (cargo) to build.
929
930```
931cd rust
bbeb1b87 932cargo run --release --bin stepX_YYY
abdd56eb
JM
933```
934
821930db
JM
935### Scala ###
936
937Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
938
939```
940cd scala
941sbt 'run-main stepX_YYY'
942 # OR
943sbt compile
944scala -classpath target/scala*/classes stepX_YYY
945```
946
6c0968a6 947### Scheme (R7RS) ###
ff3a8bf8 948
ff3a8bf8
VS
949The Scheme implementation of mal has been tested with Chibi-Scheme
9500.7.3, Kawa 2.4, Gauche 0.9.5, CHICKEN 4.11.0, Sagittarius 0.8.3,
951Cyclone 0.6.3 (Git version) and Foment 0.4 (Git version). You should
952be able to get it running on other conforming R7RS implementations
953after figuring out how libraries are loaded and adjusting the
954`Makefile` and `run` script accordingly.
955
956```
a7b8df67 957cd scheme
ff3a8bf8
VS
958make symlinks
959# chibi
6c0968a6 960scheme_MODE=chibi ./run
ff3a8bf8
VS
961# kawa
962make kawa
6c0968a6 963scheme_MODE=kawa ./run
ff3a8bf8 964# gauche
6c0968a6 965scheme_MODE=gauche ./run
ff3a8bf8
VS
966# chicken
967make chicken
6c0968a6 968scheme_MODE=chicken ./run
ff3a8bf8 969# sagittarius
6c0968a6 970scheme_MODE=sagittarius ./run
ff3a8bf8
VS
971# cyclone
972make cyclone
6c0968a6 973scheme_MODE=cyclone ./run
ff3a8bf8 974# foment
6c0968a6 975scheme_MODE=foment ./run
ff3a8bf8
VS
976```
977
034e82ad
DM
978### Skew ###
979
034e82ad
DM
980The Skew implementation of mal has been tested with Skew 0.7.42.
981
982```
983cd skew
984make
985node stepX_YYY.js
986```
987
988
2539e6af
KR
989### Swift
990
e31349f6
KR
991The Swift implementation of mal requires the Swift 2.0 compiler (XCode
9927.0) to build. Older versions will not work due to changes in the
993language and standard library.
8b142f08 994
2539e6af
KR
995```
996cd swift
997make
998./stepX_YYY
999```
1000
ea1395aa
JM
1001### Swift 3
1002
1003The Swift 3 implementation of mal requires the Swift 3.0 compiler. It
a3a6f680 1004has been tested with Swift 3 Preview 3.
ea1395aa
JM
1005
1006```
1007cd swift3
1008make
1009./stepX_YYY
1010```
1011
2c1c2660 1012### Swift 4
1013
1014The Swift 4 implementation of mal requires the Swift 4.0 compiler. It
1015has been tested with Swift 4.2.3 release.
1016
1017```
1018cd swift4
1019make
1020./stepX_YYY
1021```
1022
6aa9c258
OM
1023### Swift 5
1024
1025The Swift 5 implementation of mal requires the Swift 5.0 compiler. It
1026has been tested with Swift 5.1.1 release.
1027
1028```
1029cd swift5
b667adf5 1030swift run stepX_YYY
6aa9c258
OM
1031```
1032
54d9903c
DM
1033### Tcl 8.6
1034
54d9903c
DM
1035The Tcl implementation of mal requires Tcl 8.6 to run. For readline line
1036editing support, install tclreadline.
1037
1038```
1039cd tcl
1040tclsh ./stepX_YYY.tcl
1041```
1042
c527d565 1043### TypeScript
1044
1045The TypeScript implementation of mal requires the TypeScript 2.2 compiler.
db885df9 1046It has been tested with Node.js v6.
c527d565 1047
1048```
1049cd ts
1050make
1051node ./stepX_YYY.js
1052```
1053
213a3288
ST
1054### Vala
1055
1056The Vala implementation of mal has been tested with the Vala 0.40.8
1057compiler. You will need to install `valac` and `libreadline-dev` or
1058equivalent.
1059
1060```
1061cd vala
1062make
1063./stepX_YYY
1064```
1065
36e91db4
DM
1066### VHDL
1067
36e91db4
DM
1068The VHDL implementation of mal has been tested with GHDL 0.29.
1069
1070```
1071cd vhdl
1072make
1073./run_vhdl.sh ./stepX_YYY
1074```
1075
50a964ce
DM
1076### Vimscript
1077
aa62cbda 1078The Vimscript implementation of mal requires Vim 8.0 to run.
50a964ce
DM
1079
1080```
1081cd vimscript
1082./run_vimscript.sh ./stepX_YYY.vim
1083```
1084
ee7cd585
JM
1085### Visual Basic.NET ###
1086
1087The VB.NET implementation of mal has been tested on Linux using the Mono
1088VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
1089required to build and run the VB.NET implementation.
1090
1091```
1092cd vb
1093make
1094mono ./stepX_YYY.exe
1095```
1096
d72395aa
JM
1097### WebAssembly (wasm) ###
1098
27359631 1099The WebAssembly implementation is written in
d72395aa 1100[Wam](https://github.com/kanaka/wam) (WebAssembly Macro language) and
d88adace 1101runs under several different non-web embeddings (runtimes):
9a7485aa 1102[node](https://nodejs.org),
d88adace 1103[wasmtime](https://github.com/CraneStation/wasmtime),
9a7485aa
JM
1104[wasmer](https://wasmer.io),
1105[lucet](https://github.com/fastly/lucet),
030f725c 1106[wax](https://github.com/kanaka/wac),
d88adace
JM
1107[wace](https://github.com/kanaka/wac),
1108[warpy](https://github.com/kanaka/warpy).
d72395aa
JM
1109
1110```
1111cd wasm
d88adace
JM
1112# node
1113make wasm_MODE=node
1114./run.js ./stepX_YYY.wasm
1115# wasmtime
1116make wasm_MODE=wasmtime
1117wasmtime --dir=./ --dir=../ --dir=/ ./stepX_YYY.wasm
9a7485aa
JM
1118# wasmer
1119make wasm_MODE=wasmer
1120wasmer run --dir=./ --dir=../ --dir=/ ./stepX_YYY.wasm
1121# lucet
1122make wasm_MODE=lucet
1123lucet-wasi --dir=./:./ --dir=../:../ --dir=/:/ ./stepX_YYY.so
030f725c
JM
1124# wax
1125make wasm_MODE=wax
9a7485aa 1126wax ./stepX_YYY.wasm
d88adace
JM
1127# wace
1128make wasm_MODE=wace_libc
d72395aa 1129wace ./stepX_YYY.wasm
d88adace
JM
1130# warpy
1131make wasm_MODE=warpy
1132warpy --argv --memory-pages 256 ./stepX_YYY.wasm
d72395aa
JM
1133```
1134
84eaa11c
DM
1135### Wren
1136
1137The Wren implementation of mal was tested on Wren 0.2.0.
1138
1139```
1140cd wren
1141wren ./stepX_YYY.wren
1142```
1143
a3665311
DM
1144### Yorick
1145
a3665311
DM
1146The Yorick implementation of mal was tested on Yorick 2.2.04.
1147
1148```
1149cd yorick
1150yorick -batch ./stepX_YYY.i
1151```
1152
ee7cd585
JM
1153
1154
592eb5cf
JM
1155## Running tests
1156
d57f74df
JM
1157The top level Makefile has a number of useful targets to assist with
1158implementation development and testing. The `help` target provides
1159a list of the targets and options:
1160
1161```
1162make help
1163```
1164
294aba2c
JM
1165### Functional tests
1166
9a7485aa 1167The are almost 800 generic functional tests (for all implementations)
294aba2c
JM
1168in the `tests/` directory. Each step has a corresponding test file
1169containing tests specific to that step. The `runtest.py` test harness
bd62ff74
JM
1170launches a Mal step implementation and then feeds the tests one at
1171a time to the implementation and compares the output/return value to
1172the expected output/return value.
592eb5cf 1173
592eb5cf
JM
1174* To run all the tests across all implementations (be prepared to wait):
1175
1176```
1177make test
1178```
1179
1180* To run all tests against a single implementation:
1181
1182```
e5737b08 1183make "test^IMPL"
592eb5cf
JM
1184
1185# e.g.
e5737b08
SL
1186make "test^clojure"
1187make "test^js"
592eb5cf
JM
1188```
1189
1190* To run tests for a single step against all implementations:
1191
1192```
e5737b08 1193make "test^stepX"
592eb5cf
JM
1194
1195# e.g.
e5737b08
SL
1196make "test^step2"
1197make "test^step7"
592eb5cf
JM
1198```
1199
4c58cd4e 1200* To run tests for a specific step against a single implementation:
592eb5cf
JM
1201
1202```
e5737b08 1203make "test^IMPL^stepX"
592eb5cf
JM
1204
1205# e.g
e5737b08
SL
1206make "test^ruby^step3"
1207make "test^ps^step4"
592eb5cf 1208```
fd888612 1209
294aba2c
JM
1210### Self-hosted functional tests
1211
1212* To run the functional tests in self-hosted mode, you specify `mal`
1213 as the test implementation and use the `MAL_IMPL` make variable
1214 to change the underlying host language (default is JavaScript):
1215```
e5737b08 1216make MAL_IMPL=IMPL "test^mal^step2"
294aba2c
JM
1217
1218# e.g.
e5737b08
SL
1219make "test^mal^step2" # js is default
1220make MAL_IMPL=ruby "test^mal^step2"
1221make MAL_IMPL=python "test^mal^step2"
294aba2c
JM
1222```
1223
854cf2a6
DM
1224### Starting the REPL
1225
1226* To start the REPL of an implementation in a specific step:
1227
1228```
1229make "repl^IMPL^stepX"
1230
1231# e.g
1232make "repl^ruby^step3"
1233make "repl^ps^step4"
1234```
1235
1236* If you omit the step, then `stepA` is used:
1237
1238```
1239make "repl^IMPL"
1240
1241# e.g
1242make "repl^ruby"
1243make "repl^ps"
1244```
1245
1246* To start the REPL of the self-hosted implementation, specify `mal` as the
1247 REPL implementation and use the `MAL_IMPL` make variable to change the
1248 underlying host language (default is JavaScript):
1249```
1250make MAL_IMPL=IMPL "repl^mal^stepX"
1251
1252# e.g.
1253make "repl^mal^step2" # js is default
1254make MAL_IMPL=ruby "repl^mal^step2"
1255make MAL_IMPL=python "repl^mal"
1256```
294aba2c
JM
1257
1258### Performance tests
1259
8569b2af
JM
1260Warning: These performance tests are neither statistically valid nor
1261comprehensive; runtime performance is a not a primary goal of mal. If
1262you draw any serious conclusions from these performance tests, then
1263please contact me about some amazing oceanfront property in Kansas
1264that I'm willing to sell you for cheap.
1265
294aba2c
JM
1266* To run performance tests against a single implementation:
1267```
e5737b08 1268make "perf^IMPL"
294aba2c
JM
1269
1270# e.g.
e5737b08 1271make "perf^js"
294aba2c
JM
1272```
1273
1274* To run performance tests against all implementations:
1275```
e5737b08 1276make "perf"
294aba2c
JM
1277```
1278
1279### Generating language statistics
1280
4c58cd4e 1281* To report line and byte statistics for a single implementation:
294aba2c 1282```
e5737b08 1283make "stats^IMPL"
294aba2c
JM
1284
1285# e.g.
e5737b08 1286make "stats^js"
294aba2c
JM
1287```
1288
5b207de7 1289## Dockerized testing
75363567 1290
5b207de7
JM
1291Every implementation directory contains a Dockerfile to create
1292a docker image containing all the dependencies for that
1293implementation. In addition, the top-level Makefile contains support
1294for running the tests target (and perf, stats, repl, etc) within
1295a docker container for that implementation by passing *"DOCKERIZE=1"*
1296on the make command line. For example:
75363567 1297
75363567 1298```
5b207de7 1299make DOCKERIZE=1 "test^js^step3"
75363567
JM
1300```
1301
5b207de7
JM
1302Existing implementations already have docker images built and pushed
1303to the docker registry. However, if
1304you wish to build or rebuild a docker image locally, the toplevel
1305Makefile provides a rule for building docker images:
1306
75363567 1307```
5b207de7
JM
1308make "docker-build^IMPL"
1309```
1310
75363567
JM
1311
1312**Notes**:
5b207de7
JM
1313* Docker images are named *"kanaka/mal-test-IMPL"*
1314* JVM-based language implementations (Groovy, Java, Clojure, Scala):
70cefa38
RM
1315 you will probably need to run this command once manually
1316 first `make DOCKERIZE=1 "repl^IMPL"` before you can run tests because
5b207de7 1317 runtime dependencies need to be downloaded to avoid the tests timing
70cefa38 1318 out. These dependencies are downloaded to dot-files in the /mal
5b207de7 1319 directory so they will persist between runs.
75363567 1320
07734c09 1321
fd888612
JM
1322## License
1323
1324Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
1325License 2.0). See LICENSE.txt for more details.