This tutorial/book, written by Jonathan Tang is actually cited as an inspiration in the credits page and is a very nice way to get into functional programming.
For a much smaller piece, this technical report contains a two-page compiler for a small Lisp to x86 assembly, from parsing to codegen, written as a series of Parsing Expression Grammar substitutions:
For french speakers, there is a newer edition of that book which has never been translated to english. It is titled "Principes d'implantation de Scheme et Lisp" and is available here:
I still remember when Amazon CA accidentally had this on sale for a pittance, then axed all the orders when people tried to buy it. Really should get a copy at some point.
Yeah they cancelled my order. The price (of a few cents) had been assigned by a software error. Amazon was most apologetic for their inability to ship the item, and compensated me with a $10.00 voucher.
On a related note, I found a copy of Adele Goldberg's 'Smalltalk 80: The Language' in a junk shop for 50 cents. When I checked Amazon, the listed price was over five thousand dollars (due to automated bidding bots from rival booksellers).
I think a few orders actually shipped, but the impression I got was the vast majority got cancelled, and yeah I've only heard wonderful things about the book, I just need to decide to drop the cash on it.
ahem... "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."
Are there any guides like this one for building a logo interpreter? I'd wager it's been around 15 years since I last played with that - but it left me with a lasting impression
To be honest, I just grabbed a PDF of the Apple Logo II manual and blazed away at it, hence the scariness of some of the eval and rendering code...
I got distracted by other things before completing the IO and editing parts but it was a lot of fun.
It's been a while but, from memory, the parts that caused me the most grief were infix operators, unary minus and statements like IF with a variable number of parameters.
I parsed the text into nested lists of Nodes where each node could be a literal or "word" value, a [ ] list or a ( ) grouping. The interpreter treats the nodes as a stream to be consumed one at a time.
When the interpreter is expecting a call to a procedure the next node in the stream should be a word. It can then look up the procedure in a dictionary of built in and user defined procedures. The list of parameters to the procedure indicates how many additional nodes to evaluate when building the values to pass to it.
In the case of variable parameters like a call to SUM you can express it as "SUM 10 20" for the minimum parameters or "(SUM 10 20 30)" for a variable number. The grouping indicates the first element, SUM, is the proc and all the other values are parameters. You could also express it as "10 + 20 + 30" which is evaluated as either "(SUM 10 (SUM 20 30))" or "(SUM (SUM 10 20) 30)" - I can't remember off the top of my head!
The "toy" interpreters that I've found -- Lisp and otherwise -- leak memory. So I'm doing a little bit of research into garbage collection. All in the name of fun and learning.
Thanks for that link! It looks like something that I could comprehend. My C programming skills are pretty limited -- I learned C to move myself one step away from assembly language on microcontrollers.
I've not tried any of these. I'd be interested in someone who's done the lot (Lisp in Small Pieces, the Haskell one, and these two C-created lisps) giving a take on each. Making a lisp or forth seems like a great way to learn [x] thing.
Is this really for someone with no C knowledge, i'd definitely love to learn manual memory management and the such - this might be too much to chew at once.
Nice to see you chiming in. I picked up the 2nd Ed years ago and filled in a few of those "Oh, that's what they meant" gaps that looking at a complete/optimized/bummed implementation didn't explain for me. :)
Please stop using HN comments just to promote links to your site. Users here consider that spam.
HN threads are supposed to be conversations. It's fine to bring up what you're working on if it's naturally related and makes the conversation more interesting. But it's not fine only to do that, or to contrive opportunities for it; that's not conversation, it's commercials.
> If you're looking to learn C, or you've ever wondered how to build your own programming language, this is the book for you. In just a few lines of code, I'll teach you how to use C, and together, we'll start building your very own language.
Agreed on "a few lines", but why should I buy a whole book on this? I'd really appreciate if the OP tried not to hijack hacker feeds for promotion. At least in my book, (s)he is blacklisted for eternity.
You can read the book online. Beyond that, if by hacker feeds you're referring to hacker news, you may notice that the author of the book and the submitter are two different people. Finally, do you really think it's unusual for someone to use hacker news for promotion?
Save the "blacklisted for eternity" melodrama for a worthy cause.
I disagree. The author (she?) has spent what looks like a lot of effort in building a introduction to at least two areas of basic software literacy and, assuming the book is even half way reliable (quick look shows no obvious horrors) then this is a worthwhile addition to the "how to code" which beats most Java-in-10-days books simply for its subject matter.
Add in what seems to be a recurring theme of "don't worry, this is hard, ignore the (male?) arse-hats and just do it, and we have an introduction by and for women - a sorely needed part of the landscape.
So, as I judge this book by its cover, it seems a good and worthwhile addition to the community. Please use Hacker News to promote worthwhile additions (especially as there seems to be a free online copy)
https://github.com/kanaka/mal