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