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