Hacker News new | past | comments | ask | show | jobs | submit login
A Simple Scheme Compiler (1997) (utexas.edu)
91 points by azhenley on Aug 24, 2020 | hide | past | favorite | 17 comments

Ghuloum's scheme compiler tutorial essentially follows a useful process: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf. It starts with emitting x86 machine code for constants, then unary and binary primitives, local variables, conditionals, heap allocation, procedure calls, and finally closures. It helps that Scheme has little to no parser to speak of, but it is straightforward to extend the technique to a language that does.

The book this is from (follow the contents link) is dated 1997, which I find very disappointing. I think it is part of Paul Wilson's garbage collection archive. It was apparently intended to go from an introduction to Scheme all the way to implementation details. Unfortunately, it was never finished.

You might like "Lisp In Small Pieces", which starts from a simple Lisp-1 interpreter to a Lisp-2 to C transport.

With a bytecode compiler, multiple implementation approaches, and a couple of macrosystems dissected along the line. Though, LiSP is geared a bit more towards Scheme semantics rather than pragmatics. There are some details like closures, and dynamic binding, and call/cc, but you won't find truly gnarly details on garbage collection, value representation, threads, etc. Nevertheless, it's still an amazing book which I would recommend reading!

Fair enough. I heard that John Anatomy of Lisp might have more details. Do you know books talking about the topics you mentionned ?

I would like to know as well. I would also be interested in opinions about "Lisp system implementation by Nils M Holm". I tried to read "Lisp in small pieces" at least 3 times but never managed to go further than the 1st chapter. I find the prose pedantic and often it doesn't go straight to the point that is the objective of the chapter. Maybe this is an issue due to the translation from French. In any case I find it a very heavy read. I have the feeling that the contents of the book could be easily condensed in half the pages.

I've also attempted it several times. If I were not so burnt out on programming at the moment (WFH is not a vacation, and I desperately need one) I'd probably have made it through this last time. Maybe, like all those SICP study groups, someone should make a LiSP study group to help keep people engaged and moving.

what part are you stuck on ?

Actually, I was making good headway with this last attempt. I just burned out on programming (generally), not specific to the text. And since I don't want to program right now, there's no point in trying to progress through the book. An earlier attempt failed entirely because of that (reading and not doing), other times I stalled out because I just didn't understand it.

Generally I've found more advanced material requires a lot of "steeping" in my mind before it clicks. I was literally in my 4th year of college before Calculus finally actually clicked in my brain, this book seems to have the same issue. My first couple times I just didn't understand what I was reading, and I put it down (for many years actually, time flies). When I picked it up this time I honestly don't know what my issue was with comprehending it before. In the intervening years I did a much deeper dive into using Common Lisp as my hobby language, and I think that's helped a lot. What I'm reading connects better with the practice I've had in using a Lisp. Similar to calculus, I had spent a couple years applying it (not just studying it) and when I went back and reexamined some basic materials everything just fell into place in my mind.

Same here. Time did half the work. Revisiting the book every year or so made me click.

IMO the point of the prose is to explain each concept so thoroughly that the concept and implementation go from "this is beyond me" to "of course it works this way, it's obvious" for each and every chapter. It could maybe be shortened, then maybe not everyone could have that experience.

I have also bounced off of LiSP a couple times

I found the style a bit difficult too.

Missing a last name: "Anatomy of Lisp by John Allen".

It is excellent and easy-to-follow … right up until the denotational semantics piece, which I found very difficult to understand. Maybe someday!

I can't find any author information in the linked doc but it reminds me of the work Donovan Kolbly was doing about that time on RScheme. I think RScheme was initially intended to be a teachable implementation and I seem to recall a book project that went along with it (I was a grad student then and there, and was an RScheme user, but wasn't closely involved with Wilson's group).

Now that you mention it, RScheme sounds right.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact