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