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