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