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