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