From bcddc3e49a21adc1250e7c6bea3e36922380d62e Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 29 Mar 2014 19:01:14 -0500 Subject: README: add more details. --- README.md | 62 ++++++++++++++++++----- mal/clojurewest2014.mal | 127 ++++++++++++++++++++++++++++++++++++++++++++++++ mal/presentation.mal | 127 ------------------------------------------------ 3 files changed, 178 insertions(+), 138 deletions(-) create mode 100755 mal/clojurewest2014.mal delete mode 100755 mal/presentation.mal diff --git a/README.md b/README.md index 2784850..5b77c8b 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,57 @@ # mal - Make a Lisp -See mal/presentation.mal +## Description + +Mal is an interpreter for a subset of the Clojure programming +language. Mal is implemetated from scratch in 10 different languages: + +* Javascript +* Python +* Clojure +* C +* Java +* PHP +* Bash shell +* GNU Make +* mal itself +* Postscript (in-progress) + + +Mal is also a learning tool. Each implentation of mal is separated +into 11 incremental, self-contained (and testable) steps that +demonstrate core concepts of Lisp. The last step is capable of +self-hosting (running the mal implemenation of mal). + +The mal (make a lisp) steps are: + +* step0_repl +* step1_read_print +* step2_eval +* step3_env +* step4_if_fn_do +* step5_tco +* step6_file +* step7_quote +* step8_macros +* step9_interop +* stepA_more + + +Mal was presented publicly for the first time in a lightning talk at +Clojure West 2014 (unfortunately there is no video). See +mal/clojurewest2014.mal for the presentation that was given at the +conference (yes the presentation is a mal program). ## Building/running implementations -* Bash 4 +### Bash 4 ``` cd bash bash stepX_YYY.sh ``` -* C +### C ``` cd c @@ -19,14 +59,14 @@ make ./stepX_YYY ``` -* Clojure +### Clojure ``` cd clojure lein with-profile +stepX trampoline run ``` -* Java 1.7 +### Java 1.7 ``` cd java @@ -36,14 +76,14 @@ mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS" ``` -* Javascript/Node +### Javascript/Node ``` cd js node stepX_YYY.js ``` -* Mal +### Mal Running the mal implementation of mal involves running stepA of one of the other implementations and passing the mal step to run as a command @@ -55,28 +95,28 @@ IMPL_STEPA_CMD ../mal/stepX_YYY.mal ``` -* GNU Make 3.81 +### GNU Make 3.81 ``` cd make make -f stepX_YYY.mk ``` -* PHP 5.3 +### PHP 5.3 ``` cd php php stepX_YYY.php ``` -* Postscript Level 2/3 +### Postscript Level 2/3 ``` cd ps gs -q -dNODISPLAY stepX_YYY.ps ``` -* Python 2.X +### Python 2.X ``` cd python diff --git a/mal/clojurewest2014.mal b/mal/clojurewest2014.mal new file mode 100755 index 0000000..2b5be9c --- /dev/null +++ b/mal/clojurewest2014.mal @@ -0,0 +1,127 @@ +;; Mal Presentation + +(def! clear + (fn* () + (str ""))) + +(def! bold + (fn* (s) + (str "" s ""))) + +(def! blue + (fn* (s) + (str "" s ""))) + +(def! title + (fn* (s) + (bold (blue (str s "\n"))))) + +(def! title2 + (fn* (s) + (bold (blue s)))) + + +(def! conj-slides + (list + (list + (title2 " __ __ _ _") + (title2 "| \/ | / \ | |") + (title2 "| |\/| | / _ \ | | ") + (title2 "| | | |/ ___ \| |___ ") + (title2 "|_| |_/_/ \_\_____|")) + (list + (title "gherkin") + "- a lisp1 written in bash4") + (list + (title "mal - an interpreter for a subset of Clojure")) + (list + (title "mal - an interpreter for a subset of Clojure") + "- written in GNU make") + (list + (title "mal - an interpreter for a subset of Clojure") + "- written in GNU make" + "- and Bash 4") + (list + (title "mal - an interpreter for a subset of Clojure") + "- written in GNU make" + "- and Bash 4" + "- and Javascript") + (list + (title "mal - an interpreter for a subset of Clojure") + "- written in GNU make" + "- and Bash 4" + "- and Javascript" + "- and Python") + (list + (title "mal - an interpreter for a subset of Clojure") + "- written in GNU make" + "- and Bash 4" + "- and Javascript" + "- and Python" + "- and Clojure") + (list + (title "mal - an interpreter for a subset of Clojure") + "- written in GNU make" + "- and Bash 4" + "- and Javascript" + "- and Python" + "- and Clojure" + "- and C and Java and PHP") + (list + (title "things it has") + "- scalars: integers, strings, symbols, nil, true, false" + "- immutable collections: lists, vectors, hash-maps" + "- metadata, atoms" + "- def!, fn*, let*" + " - varargs: (fn* (x y & more) ...)" + "- tail call optimization" + " - except GNU make implementation (no iteration)" + "- macros (quote, unquote, quasiquote, splice-quote)" + "- almost 300 unit tests" + "- REPL with readline (GNU readline or libedit)") + (list + (title "things it does not have") + "- performance" + "- namespaces" + "- keywords" + "- GC (in bash, make, C implmentations)" + "- lots of other things") + (list + (title "why?") + "- because!") + (list + (title "why?") + "- because!" + "- gherkin was an inspiration to higher levels of crazy" + "- evolved into learning tool" + "- way to learn about Lisp and also the target language" + "- each implementation broken into small 10 steps") + (list + (title "thanks to:") + "- Peter Norvig: inspiration: lispy" + " - http://norvig.com/lispy.html" + "- Alan Dipert: gherkin, original gherkin slides" + " - https://github.com/alandipert/gherkin") + (list + (title "mal - Make a Lisp") + "https://github.com/kanaka/mal") + (list + (title "demo")))) + +(def! present + (fn* (slides) + (if (> (count slides) 0) + (do + ;;(py!* "import os; r = os.system('clear')") + ;;(sh* "clear") + ;;(make* "$(shell clear)") + (println (clear)) + + ;;(prn (first slides)) + (apply println (map (fn* (line) (str "\n " line)) (first slides))) + (println "\n\n\n") + (readline "") + (present (rest slides)))))) + +(present conj-slides) + diff --git a/mal/presentation.mal b/mal/presentation.mal deleted file mode 100755 index 2b5be9c..0000000 --- a/mal/presentation.mal +++ /dev/null @@ -1,127 +0,0 @@ -;; Mal Presentation - -(def! clear - (fn* () - (str ""))) - -(def! bold - (fn* (s) - (str "" s ""))) - -(def! blue - (fn* (s) - (str "" s ""))) - -(def! title - (fn* (s) - (bold (blue (str s "\n"))))) - -(def! title2 - (fn* (s) - (bold (blue s)))) - - -(def! conj-slides - (list - (list - (title2 " __ __ _ _") - (title2 "| \/ | / \ | |") - (title2 "| |\/| | / _ \ | | ") - (title2 "| | | |/ ___ \| |___ ") - (title2 "|_| |_/_/ \_\_____|")) - (list - (title "gherkin") - "- a lisp1 written in bash4") - (list - (title "mal - an interpreter for a subset of Clojure")) - (list - (title "mal - an interpreter for a subset of Clojure") - "- written in GNU make") - (list - (title "mal - an interpreter for a subset of Clojure") - "- written in GNU make" - "- and Bash 4") - (list - (title "mal - an interpreter for a subset of Clojure") - "- written in GNU make" - "- and Bash 4" - "- and Javascript") - (list - (title "mal - an interpreter for a subset of Clojure") - "- written in GNU make" - "- and Bash 4" - "- and Javascript" - "- and Python") - (list - (title "mal - an interpreter for a subset of Clojure") - "- written in GNU make" - "- and Bash 4" - "- and Javascript" - "- and Python" - "- and Clojure") - (list - (title "mal - an interpreter for a subset of Clojure") - "- written in GNU make" - "- and Bash 4" - "- and Javascript" - "- and Python" - "- and Clojure" - "- and C and Java and PHP") - (list - (title "things it has") - "- scalars: integers, strings, symbols, nil, true, false" - "- immutable collections: lists, vectors, hash-maps" - "- metadata, atoms" - "- def!, fn*, let*" - " - varargs: (fn* (x y & more) ...)" - "- tail call optimization" - " - except GNU make implementation (no iteration)" - "- macros (quote, unquote, quasiquote, splice-quote)" - "- almost 300 unit tests" - "- REPL with readline (GNU readline or libedit)") - (list - (title "things it does not have") - "- performance" - "- namespaces" - "- keywords" - "- GC (in bash, make, C implmentations)" - "- lots of other things") - (list - (title "why?") - "- because!") - (list - (title "why?") - "- because!" - "- gherkin was an inspiration to higher levels of crazy" - "- evolved into learning tool" - "- way to learn about Lisp and also the target language" - "- each implementation broken into small 10 steps") - (list - (title "thanks to:") - "- Peter Norvig: inspiration: lispy" - " - http://norvig.com/lispy.html" - "- Alan Dipert: gherkin, original gherkin slides" - " - https://github.com/alandipert/gherkin") - (list - (title "mal - Make a Lisp") - "https://github.com/kanaka/mal") - (list - (title "demo")))) - -(def! present - (fn* (slides) - (if (> (count slides) 0) - (do - ;;(py!* "import os; r = os.system('clear')") - ;;(sh* "clear") - ;;(make* "$(shell clear)") - (println (clear)) - - ;;(prn (first slides)) - (apply println (map (fn* (line) (str "\n " line)) (first slides))) - (println "\n\n\n") - (readline "") - (present (rest slides)))))) - -(present conj-slides) - -- cgit v1.2.3