OCaml: Fix stepA command-line script running
[jackhill/mal.git] / README.md
CommitLineData
60154d24
JM
1# mal - Make a Lisp
2
bcddc3e4
JM
3## Description
4
b76aa73b
JM
5Mal is an Clojure inspired Lisp interpreter.
6
9d42904e 7Mal is implemented in 22 different languages:
bcddc3e4 8
edc3b064 9* Bash shell
bcddc3e4 10* C
edc3b064
JM
11* C#
12* Clojure
891c3f3b 13* CoffeeScript
1771ab50 14* Go
b76aa73b 15* Haskell
bcddc3e4 16* Java
d32f9b87 17* Javascript ([Online Demo](http://kanaka.github.io/mal))
9d42904e 18* Lua
bcddc3e4
JM
19* GNU Make
20* mal itself
6301e0b6 21* Perl
edc3b064
JM
22* PHP
23* Postscript
24* Python
9b3362e8 25* R
f5223195 26* Racket
8adb0827 27* Ruby
abdd56eb 28* Rust
821930db 29* Scala
ee7cd585 30* Visual Basic.NET
bcddc3e4
JM
31
32
0f4ca9d1 33Mal is a [learning tool](process/guide.md). Each implementation of mal is separated into 11
b76aa73b
JM
34incremental, self-contained (and testable) steps that demonstrate core
35concepts of Lisp. The last step is capable of self-hosting (running
36the mal implemenation of mal).
bcddc3e4
JM
37
38The mal (make a lisp) steps are:
39
0f4ca9d1
JM
40* [step0_repl](process/guide.md#step0)
41* [step1_read_print](process/guide.md#step1)
42* [step2_eval](process/guide.md#step2)
43* [step3_env](process/guide.md#step3)
44* [step4_if_fn_do](process/guide.md#step4)
45* [step5_tco](process/guide.md#step5)
46* [step6_file](process/guide.md#step6)
47* [step7_quote](process/guide.md#step7)
48* [step8_macros](process/guide.md#step8)
49* [step9_try](process/guide.md#step9)
50* [stepA_interop](process/guide.md#stepA)
bcddc3e4
JM
51
52
53Mal was presented publicly for the first time in a lightning talk at
54Clojure West 2014 (unfortunately there is no video). See
55mal/clojurewest2014.mal for the presentation that was given at the
56conference (yes the presentation is a mal program).
60154d24
JM
57
58## Building/running implementations
59
bcddc3e4 60### Bash 4
60154d24
JM
61
62```
63cd bash
64bash stepX_YYY.sh
65```
66
bcddc3e4 67### C
60154d24 68
01c97316
JM
69The C implementation of mal requires the following libraries (lib and
70header packages): glib, libffi6 and either the libedit or GNU readline library.
54c75382 71
60154d24
JM
72```
73cd c
74make
75./stepX_YYY
76```
77
9b1563a3 78### C# ###
edc3b064
JM
79
80The C# implementation of mal has been tested on Linux using the Mono
81C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
82required to build and run the C# implementation.
83
84```
85cd cs
86make
ee7cd585 87mono ./stepX_YYY.exe
edc3b064
JM
88```
89
90
bcddc3e4 91### Clojure
60154d24
JM
92
93```
94cd clojure
95lein with-profile +stepX trampoline run
96```
97
891c3f3b
JM
98### CoffeeScript
99
100```
101sudo npm install -g coffee-script
102cd coffee
103coffee ./stepX_YYY
104```
105
1771ab50
JM
106### Go
107
fd888612
JM
108You Go implementation of mal requires that go is installed on on the
109path. The implementation has been tested with Go 1.3.1.
110
1771ab50
JM
111```
112cd go
113make
114./stepX_YYY
115```
116
117
b76aa73b
JM
118### Haskell
119
2988d38e 120Install the Haskell compiler (ghc/ghci), the Haskell platform and
5400d4bf
JM
121either the editline package (BSD) or the readline package (GPL). On
122Ubuntu these packages are: ghc, haskell-platform,
123libghc-readline-dev/libghc-editline-dev
b76aa73b
JM
124
125```
126cd haskell
127make
128./stepX_YYY
129```
130
131
bcddc3e4 132### Java 1.7
60154d24 133
01c97316
JM
134The Java implementation of mal requires maven2 to build.
135
60154d24
JM
136```
137cd java
138mvn compile
139mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
140 # OR
141mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
142```
143
bcddc3e4 144### Javascript/Node
60154d24
JM
145
146```
147cd js
54c75382 148npm update
60154d24
JM
149node stepX_YYY.js
150```
151
9d42904e
JM
152### Lua
153
154Running the Lua implementations of mal requires lua 5.1 or later,
155luarocks and the lua-rex-pcre library installed.
156
157```
158cd lua
159make # to build and link linenoise.so
160./stepX_YYY.lua
161```
162
bcddc3e4 163### Mal
60154d24
JM
164
165Running the mal implementation of mal involves running stepA of one of
166the other implementations and passing the mal step to run as a command
5d446bd8 167line argument.
60154d24
JM
168
169```
170cd IMPL
171IMPL_STEPA_CMD ../mal/stepX_YYY.mal
172
173```
174
bcddc3e4 175### GNU Make 3.81
60154d24
JM
176
177```
178cd make
179make -f stepX_YYY.mk
180```
181
9b1563a3 182### Perl 5.8
9e5b2151
JM
183
184For readline line editing support, install Term::ReadLine::Perl or
185Term::ReadLine::Gnu from CPAN.
186
187```
188cd perl
189perl stepX_YYY.pl
190```
191
192
bcddc3e4 193### PHP 5.3
60154d24 194
01c97316
JM
195The PHP implementation of mal requires the php command line interface
196to run.
197
60154d24
JM
198```
199cd php
200php stepX_YYY.php
201```
202
bcddc3e4 203### Postscript Level 2/3
60154d24 204
01c97316
JM
205The Postscript implementation of mal requires ghostscript to run. It
206has been tested with ghostscript 9.10.
207
60154d24
JM
208```
209cd ps
fa64b741 210gs -q -dNODISPLAY -I./ stepX_YYY.ps
60154d24
JM
211```
212
a05f7822 213### Python (2 or 3)
60154d24
JM
214
215```
216cd python
217python stepX_YYY.py
218```
8adb0827 219
9b3362e8
JM
220### R
221
222The R implementation of mal requires R (r-base-core) to run.
223
224```
225cd r
9d42904e 226make libs # to download and build rdyncall
f5223195
JM
227Rscript stepX_YYY.r
228```
229
230### Racket (5.3)
231
232The Racket implementation of mal requires the Racket
233compiler/interpreter to run.
234
235```
236cd racket
237./stepX_YYY.rb
9b3362e8
JM
238```
239
8adb0827
JM
240### Ruby (1.8)
241
242```
243cd ruby
244ruby stepX_YYY.rb
245```
592eb5cf 246
abdd56eb
JM
247### Rust (0.13)
248
249The rust implementation of mal requires the rust compiler and build
250tool (cargo) to build.
251
252```
253cd rust
111dbaf1
JM
254# Need patched pcre lib (should be temporary)
255git clone https://github.com/kanaka/rust-pcre cadencemarseille-pcre
abdd56eb
JM
256cargo build
257./target/stepX_YYY
258```
259
821930db
JM
260### Scala ###
261
262Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
263
264```
265cd scala
266sbt 'run-main stepX_YYY'
267 # OR
268sbt compile
269scala -classpath target/scala*/classes stepX_YYY
270```
271
ee7cd585
JM
272### Visual Basic.NET ###
273
274The VB.NET implementation of mal has been tested on Linux using the Mono
275VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
276required to build and run the VB.NET implementation.
277
278```
279cd vb
280make
281mono ./stepX_YYY.exe
282```
283
284
285
592eb5cf
JM
286## Running tests
287
a816262a 288The are nearly 500 generic Mal tests (for all implementations) in the
592eb5cf
JM
289`tests/` directory. Each step has a corresponding test file containing
290tests specific to that step. The `runtest.py` test harness uses
291pexpect to launch a Mal step implementation and then feeds the tests
292one at a time to the implementation and compares the output/return
293value to the expected output/return value.
294
295To simplify the process of running tests, a top level Makefile is
296provided with convenient test targets.
297
298* To run all the tests across all implementations (be prepared to wait):
299
300```
301make test
302```
303
304* To run all tests against a single implementation:
305
306```
307make test^IMPL
308
309# e.g.
310make test^clojure
311make test^js
312```
313
314* To run tests for a single step against all implementations:
315
316```
317make test^stepX
318
319# e.g.
320make test^step2
321make test^step7
322```
323
324* To run a specifc step against a single implementation:
325
326```
327make test^IMPL^stepX
328
329# e.g
330make test^ruby^step3
331make test^ps^step4
332```
fd888612
JM
333
334## License
335
336Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
337License 2.0). See LICENSE.txt for more details.
338