Add rexx implementation
[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
27696157 7Mal is a Clojure inspired Lisp interpreter.
b76aa73b 8
9592d833 9Mal is implemented in 66 languages:
bcddc3e4 10
6faafa00 11* Ada
8c7587af 12* GNU awk
edc3b064 13* Bash shell
2bcc46af 14* BASIC (C64 and QBasic)
bcddc3e4 15* C
73fc9366 16* C++
edc3b064 17* C#
385a08eb 18* ChucK
e7f85ce1 19* Common Lisp
edc3b064 20* Clojure
891c3f3b 21* CoffeeScript
6c4dede1 22* Crystal
f82cb965 23* D
bcf95720 24* Dart
bb526975 25* Elixir
e0b7f668 26* Emacs Lisp
2cc3804b 27* Erlang
88e934b6 28* ES6 (ECMAScript 6 / ECMAScript 2015)
6f78381f 29* F#
0fe47e88 30* Factor
96032890 31* Forth
1771ab50 32* Go
7ab0f63e 33* Groovy
7c6882f2 34* GNU Guile
9592d833 35* GNU Smalltalk
b76aa73b 36* Haskell
33dec7af 37* Haxe
61f69fba 38* Io
bcddc3e4 39* Java
39381792
JM
40* JavaScript ([Online Demo](http://kanaka.github.io/mal))
41* Julia
53c2ea70 42* Kotlin
0af8fd20 43* LiveScript
4eb88ef2 44* Logo
9d42904e 45* Lua
bcddc3e4
JM
46* GNU Make
47* mal itself
8a9d0a8a 48* MATLAB
1218ce98 49* [miniMAL](https://github.com/kanaka/miniMAL)
a2cd0a3a 50* Nim
0067158f 51* Object Pascal
7cae6e6f 52* Objective C
bc6448bc 53* OCaml
6301e0b6 54* Perl
a7081401 55* Perl 6
edc3b064 56* PHP
b6263859 57* Picolisp
b88bb764
JM
58* PL/pgSQL (Postgres)
59* PL/SQL (Oracle)
edc3b064 60* Postscript
5c34565f 61* PowerShell
edc3b064 62* Python
23e38cd2 63* RPython
9b3362e8 64* R
f5223195 65* Racket
8adb0827 66* Ruby
abdd56eb 67* Rust
821930db 68* Scala
034e82ad 69* Skew
8b142f08 70* Swift
ea1395aa 71* Swift 3
54d9903c 72* Tcl
db885df9 73* TypeScript
36e91db4 74* VHDL
50a964ce 75* Vimscript
ee7cd585 76* Visual Basic.NET
bcddc3e4
JM
77
78
bd08422d
JM
79Mal is a learning tool. See the [make-a-lisp process
80guide](process/guide.md). Each implementation of mal is separated into
8111 incremental, self-contained (and testable) steps that demonstrate
82core concepts of Lisp. The last step is capable of self-hosting
83(running the mal implementation of mal).
bcddc3e4
JM
84
85The mal (make a lisp) steps are:
86
0f4ca9d1
JM
87* [step0_repl](process/guide.md#step0)
88* [step1_read_print](process/guide.md#step1)
89* [step2_eval](process/guide.md#step2)
90* [step3_env](process/guide.md#step3)
91* [step4_if_fn_do](process/guide.md#step4)
92* [step5_tco](process/guide.md#step5)
93* [step6_file](process/guide.md#step6)
94* [step7_quote](process/guide.md#step7)
95* [step8_macros](process/guide.md#step8)
96* [step9_try](process/guide.md#step9)
90f618cb 97* [stepA_mal](process/guide.md#stepA)
bcddc3e4
JM
98
99
100Mal was presented publicly for the first time in a lightning talk at
101Clojure West 2014 (unfortunately there is no video). See
dede32ba
JM
102examples/clojurewest2014.mal for the presentation that was given at the
103conference (yes the presentation is a mal program). At Midwest.io
1042015, Joel Martin gave a presentation on Mal titled "Achievement
105Unlocked: A Better Path to Language Learning".
106[Video](https://www.youtube.com/watch?v=lgyOAiRtZGw),
9ed75afd
JM
107[Slides](http://kanaka.github.io/midwest.io.mal/). More recently
108Joel gave a presentation on "Make Your Own Lisp Interpreter in
10910 Incremental Steps" at LambdaConf 2016: [Part
1101](https://www.youtube.com/watch?v=jVhupfthTEk), [Part
1112](https://www.youtube.com/watch?v=X5OQBMGpaTU),
112[Slides](http://kanaka.github.io/lambdaconf/).
60154d24 113
144f2b6a 114If you are interesting in creating a mal implementation (or just
bd62ff74 115interested in using mal for something), please drop by the #mal
144f2b6a
JM
116channel on freenode. In addition to the [make-a-lisp process
117guide](process/guide.md) there is also a [mal/make-a-lisp
118FAQ](docs/FAQ.md) where I attempt to answer some common questions.
119
60154d24
JM
120## Building/running implementations
121
5b207de7
JM
122The simplest way to run any given implementation is to use docker.
123Every implementation has a docker image pre-built with language
124dependencies installed. You can launch the REPL using a convenience
125target in the top level Makefile (where IMPL is the implementation
126directory name and stepX is the step to run):
127
128```
129make DOCKERIZE=1 "repl^IMPL^stepX"
130 # OR stepA is the default step:
131make DOCKERIZE=1 "repl^IMPL"
132```
133
134
6faafa00
CM
135### Ada
136
7b458a65
JM
137*The Ada implementation was created by [Chris Moore](https://github.com/zmower)*
138
139The Ada implementation was developed with GNAT 4.9 on debian. It also
140compiles unchanged on windows if you have windows versions of git,
141GNAT and (optionally) make. There are no external dependencies
142(readline not implemented).
6faafa00
CM
143
144```
145cd ada
146make
147./stepX_YYY
148```
149
8c7587af
MK
150### GNU awk
151
4c58cd4e 152*The GNU awk implementation was created by [Miutsuru kariya](https://github.com/kariya-mitsuru)*
390d5829 153
8c7587af
MK
154The GNU awk implementation of mal has been tested with GNU awk 4.1.1.
155
156```
157cd gawk
158gawk -O -f stepX_YYY.awk
159```
160
bcddc3e4 161### Bash 4
60154d24
JM
162
163```
164cd bash
165bash stepX_YYY.sh
166```
167
2bcc46af 168### BASIC (C64 and QBasic)
1b245300 169
2bcc46af
JM
170The BASIC implementation uses a preprocessor that can generate BASIC
171code that is compatible with both C64 BASIC (CBM v2) and QBasic. The
1b245300
JM
172C64 mode has been tested with
173[cbmbasic](https://github.com/kanaka/cbmbasic) (the patched version is
174currently required to fix issues with line input) and the QBasic mode
175has been tested with [qb64](http://www.qb64.net/).
176
177Generate C64 code and run it using cbmbasic:
178
179```
180cd basic
181make stepX_YYY.bas
182STEP=stepX_YYY ./run
183```
184
185Generate QBasic code and load it into qb64:
186
187```
188cd basic
189make MODE=qbasic stepX_YYY.bas
190./qb64 stepX_YYY.bas
191```
192
193Thanks to [Steven Syrek](https://github.com/sjsyrek) for the original
194inspiration for this implementation.
195
196
bcddc3e4 197### C
60154d24 198
01c97316 199The C implementation of mal requires the following libraries (lib and
6b3ecaa7
DM
200header packages): glib, libffi6, libgc, and either the libedit or GNU readline
201library.
54c75382 202
60154d24
JM
203```
204cd c
205make
206./stepX_YYY
207```
208
73fc9366
JM
209### C++
210
a848d783
JM
211*The C++ implementation was created by [Stephen Thirlwall (sdt)](https://github.com/sdt)*
212
73fc9366
JM
213The C++ implementation of mal requires g++-4.9 or clang++-3.5 and
214a readline compatible library to build. See the `cpp/README.md` for
215more details:
216
217```
218cd cpp
219make
220 # OR
221make CXX=clang++-3.5
222./stepX_YYY
223```
224
225
9b1563a3 226### C# ###
edc3b064
JM
227
228The C# implementation of mal has been tested on Linux using the Mono
229C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
230required to build and run the C# implementation.
231
232```
233cd cs
234make
ee7cd585 235mono ./stepX_YYY.exe
edc3b064
JM
236```
237
385a08eb
VS
238### ChucK
239
240*The ChucK implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
241
332611f5 242The ChucK implementation has been tested with ChucK 1.3.5.2.
385a08eb
VS
243
244```
245cd chuck
246./run
247```
edc3b064 248
e7f85ce1 249### Common Lisp
b0e08374 250
e7f85ce1 251*The Common Lisp implementation was created by [Iqbal Ansari](https://github.com/iqbalansari)*
b0e08374 252
e7f85ce1
IA
253The implementation has been tested with SBCL, CCL, CMUCL, GNU CLISP, ECL and
254Allegro CL on Ubuntu 16.04 and Ubuntu 12.04, see
255the [README][common-lisp/README.org] for more details. Provided you have the
256dependencies mentioned installed, do the following to run the implementation
b0e08374
IA
257
258```
e7f85ce1 259cd common-lisp
b0e08374
IA
260make
261./run
262```
263
bcddc3e4 264### Clojure
60154d24 265
aa716df6
JM
266For the most part the Clojure implementation requires Clojure 1.5,
267however, to pass all tests, Clojure 1.8.0-RC4 is required.
268
60154d24
JM
269```
270cd clojure
271lein with-profile +stepX trampoline run
272```
273
891c3f3b
JM
274### CoffeeScript
275
276```
277sudo npm install -g coffee-script
278cd coffee
279coffee ./stepX_YYY
280```
281
58b84dd5 282### Crystal
283
6427adea 284*The Crystal implementation of mal was created by [Linda_pp](https://github.com/rhysd)*
6c4dede1 285
d10848bb 286The Crystal implementation of mal has been tested with Crystal 0.18.4.
6c4dede1 287
58b84dd5 288```
289cd crystal
290crystal run ./stepX_YYY.cr
6c4dede1
JM
291 # OR
292make # needed to run tests
293./stepX_YYY
58b84dd5 294```
295
f82cb965
DM
296### D
297
298*The D implementation was created by [Dov Murik](https://github.com/dubek)*
299
300The D implementation of mal was tested with GDC 4.8. It requires the GNU
301readline library.
302
303```
304cd d
305make
306./stepX_YYY
307```
308
bcf95720
HT
309### Dart
310
311*The Dart implementation was created by [Harry Terkelsen](https://github.com/hterkelsen)*
312
313The Dart implementation has been tested with Dart 1.20.
314
315```
316cd dart
317dart ./stepX_YYY
318```
319
e0b7f668
VS
320### Emacs Lisp
321
322*The Emacs Lisp implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
323
324The Emacs Lisp implementation of mal has been tested with Emacs 24.3
325and 24.5. While there is very basic readline editing (`<backspace>`
326and `C-d` work, `C-c` cancels the process), it is recommended to use
327`rlwrap`.
328
329```
330cd elisp
331emacs -Q --batch --load stepX_YYY.el
332# with full readline support
333rlwrap emacs -Q --batch --load stepX_YYY.el
334```
335
bb526975 336### Elixir
337
338*The Elixir implementation was created by [Martin Ek (ekmartin)](https://github.com/ekmartin)*
339
340The Elixir implementation of mal has been tested with Elixir 1.0.5.
341
342```
343cd elixir
df2ca97b 344mix stepX_YYY
345# Or with readline/line editing functionality:
bb526975 346iex -S mix stepX_YYY
347```
348
2cc3804b
NF
349### Erlang
350
425ef3d7
JM
351*The Erlang implementation was created by [Nathan Fiedler (nlfiedler)](https://github.com/nlfiedler)*
352
82484631
JM
353The Erlang implementation of mal requires [Erlang/OTP R17](http://www.erlang.org/download.html)
354and [rebar](https://github.com/rebar/rebar) to build.
2cc3804b
NF
355
356```
357cd erlang
425ef3d7
JM
358make
359 # OR
360MAL_STEP=stepX_YYY rebar compile escriptize # build individual step
2cc3804b
NF
361./stepX_YYY
362```
363
88e934b6
JM
364### ES6 (ECMAScript 6 / ECMAScript 2015)
365
366The ES6 implementation uses the [babel](https://babeljs.io) compiler
367to generate ES5 compatible JavaScript. The generated code has been
368tested with Node 0.12.4.
369
370```
371cd es6
372make
373node build/stepX_YYY.js
374```
375
376
6f78381f
PS
377### F# ###
378
379*The F# implementation was created by [Peter Stephens (pstephens)](https://github.com/pstephens)*
380
381The F# implementation of mal has been tested on Linux using the Mono
382F# compiler (fsharpc) and the Mono runtime (version 3.12.1). The mono C#
206a1657 383compiler (mcs) is also necessary to compile the readline dependency. All are
6f78381f
PS
384required to build and run the F# implementation.
385
386```
387cd fsharp
388make
389mono ./stepX_YYY.exe
390```
391
5a53c643
JL
392### Factor
393
44c8a524 394*The Factor implementation was created by [Jordan Lewis (jordanlewis)](https://github.com/jordanlewis)*
5a53c643 395
0fe47e88 396The Factor implementation of mal has been tested with Factor 0.97
07eb827b 397([factorcode.org](http://factorcode.org)).
0fe47e88 398
5a53c643
JL
399```
400cd factor
199b1ce7 401FACTOR_ROOTS=. factor -run=stepX_YYY
5a53c643
JL
402```
403
96032890
C
404### Forth
405
a848d783
JM
406*The Forth implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
407
96032890
C
408```
409cd forth
410gforth stepX_YYY.fs
411```
412
1771ab50
JM
413### Go
414
0fe47e88 415The Go implementation of mal requires that go is installed on on the
fd888612
JM
416path. The implementation has been tested with Go 1.3.1.
417
1771ab50
JM
418```
419cd go
420make
421./stepX_YYY
422```
423
424
7ab0f63e
JM
425### Groovy
426
427The Groovy implementation of mal requires Groovy to run and has been
428tested with Groovy 1.8.6.
429
430```
431cd groovy
432make
433groovy ./stepX_YYY.groovy
434```
435
5a9cda80
JM
436### GNU Guile 2.1+
437
438*The Guile implementation was created by [Mu Lei (NalaGinrut)](https://github.com/NalaGinrut).*
439
440```
441cd guile
442guile -L ./ stepX_YYY.scm
443```
7ab0f63e 444
9592d833
VS
445### GNU Smalltalk
446
447*The Smalltalk implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
448
449The Smalltalk implementation of mal has been tested with GNU Smalltalk 3.2.91.
450
451```
452cd gst
453./run
454```
455
b76aa73b
JM
456### Haskell
457
f60f33e0
JM
458The Haskell implementation requires the ghc compiler version 7.10.1 or
459later and also the Haskell parsec and readline (or editline) packages.
b76aa73b
JM
460
461```
462cd haskell
463make
464./stepX_YYY
465```
466
33dec7af
JM
467### Haxe
468
469The Haxe implementation of mal requires Haxe version 3.2 to compile.
470Four different Haxe targets are supported: Neko, Python, C++, and
471JavaScript.
472
473```
474cd haxe
475# Neko
476make all-neko
477neko ./stepX_YYY.n
478# Python
479make all-python
480python3 ./stepX_YYY.py
481# C++
482make all-cpp
483./cpp/stepX_YYY
484# JavaScript
485make all-js
486node ./stepX_YYY.js
487```
488
61f69fba
DM
489### Io
490
491*The Io implementation was created by [Dov Murik](https://github.com/dubek)*
492
493The Io implementation of mal has been tested with Io version 20110905.
494
495```
496cd io
497io ./stepX_YYY.io
498```
b76aa73b 499
bcddc3e4 500### Java 1.7
60154d24 501
01c97316
JM
502The Java implementation of mal requires maven2 to build.
503
60154d24
JM
504```
505cd java
506mvn compile
507mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
508 # OR
509mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
510```
511
39381792 512### JavaScript/Node
60154d24
JM
513
514```
515cd js
54c75382 516npm update
60154d24
JM
517node stepX_YYY.js
518```
519
39381792
JM
520### Julia
521
82484631 522The Julia implementation of mal requires Julia 0.4.
39381792
JM
523
524```
525cd julia
526julia stepX_YYY.jl
527```
528
53c2ea70
JFI
529### Kotlin
530
531*The Kotlin implementation was created by [Javier Fernandez-Ivern](https://github.com/ivern)*
532
75787d77 533The Kotlin implementation of mal has been tested with Kotlin 1.0.
53c2ea70
JFI
534
535```
536cd kotlin
537make
538java -jar stepX_YYY.jar
539```
540
0af8fd20
JB
541### LiveScript
542
543*The LiveScript implementation was created by [Jos van Bakel](https://github.com/c0deaddict)*
544
545The LiveScript implementation of mal has been tested with LiveScript 1.5.
546
547```
548cd livescript
549make
550node_modules/.bin/lsc stepX_YYY.ls
551```
552
4eb88ef2
DM
553### Logo
554
555*The Logo implementation was created by [Dov Murik](https://github.com/dubek)*
556
557The Logo implementation of mal has been tested with UCBLogo 6.0.
558
559```
560cd logo
561logo stepX_YYY.lg
562```
563
9d42904e
JM
564### Lua
565
8a9d0a8a 566Running the Lua implementation of mal requires lua 5.1 or later,
9d42904e
JM
567luarocks and the lua-rex-pcre library installed.
568
569```
570cd lua
571make # to build and link linenoise.so
572./stepX_YYY.lua
573```
574
bcddc3e4 575### Mal
60154d24
JM
576
577Running the mal implementation of mal involves running stepA of one of
578the other implementations and passing the mal step to run as a command
5d446bd8 579line argument.
60154d24
JM
580
581```
582cd IMPL
583IMPL_STEPA_CMD ../mal/stepX_YYY.mal
584
585```
586
bcddc3e4 587### GNU Make 3.81
60154d24
JM
588
589```
590cd make
591make -f stepX_YYY.mk
592```
593
4603f2a9 594### Nim 0.17.0
a2cd0a3a 595
a848d783
JM
596*The Nim implementation was created by [Dennis Felsing (def-)](https://github.com/def-)*
597
4603f2a9 598The Nim implementation of mal has been tested with Nim 0.17.0.
a2cd0a3a 599
600```
601cd nim
602make
603 # OR
604nimble build
605./stepX_YYY
606```
607
0067158f
JM
608### Object Pascal
609
610The Object Pascal implementation of mal has been built and tested on
611Linux using the Free Pascal compiler version 2.6.2 and 2.6.4.
612
613```
614cd objpascal
615make
616./stepX_YYY
617```
618
7cae6e6f
JM
619### Objective C
620
621The Objective C implementation of mal has been built and tested on
2faae94c
JM
622Linux using clang/LLVM 3.6. It has also been built and tested on OS
623X using XCode 7.
7cae6e6f
JM
624
625```
626cd objc
627make
628./stepX_YYY
629```
630
bc6448bc
C
631### OCaml 4.01.0
632
a848d783
JM
633*The OCaml implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
634
bc6448bc
C
635```
636cd ocaml
637make
638./stepX_YYY
639```
640
8a9d0a8a
JM
641### MATLAB
642
643The MATLAB implementation of mal has been tested with MATLAB version
644R2014a on Linux. Note that MATLAB is a commercial product. It should
645be fairly simple to support GNU Octave once it support classdef object
646syntax.
647
648```
649cd matlab
650./stepX_YYY
651matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
652 # OR with command line arguments
653matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
654```
655
1218ce98
JM
656### miniMAL
657
658[miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
659implemented in less than 1024 bytes of JavaScript. To run the miniMAL
660implementation of mal you need to download/install the miniMAL
661interpreter (which requires Node.js).
662```
1218ce98 663cd miniMAL
478fd9ce
JM
664# Download miniMAL and dependencies
665npm install
666export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
667# Now run mal implementation in miniMAL
1218ce98
JM
668miniMAL ./stepX_YYY
669```
670
9b1563a3 671### Perl 5.8
9e5b2151
JM
672
673For readline line editing support, install Term::ReadLine::Perl or
674Term::ReadLine::Gnu from CPAN.
675
676```
677cd perl
678perl stepX_YYY.pl
679```
680
a7081401
HÖS
681### Perl 6
682
683*The Perl 6 implementation was created by [Hinrik Örn Sigurðsson](https://github.com/hinrik)*
684
685The Perl 6 implementation was tested on Rakudo Perl 6 2016.04.
686
687```
688cd perl6
689perl6 stepX_YYY.pl
690```
9e5b2151 691
bcddc3e4 692### PHP 5.3
60154d24 693
01c97316
JM
694The PHP implementation of mal requires the php command line interface
695to run.
696
60154d24
JM
697```
698cd php
699php stepX_YYY.php
700```
701
b6263859
VS
702### Picolisp
703
704*The Picolisp implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
705
706The Picolisp implementation requires libreadline and Picolisp 3.1.11
707or later.
708
709```
710cd pil
711./run
712```
713
b25bf8d8
JM
714### PL/pgSQL (Postgres SQL Procedural Language)
715
b88bb764
JM
716The PL/pgSQL implementation of mal requires a running Postgres server
717(the "kanaka/mal-test-plpgsql" docker image automatically starts
718a Postgres server). The implementation connects to the Postgres server
719and create a database named "mal" to store tables and stored
720procedures. The wrapper script uses the psql command to connect to the
721server and defaults to the user "postgres" but this can be overridden
722with the PSQL_USER environment variable. A password can be specified
723using the PGPASSWORD environment variable. The implementation has been
724tested with Postgres 9.4.
b25bf8d8
JM
725
726```
727cd plpgsql
728./wrap.sh stepX_YYY.sql
b88bb764
JM
729 # OR
730PSQL_USER=myuser PGPASSWORD=mypass ./wrap.sh stepX_YYY.sql
731```
732
733### PL/SQL (Oracle SQL Procedural Language)
734
735The PL/pgSQL implementation of mal requires a running Oracle DB
736server (the "kanaka/mal-test-plsql" docker image automatically
737starts an Oracle Express server). The implementation connects to the
738Oracle server to create types, tables and stored procedures. The
739default SQL*Plus logon value (username/password@connect_identifier) is
740"system/oracle" but this can be overridden with the ORACLE_LOGON
741environment variable. The implementation has been tested with Oracle
742Express Edition 11g Release 2. Note that any SQL*Plus connection
743warnings (user password expiration, etc) will interfere with the
744ability of the wrapper script to communicate with the DB.
745
746```
747cd plsql
748./wrap.sh stepX_YYY.sql
749 # OR
750ORACLE_LOGON=myuser/mypass@ORCL ./wrap.sh stepX_YYY.sql
b25bf8d8
JM
751```
752
5c34565f
JM
753### Postscript Level 2/3
754
755The Postscript implementation of mal requires ghostscript to run. It
756has been tested with ghostscript 9.10.
757
758```
759cd ps
760gs -q -dNODISPLAY -I./ stepX_YYY.ps
761```
762
763### PowerShell
764
765The PowerShell implementation of mal requires the PowerShell script
766language. It has been tested with PowerShell 6.0.0 Alpha 9 on Linux.
767
768```
769cd powershell
770powershell ./stepX_YYY.ps1
771```
772
23e38cd2 773### Python (2.X or 3.X)
60154d24
JM
774
775```
776cd python
777python stepX_YYY.py
778```
8adb0827 779
23e38cd2
JM
780### RPython
781
782You must have [rpython](https://rpython.readthedocs.org/) on your path
783(included with [pypy](https://bitbucket.org/pypy/pypy/)).
784
785```
786cd rpython
4e8d7c28 787make # this takes a very long time
23e38cd2
JM
788./stepX_YYY
789```
790
9b3362e8
JM
791### R
792
793The R implementation of mal requires R (r-base-core) to run.
794
795```
796cd r
9d42904e 797make libs # to download and build rdyncall
f5223195
JM
798Rscript stepX_YYY.r
799```
800
801### Racket (5.3)
802
803The Racket implementation of mal requires the Racket
804compiler/interpreter to run.
805
806```
807cd racket
3796240a 808./stepX_YYY.rkt
9b3362e8
JM
809```
810
107d9694 811### Ruby (1.9+)
8adb0827
JM
812
813```
814cd ruby
815ruby stepX_YYY.rb
816```
592eb5cf 817
9106a221 818### Rust (1.0.0 nightly)
abdd56eb
JM
819
820The rust implementation of mal requires the rust compiler and build
821tool (cargo) to build.
822
823```
824cd rust
bbeb1b87 825cargo run --release --bin stepX_YYY
abdd56eb
JM
826```
827
821930db
JM
828### Scala ###
829
830Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
831
832```
833cd scala
834sbt 'run-main stepX_YYY'
835 # OR
836sbt compile
837scala -classpath target/scala*/classes stepX_YYY
838```
839
034e82ad
DM
840### Skew ###
841
842*The Skew implementation was created by [Dov Murik](https://github.com/dubek)*
843
844The Skew implementation of mal has been tested with Skew 0.7.42.
845
846```
847cd skew
848make
849node stepX_YYY.js
850```
851
852
2539e6af
KR
853### Swift
854
a848d783
JM
855*The Swift implementation was created by [Keith Rollin](https://github.com/keith-rollin)*
856
e31349f6
KR
857The Swift implementation of mal requires the Swift 2.0 compiler (XCode
8587.0) to build. Older versions will not work due to changes in the
859language and standard library.
8b142f08 860
2539e6af
KR
861```
862cd swift
863make
864./stepX_YYY
865```
866
ea1395aa
JM
867### Swift 3
868
869The Swift 3 implementation of mal requires the Swift 3.0 compiler. It
a3a6f680 870has been tested with Swift 3 Preview 3.
ea1395aa
JM
871
872```
873cd swift3
874make
875./stepX_YYY
876```
877
54d9903c
DM
878### Tcl 8.6
879
880*The Tcl implementation was created by [Dov Murik](https://github.com/dubek)*
881
882The Tcl implementation of mal requires Tcl 8.6 to run. For readline line
883editing support, install tclreadline.
884
885```
886cd tcl
887tclsh ./stepX_YYY.tcl
888```
889
c527d565 890### TypeScript
891
db885df9 892*The TypeScript implementation was created by [vvakame](https://github.com/vvakame)*
893
c527d565 894The TypeScript implementation of mal requires the TypeScript 2.2 compiler.
db885df9 895It has been tested with Node.js v6.
c527d565 896
897```
898cd ts
899make
900node ./stepX_YYY.js
901```
902
36e91db4
DM
903### VHDL
904
905*The VHDL implementation was created by [Dov Murik](https://github.com/dubek)*
906
907The VHDL implementation of mal has been tested with GHDL 0.29.
908
909```
910cd vhdl
911make
912./run_vhdl.sh ./stepX_YYY
913```
914
50a964ce
DM
915### Vimscript
916
917*The Vimscript implementation was created by [Dov Murik](https://github.com/dubek)*
918
aa62cbda 919The Vimscript implementation of mal requires Vim 8.0 to run.
50a964ce
DM
920
921```
922cd vimscript
923./run_vimscript.sh ./stepX_YYY.vim
924```
925
ee7cd585
JM
926### Visual Basic.NET ###
927
928The VB.NET implementation of mal has been tested on Linux using the Mono
929VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
930required to build and run the VB.NET implementation.
931
932```
933cd vb
934make
935mono ./stepX_YYY.exe
936```
937
938
939
592eb5cf
JM
940## Running tests
941
294aba2c
JM
942### Functional tests
943
eaa6ceb4 944The are over 600 generic functional tests (for all implementations)
294aba2c
JM
945in the `tests/` directory. Each step has a corresponding test file
946containing tests specific to that step. The `runtest.py` test harness
bd62ff74
JM
947launches a Mal step implementation and then feeds the tests one at
948a time to the implementation and compares the output/return value to
949the expected output/return value.
592eb5cf
JM
950
951To simplify the process of running tests, a top level Makefile is
952provided with convenient test targets.
953
954* To run all the tests across all implementations (be prepared to wait):
955
956```
957make test
958```
959
960* To run all tests against a single implementation:
961
962```
e5737b08 963make "test^IMPL"
592eb5cf
JM
964
965# e.g.
e5737b08
SL
966make "test^clojure"
967make "test^js"
592eb5cf
JM
968```
969
970* To run tests for a single step against all implementations:
971
972```
e5737b08 973make "test^stepX"
592eb5cf
JM
974
975# e.g.
e5737b08
SL
976make "test^step2"
977make "test^step7"
592eb5cf
JM
978```
979
4c58cd4e 980* To run tests for a specific step against a single implementation:
592eb5cf
JM
981
982```
e5737b08 983make "test^IMPL^stepX"
592eb5cf
JM
984
985# e.g
e5737b08
SL
986make "test^ruby^step3"
987make "test^ps^step4"
592eb5cf 988```
fd888612 989
294aba2c
JM
990### Self-hosted functional tests
991
992* To run the functional tests in self-hosted mode, you specify `mal`
993 as the test implementation and use the `MAL_IMPL` make variable
994 to change the underlying host language (default is JavaScript):
995```
e5737b08 996make MAL_IMPL=IMPL "test^mal^step2"
294aba2c
JM
997
998# e.g.
e5737b08
SL
999make "test^mal^step2" # js is default
1000make MAL_IMPL=ruby "test^mal^step2"
1001make MAL_IMPL=python "test^mal^step2"
294aba2c
JM
1002```
1003
854cf2a6
DM
1004### Starting the REPL
1005
1006* To start the REPL of an implementation in a specific step:
1007
1008```
1009make "repl^IMPL^stepX"
1010
1011# e.g
1012make "repl^ruby^step3"
1013make "repl^ps^step4"
1014```
1015
1016* If you omit the step, then `stepA` is used:
1017
1018```
1019make "repl^IMPL"
1020
1021# e.g
1022make "repl^ruby"
1023make "repl^ps"
1024```
1025
1026* To start the REPL of the self-hosted implementation, specify `mal` as the
1027 REPL implementation and use the `MAL_IMPL` make variable to change the
1028 underlying host language (default is JavaScript):
1029```
1030make MAL_IMPL=IMPL "repl^mal^stepX"
1031
1032# e.g.
1033make "repl^mal^step2" # js is default
1034make MAL_IMPL=ruby "repl^mal^step2"
1035make MAL_IMPL=python "repl^mal"
1036```
294aba2c
JM
1037
1038### Performance tests
1039
8569b2af
JM
1040Warning: These performance tests are neither statistically valid nor
1041comprehensive; runtime performance is a not a primary goal of mal. If
1042you draw any serious conclusions from these performance tests, then
1043please contact me about some amazing oceanfront property in Kansas
1044that I'm willing to sell you for cheap.
1045
294aba2c
JM
1046* To run performance tests against a single implementation:
1047```
e5737b08 1048make "perf^IMPL"
294aba2c
JM
1049
1050# e.g.
e5737b08 1051make "perf^js"
294aba2c
JM
1052```
1053
1054* To run performance tests against all implementations:
1055```
e5737b08 1056make "perf"
294aba2c
JM
1057```
1058
1059### Generating language statistics
1060
4c58cd4e 1061* To report line and byte statistics for a single implementation:
294aba2c 1062```
e5737b08 1063make "stats^IMPL"
294aba2c
JM
1064
1065# e.g.
e5737b08 1066make "stats^js"
294aba2c
JM
1067```
1068
4c58cd4e 1069* To report line and bytes statistics for general Lisp code (env, core
294aba2c
JM
1070 and stepA):
1071```
e5737b08 1072make "stats-lisp^IMPL"
294aba2c
JM
1073
1074# e.g.
e5737b08 1075make "stats-lisp^js"
294aba2c
JM
1076```
1077
5b207de7 1078## Dockerized testing
75363567 1079
5b207de7
JM
1080Every implementation directory contains a Dockerfile to create
1081a docker image containing all the dependencies for that
1082implementation. In addition, the top-level Makefile contains support
1083for running the tests target (and perf, stats, repl, etc) within
1084a docker container for that implementation by passing *"DOCKERIZE=1"*
1085on the make command line. For example:
75363567 1086
75363567 1087```
5b207de7 1088make DOCKERIZE=1 "test^js^step3"
75363567
JM
1089```
1090
5b207de7
JM
1091Existing implementations already have docker images built and pushed
1092to the docker registry. However, if
1093you wish to build or rebuild a docker image locally, the toplevel
1094Makefile provides a rule for building docker images:
1095
75363567 1096```
5b207de7
JM
1097make "docker-build^IMPL"
1098```
1099
75363567
JM
1100
1101**Notes**:
5b207de7
JM
1102* Docker images are named *"kanaka/mal-test-IMPL"*
1103* JVM-based language implementations (Groovy, Java, Clojure, Scala):
1104 you will probably need to run these implementations once manually
1105 first (make DOCKERIZE=1 "repl^IMPL")before you can run tests because
1106 runtime dependencies need to be downloaded to avoid the tests timing
1107 out. These dependencies are download to dot-files in the /mal
1108 directory so they will persist between runs.
75363567 1109
294aba2c 1110
fd888612
JM
1111## License
1112
1113Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
1114License 2.0). See LICENSE.txt for more details.