Hacker News new | past | comments | ask | show | jobs | submit login
Building a Programming Language Pt. 3 – Interpreting (drew.ltd)
129 points by drew-y 77 days ago | hide | past | web | favorite | 10 comments



Where were all these compiler/interpreter tutorials 20 years ago? All I had was Jack Crenshaw's guide and The Dragon Book!

Happy to see all these materials with different perspectives.


I feel like a few things are going on.

1) LLVM has made it easier to build JITed or even compiled languages than ever before, that will run on multiple platforms while having decent performance.

2) Languages like Rust have come along (tying back to point 1) showing that there can be more to languages than the C/C++s and the Javas etc of the world (yes I know we've had stuff like Haskell and Lisp for a long time but they've never broken into the mainstream, despite how much I wish this was otherwise).

3) Various projects like Crafting Interpreters, Jon Blow's work on Jai, plus other smaller languages like Zig have made people better understand "this isn't as crazy hard as I thought".

I sort of hope we see a proliferation of new and interesting languages that explore idea spaces the way Rust is exploring memory safety (including the hope someone explores gradual safety the way we've started to see gradual typing).


I remember SICP has a whole chapter where you build and play with an abstract syntax evaluator. One of the exercises even asks the reader to implement lisp macros. I'm currently porting it to java as a joke for my comp/sci professor.


At the library! E.g. http://datarama.dk/Anatomy%20of%20Lisp.html from the 1970s. You had to keep looking and be open to works not in C, but they were out there.


The JVMS was around 20 years ago, and had a lot of great hints. And then there was the smalltalk 80 book which talked about how it’s interpreter was implemented. Actually, I’m kind of depressed we haven’t advanced very much from methods in use 40 years ago.


Which methods specifically do you feel leave a lot of room for improvement?


Can anyone recommend a resource that will teach me how to write a compiler for a statically typed compiled language? Pretty much every tutorial and resource focuses on dynamic interpreted languages. I want to learn how to implement a type system inside a compiler.


For the type system aspects, there are two steps:

1. Learn the theory. Yes, you need to. On this matter, the book "Types and Programming Languages" (or TAPL for short) is the bible: https://www.cis.upenn.edu/~bcpierce/tapl/

2. Implement toy type systems. There are several resources for this, but personally, I like this one: http://plzoo.andrej.com/


Thank you for the links brother


Implementing a programming language was one of the most rewarding things I did at university. The knowledge gained around coding a recursive descent parser actually proved useful in my professional life. As did the lessons in patience from deciphering the professors reference implementation.




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

Search: