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