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