Commit | Line | Data |
---|---|---|
60154d24 JM |
1 | # mal - Make a Lisp |
2 | ||
bcddc3e4 JM |
3 | ## Description |
4 | ||
5 | Mal is an interpreter for a subset of the Clojure programming | |
6 | language. Mal is implemetated from scratch in 10 different languages: | |
7 | ||
8 | * Javascript | |
9 | * Python | |
10 | * Clojure | |
11 | * C | |
12 | * Java | |
13 | * PHP | |
14 | * Bash shell | |
15 | * GNU Make | |
16 | * mal itself | |
17 | * Postscript (in-progress) | |
18 | ||
19 | ||
20 | Mal is also a learning tool. Each implentation of mal is separated | |
21 | into 11 incremental, self-contained (and testable) steps that | |
22 | demonstrate core concepts of Lisp. The last step is capable of | |
23 | self-hosting (running the mal implemenation of mal). | |
24 | ||
25 | The mal (make a lisp) steps are: | |
26 | ||
27 | * step0_repl | |
28 | * step1_read_print | |
29 | * step2_eval | |
30 | * step3_env | |
31 | * step4_if_fn_do | |
32 | * step5_tco | |
33 | * step6_file | |
34 | * step7_quote | |
35 | * step8_macros | |
36 | * step9_interop | |
37 | * stepA_more | |
38 | ||
39 | ||
40 | Mal was presented publicly for the first time in a lightning talk at | |
41 | Clojure West 2014 (unfortunately there is no video). See | |
42 | mal/clojurewest2014.mal for the presentation that was given at the | |
43 | conference (yes the presentation is a mal program). | |
60154d24 JM |
44 | |
45 | ## Building/running implementations | |
46 | ||
bcddc3e4 | 47 | ### Bash 4 |
60154d24 JM |
48 | |
49 | ``` | |
50 | cd bash | |
51 | bash stepX_YYY.sh | |
52 | ``` | |
53 | ||
bcddc3e4 | 54 | ### C |
60154d24 | 55 | |
54c75382 JM |
56 | The C implementation of mal requires the following libraries: glib, |
57 | libffi6 and either the libedit or GNU readline library. | |
58 | ||
60154d24 JM |
59 | ``` |
60 | cd c | |
61 | make | |
62 | ./stepX_YYY | |
63 | ``` | |
64 | ||
bcddc3e4 | 65 | ### Clojure |
60154d24 JM |
66 | |
67 | ``` | |
68 | cd clojure | |
69 | lein with-profile +stepX trampoline run | |
70 | ``` | |
71 | ||
bcddc3e4 | 72 | ### Java 1.7 |
60154d24 JM |
73 | |
74 | ``` | |
75 | cd java | |
76 | mvn compile | |
77 | mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY | |
78 | # OR | |
79 | mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS" | |
80 | ``` | |
81 | ||
bcddc3e4 | 82 | ### Javascript/Node |
60154d24 JM |
83 | |
84 | ``` | |
85 | cd js | |
54c75382 | 86 | npm update |
60154d24 JM |
87 | node stepX_YYY.js |
88 | ``` | |
89 | ||
bcddc3e4 | 90 | ### Mal |
60154d24 JM |
91 | |
92 | Running the mal implementation of mal involves running stepA of one of | |
93 | the other implementations and passing the mal step to run as a command | |
5d446bd8 | 94 | line argument. |
60154d24 JM |
95 | |
96 | ``` | |
97 | cd IMPL | |
98 | IMPL_STEPA_CMD ../mal/stepX_YYY.mal | |
99 | ||
100 | ``` | |
101 | ||
bcddc3e4 | 102 | ### GNU Make 3.81 |
60154d24 JM |
103 | |
104 | ``` | |
105 | cd make | |
106 | make -f stepX_YYY.mk | |
107 | ``` | |
108 | ||
bcddc3e4 | 109 | ### PHP 5.3 |
60154d24 JM |
110 | |
111 | ``` | |
112 | cd php | |
113 | php stepX_YYY.php | |
114 | ``` | |
115 | ||
bcddc3e4 | 116 | ### Postscript Level 2/3 |
60154d24 JM |
117 | |
118 | ``` | |
119 | cd ps | |
120 | gs -q -dNODISPLAY stepX_YYY.ps | |
121 | ``` | |
122 | ||
bcddc3e4 | 123 | ### Python 2.X |
60154d24 JM |
124 | |
125 | ``` | |
126 | cd python | |
127 | python stepX_YYY.py | |
128 | ``` |