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