Hack Your Own Lisp Language Using… Well… Anything

Lisp is one of those interesting computer languages that you either love or hate. But it has certainly stood the test of time. Of all the ancient languages that are still in practical use, only FORTRAN is older, and only by one year. If you ever wanted to learn Lisp, [Kanaka] has an interesting approach: Study how to build your own Lisp in your favorite language.

What if your favorite language is something obscure? [Kanaka’s] GitHub page has no fewer than 64 different implementations of Mal (Make a Lisp), each in a different language. Unsurprisingly, C and Python are on the list. However, so is Forth and Go and Awk. Not strange enough for you? How about Make? Yes, Make, like you use to build programs. Bash, Postscript, and even VHDL have entries, although–surprisingly–no Verilog; we don’t know why.

Each implementation of Mal is separated into eleven incremental, self-contained, and testable steps that demonstrate core concepts of Lisp. The last step can actually run a copy of itself–typical for a mind-bending language like Lisp. There is a guide to help you navigate through the process in the language of your choice. The suggestion is to not look at the code in the repository until after you’ve written it yourself. You can see [Kanaka] (also known as [Joel Martin]) giving a recent talk about the Mal process in the videos below.

If you haven’t used Lisp, you might think it stands for “lots of irritating spurious parenthesis” instead of “list processing.” If you use emacs, you’ve been using Lisp for a long time. Supposedly at least some incarnation of Reddit, Orbitz, and Yahoo Store all used Lisp. We’ve even seen Lisp on microcontrollers and Raspberry Pi operating systems.

Although learning Lisp by building is a lofty goal, we couldn’t help but think that this repository might be useful for people who just want to compare programming languages. We also couldn’t help but think of JONESFORTH, which has taught a lot of people Forth by building a Forth interpreter.

22 thoughts on “Hack Your Own Lisp Language Using… Well… Anything

  1. Well done. Writing a language should be an early educational task whatever that language is – even a custom language.

    It’s dead simple to do with any host language but you may not get the performance you want unless you choose an efficient host language. I wrote a my first language in the late 70’s using machine code. More recently I wrote a pseudo language that was very DOM/JavaScript like using Lua as the host. I say *pseudo* as I didn’t polish it enough to be a language and used it as an application framework instead. Lua is a very good platform for this!

    Quote: “and even VHDL have entries, although–surprisingly–no Verilog; we don’t know why”

    Verilog is a Merician thing. Most of your company owned IP is written in Verilog so staff over there are often required to work with VHDL and Verilog. The VHDL for new work that may integrate IP written in Verilog.

    The rest of the world is mostly VHDL *only*. Verilog can be ambiguous where as VHDL is all ways conclusively specific. That is why you guys are now switching from Verilog to System Verilog.

    I chose VHDL as it looks different to a programming language and that to me should be the case. Verilog looks *too much* like a programming language and promotes mistakes.

  2. “If you haven’t used Lisp, you might think it stands for “lots of irritating spurious parenthesis” instead of “list processing.””

    Get yourself some pedals. One for left, one for right. LISP is good for doing DSLs.

  3. I avoided LISP all these years, then decided to learn Haskell (or try to anyway) to make up for my lack of experience with functional languages. Bootstrapping lisp could be a lot of fun. Do it in assembly on your favorite processor!! What about the Xtensa in the ESP8266? I seem to remember someone has already done LISP on the ESP8266, but that doesn’t prevent you from “blindfolding yourself” and doing it again yourself your own way. It would build character … or something.

    Fooling with Haskell was certainly a lot of fun. Something I should get back to. There was something called Project Euler that had a bunch of mathematical riddles that served as Haskell challenges.

    I need to take a look at LISP written using Make. Apparently Make is Turing complete (Gnu make anyway, which is pretty much all anyone uses these days). The claim is that once you have lambda, it is all downhill.

    1. I did that exact BASIC before I did machine code.

      That was a blast from the past to see an ad for NewDOS which I used as well. It was much better than TRSDOS.

      NewDOS had basic extensions like RENUM to renumber lines. When you had a line 10 and a line eleven you couldn’t make a line 10.5 lol.

      BASIC was a fun learning language but it gives you so many bad habits to get over.

    1. Lenny Susskind’s “theoretical minimum” type lectures have even worse stats. But are well worth watching.

      Few hundred hours to really be in a position to understand much of physics (along the path to string theory).

      You wont be writing any papers at the end of it, but you will definitely be able to appreciate them more.

      You’ll also *really* understand what is meant by “hologram”, and all the junk you hear about blackholes.

  4. Good article.

    Clojure got me into Lisp despite being an emacs user for a long time I had little interest.

    Clojure is a Lisp, functionally orientated and can use the JVM (I am not a java programmer but tthe interop is very useful), JS and .net (I think .net one of those windows run times).

    Good fun.

  5. POP-2 got me into LISP. When I was at Southampton in 1974 for my Electronics degree, they gave us poor students fifteen seconds of CPU time per week on the local ICL 1900 mainframe. I very, very quickly got bored using BASIC, since the interpreter used up fifteen seconds of CPU time in very short order. So, I went to the Ops centre in the Maths building to find out more, and they told me about POP-2 (from the Department of Machine Intelligence and Perception at Edinburgh) – much more exciting than BASIC, and then I found the Algol compiler. Fifteen seconds of Algol time in a week meant I could write programs that produced some significant results. (Partly because as long as the program got through the first pass compile inside the fifteen, it would run pretty much to completion without being kicked).

    (When they gave me some more time later in the course, I re-discovered POP-2 (and LISP)).

    Sorry, couldn’t resist!

  6. Would be interesting to see any current projects/products using LISP. I’ve always been interested in comparing / contrasting different languages with the idea of using the right tool for the job instead of just using one language (C for example) as just using one tool for all jobs. Sort of like comparing having 6 different types of pliers in your toolbag vs using a leatherman multi tool.

  7. Did that 30+ years ago. Was using the Xerox LISP workstation. Love the ability to change program behavior dynamically during execution. Need the speed of C. So I made a LISP interpreter with C so that I can get mix and get the best of both.

  8. I wrote a Lisp interpreter for Raspberry Pi in ARM assembly. I call it Arpilisp. Like Jonesforth, it’s all in a single, commented assembly file, ready to build, use, extend, and hack.

    Arpilisp implements Lisp from scratch, with no help from any libraries and minimal help from the kernel. It would be pretty easy to adapt it to bare metal.

Leave a Reply to EugeneCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.