Matlab: update to Octave 4.2.1
[jackhill/mal.git] / README.md
CommitLineData
60154d24
JM
1# mal - Make a Lisp
2
f9e6bb80
JM
3[![Build Status](https://travis-ci.org/kanaka/mal.svg?branch=master)](https://travis-ci.org/kanaka/mal)
4
bcddc3e4
JM
5## Description
6
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
4bb2ab37 49* Matlab (GNU Octave and 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
4bb2ab37 655### MatLab (GNU Octave and MATLAB)
8a9d0a8a 656
4bb2ab37
JM
657The MatLab implementation has been tested with GNU Octave 4.2.1.
658It has also been tested with MATLAB version R2014a on Linux. Note that
659MATLAB is a commercial product.
8a9d0a8a
JM
660
661```
662cd matlab
663./stepX_YYY
4bb2ab37 664octave -q --no-gui --no-history --eval "stepX_YYY();quit;"
8a9d0a8a
JM
665matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
666 # OR with command line arguments
4bb2ab37 667octave -q --no-gui --no-history --eval "stepX_YYY('arg1','arg2');quit;"
8a9d0a8a
JM
668matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
669```
670
1218ce98
JM
671### miniMAL
672
673[miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
674implemented in less than 1024 bytes of JavaScript. To run the miniMAL
675implementation of mal you need to download/install the miniMAL
676interpreter (which requires Node.js).
677```
1218ce98 678cd miniMAL
478fd9ce
JM
679# Download miniMAL and dependencies
680npm install
681export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
682# Now run mal implementation in miniMAL
1218ce98
JM
683miniMAL ./stepX_YYY
684```
685
9b1563a3 686### Perl 5.8
9e5b2151
JM
687
688For readline line editing support, install Term::ReadLine::Perl or
689Term::ReadLine::Gnu from CPAN.
690
691```
692cd perl
693perl stepX_YYY.pl
694```
695
a7081401
HÖS
696### Perl 6
697
698*The Perl 6 implementation was created by [Hinrik Örn Sigurðsson](https://github.com/hinrik)*
699
700The Perl 6 implementation was tested on Rakudo Perl 6 2016.04.
701
702```
703cd perl6
704perl6 stepX_YYY.pl
705```
9e5b2151 706
bcddc3e4 707### PHP 5.3
60154d24 708
01c97316
JM
709The PHP implementation of mal requires the php command line interface
710to run.
711
60154d24
JM
712```
713cd php
714php stepX_YYY.php
715```
716
b6263859
VS
717### Picolisp
718
719*The Picolisp implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
720
721The Picolisp implementation requires libreadline and Picolisp 3.1.11
722or later.
723
724```
725cd pil
726./run
727```
728
b25bf8d8
JM
729### PL/pgSQL (Postgres SQL Procedural Language)
730
b88bb764
JM
731The PL/pgSQL implementation of mal requires a running Postgres server
732(the "kanaka/mal-test-plpgsql" docker image automatically starts
733a Postgres server). The implementation connects to the Postgres server
734and create a database named "mal" to store tables and stored
735procedures. The wrapper script uses the psql command to connect to the
736server and defaults to the user "postgres" but this can be overridden
737with the PSQL_USER environment variable. A password can be specified
738using the PGPASSWORD environment variable. The implementation has been
739tested with Postgres 9.4.
b25bf8d8
JM
740
741```
742cd plpgsql
743./wrap.sh stepX_YYY.sql
b88bb764
JM
744 # OR
745PSQL_USER=myuser PGPASSWORD=mypass ./wrap.sh stepX_YYY.sql
746```
747
748### PL/SQL (Oracle SQL Procedural Language)
749
750The PL/pgSQL implementation of mal requires a running Oracle DB
751server (the "kanaka/mal-test-plsql" docker image automatically
752starts an Oracle Express server). The implementation connects to the
753Oracle server to create types, tables and stored procedures. The
754default SQL*Plus logon value (username/password@connect_identifier) is
755"system/oracle" but this can be overridden with the ORACLE_LOGON
756environment variable. The implementation has been tested with Oracle
757Express Edition 11g Release 2. Note that any SQL*Plus connection
758warnings (user password expiration, etc) will interfere with the
759ability of the wrapper script to communicate with the DB.
760
761```
762cd plsql
763./wrap.sh stepX_YYY.sql
764 # OR
765ORACLE_LOGON=myuser/mypass@ORCL ./wrap.sh stepX_YYY.sql
b25bf8d8
JM
766```
767
5c34565f
JM
768### Postscript Level 2/3
769
770The Postscript implementation of mal requires ghostscript to run. It
771has been tested with ghostscript 9.10.
772
773```
774cd ps
775gs -q -dNODISPLAY -I./ stepX_YYY.ps
776```
777
778### PowerShell
779
780The PowerShell implementation of mal requires the PowerShell script
781language. It has been tested with PowerShell 6.0.0 Alpha 9 on Linux.
782
783```
784cd powershell
785powershell ./stepX_YYY.ps1
786```
787
23e38cd2 788### Python (2.X or 3.X)
60154d24
JM
789
790```
791cd python
792python stepX_YYY.py
793```
8adb0827 794
23e38cd2
JM
795### RPython
796
797You must have [rpython](https://rpython.readthedocs.org/) on your path
798(included with [pypy](https://bitbucket.org/pypy/pypy/)).
799
800```
801cd rpython
4e8d7c28 802make # this takes a very long time
23e38cd2
JM
803./stepX_YYY
804```
805
9b3362e8
JM
806### R
807
808The R implementation of mal requires R (r-base-core) to run.
809
810```
811cd r
9d42904e 812make libs # to download and build rdyncall
f5223195
JM
813Rscript stepX_YYY.r
814```
815
816### Racket (5.3)
817
818The Racket implementation of mal requires the Racket
819compiler/interpreter to run.
820
821```
822cd racket
3796240a 823./stepX_YYY.rkt
9b3362e8
JM
824```
825
44a3e2ef
DM
826### Rexx
827
828*The Rexx implementation was created by [Dov Murik](https://github.com/dubek)*
829
830The Rexx implementation of mal has been tested with Regina Rexx 3.6.
831
832```
833cd rexx
834make
835rexx -a ./stepX_YYY.rexxpp
836```
837
107d9694 838### Ruby (1.9+)
8adb0827
JM
839
840```
841cd ruby
842ruby stepX_YYY.rb
843```
592eb5cf 844
9106a221 845### Rust (1.0.0 nightly)
abdd56eb
JM
846
847The rust implementation of mal requires the rust compiler and build
848tool (cargo) to build.
849
850```
851cd rust
bbeb1b87 852cargo run --release --bin stepX_YYY
abdd56eb
JM
853```
854
821930db
JM
855### Scala ###
856
857Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
858
859```
860cd scala
861sbt 'run-main stepX_YYY'
862 # OR
863sbt compile
864scala -classpath target/scala*/classes stepX_YYY
865```
866
034e82ad
DM
867### Skew ###
868
869*The Skew implementation was created by [Dov Murik](https://github.com/dubek)*
870
871The Skew implementation of mal has been tested with Skew 0.7.42.
872
873```
874cd skew
875make
876node stepX_YYY.js
877```
878
879
2539e6af
KR
880### Swift
881
a848d783
JM
882*The Swift implementation was created by [Keith Rollin](https://github.com/keith-rollin)*
883
e31349f6
KR
884The Swift implementation of mal requires the Swift 2.0 compiler (XCode
8857.0) to build. Older versions will not work due to changes in the
886language and standard library.
8b142f08 887
2539e6af
KR
888```
889cd swift
890make
891./stepX_YYY
892```
893
ea1395aa
JM
894### Swift 3
895
896The Swift 3 implementation of mal requires the Swift 3.0 compiler. It
a3a6f680 897has been tested with Swift 3 Preview 3.
ea1395aa
JM
898
899```
900cd swift3
901make
902./stepX_YYY
903```
904
54d9903c
DM
905### Tcl 8.6
906
907*The Tcl implementation was created by [Dov Murik](https://github.com/dubek)*
908
909The Tcl implementation of mal requires Tcl 8.6 to run. For readline line
910editing support, install tclreadline.
911
912```
913cd tcl
914tclsh ./stepX_YYY.tcl
915```
916
c527d565 917### TypeScript
918
db885df9 919*The TypeScript implementation was created by [vvakame](https://github.com/vvakame)*
920
c527d565 921The TypeScript implementation of mal requires the TypeScript 2.2 compiler.
db885df9 922It has been tested with Node.js v6.
c527d565 923
924```
925cd ts
926make
927node ./stepX_YYY.js
928```
929
36e91db4
DM
930### VHDL
931
932*The VHDL implementation was created by [Dov Murik](https://github.com/dubek)*
933
934The VHDL implementation of mal has been tested with GHDL 0.29.
935
936```
937cd vhdl
938make
939./run_vhdl.sh ./stepX_YYY
940```
941
50a964ce
DM
942### Vimscript
943
944*The Vimscript implementation was created by [Dov Murik](https://github.com/dubek)*
945
aa62cbda 946The Vimscript implementation of mal requires Vim 8.0 to run.
50a964ce
DM
947
948```
949cd vimscript
950./run_vimscript.sh ./stepX_YYY.vim
951```
952
ee7cd585
JM
953### Visual Basic.NET ###
954
955The VB.NET implementation of mal has been tested on Linux using the Mono
956VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
957required to build and run the VB.NET implementation.
958
959```
960cd vb
961make
962mono ./stepX_YYY.exe
963```
964
965
966
592eb5cf
JM
967## Running tests
968
294aba2c
JM
969### Functional tests
970
eaa6ceb4 971The are over 600 generic functional tests (for all implementations)
294aba2c
JM
972in the `tests/` directory. Each step has a corresponding test file
973containing tests specific to that step. The `runtest.py` test harness
bd62ff74
JM
974launches a Mal step implementation and then feeds the tests one at
975a time to the implementation and compares the output/return value to
976the expected output/return value.
592eb5cf
JM
977
978To simplify the process of running tests, a top level Makefile is
979provided with convenient test targets.
980
981* To run all the tests across all implementations (be prepared to wait):
982
983```
984make test
985```
986
987* To run all tests against a single implementation:
988
989```
e5737b08 990make "test^IMPL"
592eb5cf
JM
991
992# e.g.
e5737b08
SL
993make "test^clojure"
994make "test^js"
592eb5cf
JM
995```
996
997* To run tests for a single step against all implementations:
998
999```
e5737b08 1000make "test^stepX"
592eb5cf
JM
1001
1002# e.g.
e5737b08
SL
1003make "test^step2"
1004make "test^step7"
592eb5cf
JM
1005```
1006
4c58cd4e 1007* To run tests for a specific step against a single implementation:
592eb5cf
JM
1008
1009```
e5737b08 1010make "test^IMPL^stepX"
592eb5cf
JM
1011
1012# e.g
e5737b08
SL
1013make "test^ruby^step3"
1014make "test^ps^step4"
592eb5cf 1015```
fd888612 1016
294aba2c
JM
1017### Self-hosted functional tests
1018
1019* To run the functional tests in self-hosted mode, you specify `mal`
1020 as the test implementation and use the `MAL_IMPL` make variable
1021 to change the underlying host language (default is JavaScript):
1022```
e5737b08 1023make MAL_IMPL=IMPL "test^mal^step2"
294aba2c
JM
1024
1025# e.g.
e5737b08
SL
1026make "test^mal^step2" # js is default
1027make MAL_IMPL=ruby "test^mal^step2"
1028make MAL_IMPL=python "test^mal^step2"
294aba2c
JM
1029```
1030
854cf2a6
DM
1031### Starting the REPL
1032
1033* To start the REPL of an implementation in a specific step:
1034
1035```
1036make "repl^IMPL^stepX"
1037
1038# e.g
1039make "repl^ruby^step3"
1040make "repl^ps^step4"
1041```
1042
1043* If you omit the step, then `stepA` is used:
1044
1045```
1046make "repl^IMPL"
1047
1048# e.g
1049make "repl^ruby"
1050make "repl^ps"
1051```
1052
1053* To start the REPL of the self-hosted implementation, specify `mal` as the
1054 REPL implementation and use the `MAL_IMPL` make variable to change the
1055 underlying host language (default is JavaScript):
1056```
1057make MAL_IMPL=IMPL "repl^mal^stepX"
1058
1059# e.g.
1060make "repl^mal^step2" # js is default
1061make MAL_IMPL=ruby "repl^mal^step2"
1062make MAL_IMPL=python "repl^mal"
1063```
294aba2c
JM
1064
1065### Performance tests
1066
8569b2af
JM
1067Warning: These performance tests are neither statistically valid nor
1068comprehensive; runtime performance is a not a primary goal of mal. If
1069you draw any serious conclusions from these performance tests, then
1070please contact me about some amazing oceanfront property in Kansas
1071that I'm willing to sell you for cheap.
1072
294aba2c
JM
1073* To run performance tests against a single implementation:
1074```
e5737b08 1075make "perf^IMPL"
294aba2c
JM
1076
1077# e.g.
e5737b08 1078make "perf^js"
294aba2c
JM
1079```
1080
1081* To run performance tests against all implementations:
1082```
e5737b08 1083make "perf"
294aba2c
JM
1084```
1085
1086### Generating language statistics
1087
4c58cd4e 1088* To report line and byte statistics for a single implementation:
294aba2c 1089```
e5737b08 1090make "stats^IMPL"
294aba2c
JM
1091
1092# e.g.
e5737b08 1093make "stats^js"
294aba2c
JM
1094```
1095
4c58cd4e 1096* To report line and bytes statistics for general Lisp code (env, core
294aba2c
JM
1097 and stepA):
1098```
e5737b08 1099make "stats-lisp^IMPL"
294aba2c
JM
1100
1101# e.g.
e5737b08 1102make "stats-lisp^js"
294aba2c
JM
1103```
1104
5b207de7 1105## Dockerized testing
75363567 1106
5b207de7
JM
1107Every implementation directory contains a Dockerfile to create
1108a docker image containing all the dependencies for that
1109implementation. In addition, the top-level Makefile contains support
1110for running the tests target (and perf, stats, repl, etc) within
1111a docker container for that implementation by passing *"DOCKERIZE=1"*
1112on the make command line. For example:
75363567 1113
75363567 1114```
5b207de7 1115make DOCKERIZE=1 "test^js^step3"
75363567
JM
1116```
1117
5b207de7
JM
1118Existing implementations already have docker images built and pushed
1119to the docker registry. However, if
1120you wish to build or rebuild a docker image locally, the toplevel
1121Makefile provides a rule for building docker images:
1122
75363567 1123```
5b207de7
JM
1124make "docker-build^IMPL"
1125```
1126
75363567
JM
1127
1128**Notes**:
5b207de7
JM
1129* Docker images are named *"kanaka/mal-test-IMPL"*
1130* JVM-based language implementations (Groovy, Java, Clojure, Scala):
1131 you will probably need to run these implementations once manually
1132 first (make DOCKERIZE=1 "repl^IMPL")before you can run tests because
1133 runtime dependencies need to be downloaded to avoid the tests timing
1134 out. These dependencies are download to dot-files in the /mal
1135 directory so they will persist between runs.
75363567 1136
294aba2c 1137
fd888612
JM
1138## License
1139
1140Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
1141License 2.0). See LICENSE.txt for more details.