A bit of meta-programming with scheme for prosperity&happiness

A bit of meta-programming with scheme, or: write yourself a LISP (and probably some other languages too), for prosperity and happiness.

As a continuation (!) of scheme workshop for prosperity happiness, this time we could see some variants of The Maxwell Equations Of Computer Science, i.e. LISP [meta-circular] interpreter.
Implementing a toy programming language is what every programmer should do at least once in her/his life. And it can be quite handy too — embedding small script language in some c/Java/PHP project sometimes can reduce compile-deploy-test cycles; besides, just check out https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule (yeah, common lisp… but you know, scheme was not that popular outside academia in the early 90s ;)).

As a side effect (!) you should also gain/strengthen your insights about referential transparency, dynamic vs static scoping, side effects, closures… [mostly functional] programming in general.

If you’re interested of course!

Cheers,
d.

PS notes from first workshop, introducing to scheme: https://github.com/drcz/scheme-workshop-for-prosperity-and-happiness/blob/master/scheme-1.scm

——————————————————-

PS2 How to prepare to the workshop?
You (yes, you!) are a hacker, a craftsman, an artist, a scientist, a curious and free being. You know what’s best for you, I can’t tell you (and besides, nothing is true and everything is permitted).

It’s better if you are familiar with LISP (just a little). You can check out the notes from previous workshop (the github link above — up to the line number 218 is enough). If you’ve got some time and will, try reading the original McCarthy’s paper [1] you’d like to read some more try (Part One of) this brilliant paper [2]. 

If you don’t have time or will, don’t read 🙂 you can always go back to these papers after the workshop. And billions of people throughout the history didn’t read them at all — no big deal! I’m going to start with just a fast overview of LISP; during the workshop you’ll probably get it better.

If you want to just come and take a look, there’s no need to take laptop — maybe you’ll change your mind and pair someone. Working in small groups is cool, I hope we will form some. Working alone is also cool, as well as not working at all.

As of setup, I am going to use scheme, in particular GNU’s guile-2.0, with emacs and geiser as my environment. I’m going to use Alex Shinn’s matcher (the (ice-9 match) module in guile); it should work with gambit-c as well. If you’re a debian person, you can apt-get install guile-2.0 and you’re there.

If you’re using chez scheme, Kent Dybvid’s matcher is a bit different, but it should do (I only used it once but should be able to help you). If you’re using some other lisp, in the worst case you’ll have to write some more code to do without a matcher (I’ll tell you how). 

You can pick any other language as long as you feel comfortable with it. elisp, common lisp, picolisp, shen, clojure all should do very well; js and R might do; mathematica, python and ruby will be harder, but should do. I believe Antonio and Joaquin will help with strongly typed functional languages (at least Scala and Elm and probably haskell). In general, it’s good if your language supports lists, and it should handle recursive function calls (eg older versions of php had a rather small callstack by default). Garbage collection is cool.

If you’d like to use C or Java, it’s going to be a lot of work and you will almost surely run out of time — but it does not mean “no”.

If you fail to prepare some setup, and it’s not a big deal, I may help you before we begin.

Remember we’re about good and prosperity. And enlightenment. And fun. Failing is learning, giving up is a sign of sanity.

As a last word, if you will be interested, we can do this again, or go on with other topics — I’d love to do some compilers and/or partial evaluation with you!

[1] http://www-formal.stanford.edu/jmc/recursive/recursive.html

[2] http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AIM-453.pdf