I am currently working on Scheme R5RS implementation in Java. It is a hobby project, but I'm really enjoying it. It is somewhat enlightening. Look forward to reading the Optimization chapter: I couldn't find much useful and practical info on that. I think it is quite easy to implement your interpreter, but it is really difficult (at least for me) to make it fast. Can anyone recommend any articles or books with common optimization tricks and techniques?
For making an efficient Scheme implementation: most everything written by R. Kent Dybvig or his students. I'd start with his PHd thesis (Three Implementation Models for Scheme, specifically the stack-based part).
http://www.cs.indiana.edu/~dyb/ (See also Lua's upvalues for a way to optimize closure variable access that's a bit simpler than his display closures).
> Thank you so much for the book, please, continue!
I will! > Look forward to reading the Optimization chapter: I couldn't find much useful and practical info on that. There's not too much depth in that particular chapter. The whole second part is really about implementing an interpreter (fairly) efficiently in C. As you probably know, you have to think about performance at every level—your object model, bytecode format, hash table implementation, etc. If you'd like a sneak peek, the code for the entire book is actually done already (!). You can see which snippets go into each chapter cloning the repo[1] then running:
make chapters
make c_chapters
make diffs
Then take a look in build/diffs.
There are a ton of optimization tricks that are specific to Scheme and Lisps and a lot of literature behind them. Macros and eval make it a lot harder. It's pretty dense, but I liked "Lisp in Small Pieces" a lot. [1]: https://github.com/munificent/craftinginterpreters
Interesting! I like racket...just wish it was faster. Anybody know if there will be a successor to "Realm of Racket"?
Edit:
Now I remember it uses LGPL as the license. I understand the reasoning, but I've always viewed the freedoms as giving the user freedom over the implementer...kind of just trading power.
I clicked the link without looking at the poster, and by the end of the "What’s the Catch?" paragraph I was thinking to myself that this really seems like something written by The Munificent Bob. Then I read the first sentence of the next paragraph :)
I really like your blog, I have read all of it, some posts even 2-3 times, and not only because of the content, but your writing style. I will probably read this book too ;) Also, I think Magpie is awesome.
One think I find lacking in books about building languages is a focus on tool. I am working on one (available for 0$ on leanpub: "How to create pragmatic, lightweight languages" https://leanpub.com/create_languages
) with the intention to focus more on building editors and simulator.
If you are interested in the subject you could take a look to my blog (https://tomassetti.me) I write 1-2 posts per week on building languages. Most of the time I talk about DSL.
Comments (75) 20 threads
Earlier commentsI am currently working on Scheme R5RS implementation in Java. It is a hobby project, but I'm really enjoying it. It is somewhat enlightening.
Look forward to reading the Optimization chapter: I couldn't find much useful and practical info on that. I think it is quite easy to implement your interpreter, but it is really difficult (at least for me) to make it fast.
Can anyone recommend any articles or books with common optimization tricks and techniques?
http://www.cs.indiana.edu/~dyb/
(See also Lua's upvalues for a way to optimize closure variable access that's a bit simpler than his display closures).
Yes! In fact, that's how the C version of the interpreter in my book implements closures. It's pretty brilliant. <3 those Lua folks.
Or perhaps do you have a link about how it works?
Continue this thread — 1 reply
I will!
Then take a look in build/diffs.> Look forward to reading the Optimization chapter: I couldn't find much useful and practical info on that.
There's not too much depth in that particular chapter. The whole second part is really about implementing an interpreter (fairly) efficiently in C. As you probably know, you have to think about performance at every level—your object model, bytecode format, hash table implementation, etc.
If you'd like a sneak peek, the code for the entire book is actually done already (!). You can see which snippets go into each chapter cloning the repo[1] then running:
There are a ton of optimization tricks that are specific to Scheme and Lisps and a lot of literature behind them. Macros and eval make it a lot harder. It's pretty dense, but I liked "Lisp in Small Pieces" a lot.
[1]: https://github.com/munificent/craftinginterpreters
Scheme/lisp based languages and Haskell are a great choice for this kind of project.
Edit: Now I remember it uses LGPL as the license. I understand the reasoning, but I've always viewed the freedoms as giving the user freedom over the implementer...kind of just trading power.
I really like your blog, I have read all of it, some posts even 2-3 times, and not only because of the content, but your writing style. I will probably read this book too ;)
Also, I think Magpie is awesome.
If you are interested in the subject you could take a look to my blog (https://tomassetti.me) I write 1-2 posts per week on building languages. Most of the time I talk about DSL.
All comments shown.
Couldn't load more comments. Check your connection and try again.