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