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