
Crafting Interpreters - afshinmeh
http://craftinginterpreters.com/
======
erikpukinskis
This is awesome. I have been writing and re-writing several horrible regex-
based parsers ([https://github.com/erikpukinskis/parse-a-little-
js](https://github.com/erikpukinskis/parse-a-little-js)) to back an IDE I am
building, and I can sense I am well passed the “you need to learn how to do
this properly, Erik) point.

So far this book seems to be just at the right pitch for my purposes.

Does anyone else have any recommendationed reading for someone like me? My
absolute priority is keeping the code simple and having as few features as
possible.

I’ve actually been using my ignorance as a design constraint... I don’t want
to allow complex syntax in the editor, (it’s not a general purpose editor) and
I want the parser source to be approachable.

But perhaps by this point I may have the resolve to resist the power a proper
parser will give me.

~~~
s-shellfish
My interpreters course used this book, as well as 'the little schemer'. They
follow a lot of conventions that I find really useful for software development
(various intricacies of languages in active development tend to follow the
same conventions of diagramming, labeling, notation, etc - all really
important things to keep standard when reasoning about, teaching, and
explaining programming languages!)

[https://www.amazon.com/Essentials-Programming-Languages-
MIT-...](https://www.amazon.com/Essentials-Programming-Languages-MIT-
Press/dp/0262062798)

[https://github.com/mwand/eopl3](https://github.com/mwand/eopl3)

[https://mitpress.mit.edu/books/little-schemer-fourth-
edition](https://mitpress.mit.edu/books/little-schemer-fourth-edition)

There's also this book that from my understanding, a lot of people consider
fairly foundational / useful (own it, haven't read it)

[https://mitpress.mit.edu/sites/default/files/sicp/index.html](https://mitpress.mit.edu/sites/default/files/sicp/index.html)

------
zerr
It would be interesting if authors (of this and similar materials) will
comment how this kind of activity helped them landing new gigs and/or
investments, contacts, etc...

~~~
jxub
It looks like the author made the transition from gamedev to working at Google
on Dart language team, so it seems that his writing and side projects worked
well for him.

~~~
zerr
Seems so, especially in case of Google, where it is impossible to apply to a
specific team/position/project.

Interesting, how initial contact was made... Did the author contact someone
from the Dart team, or did the team/Google contact him in the first place?

~~~
brandmeyer
> where it is impossible to apply to a specific team/position/project.

Impossible is too strong. Unusual, yes, but not impossible. If you pay
attention to their job listings, you will occasionally see openings posted for
specific roles in specific teams.

------
scottious
I love the authors other work, it really helped me when I was getting into
compiler design. I'm very excited to start reading.

------
Silhouette
This is shaping up to be an interesting read if you've ever thought about
designing your own language and wondered what happens next after the basic
stuff that every compiler tutorial covers.

It's also beautifully presented, so compliments to author for that as well.

------
mrcactu5
i think this is cool. i could learn new languages all day. however I've seen
people argue on HN that writing language is a waste of time. why should we
embark on such an exercise?

~~~
steveklabnik
Some people love Yegge, some hate him. This post is... well it's a rant. But
it kinda answers this question in an interesting way [https://steve-
yegge.blogspot.com/2007/06/rich-programmer-foo...](https://steve-
yegge.blogspot.com/2007/06/rich-programmer-food.html)

~~~
jmiserez
I didn’t realize it was from 2007 until I got to this tidbit:

> _By which I mean Machine Learning, since the term "AI" smacks of not just
> determinism, but also a distinct lack of VC funding._

------
jokoon
I've started reading it, until it used the visitor pattern for its parser. It
sort of generates Java code with some hacky way of doing things. It felt
complex for no good reason.

I have nothing against patterns, but it made it harder to follow, so I stopped
reading it.

~~~
antpls
Did you have a previous experience of something easier? May you share about
it?

~~~
criddell
What is the actual problem? Is it multiple dispatch? I think some languages
(Lisp may be one) handle it natively.

Visitor is the only way I know of dealing with it in C++. Once you do it
enough, Visitor starts to feel like a pretty natural way to extend a class
without modifying the class.

~~~
jcelerier
> Visitor is the only way I know of dealing with it in C++. Once you do it
> enough, Visitor starts to feel like a pretty natural way to extend a class
> without modifying the class.

Are you talking about traditonal OOP visitor pattern ? It's pretty terrible,
when compared to std::variant ; imagine for instance that you want to have a
way to draw the rect that contains a given shape without changing your shape
class: [https://godbolt.org/g/34KyMw](https://godbolt.org/g/34KyMw)

~~~
criddell
If your interface is that consistent, why not just make the bounding box
drawing function a template?

Visitor is nice when some kind of transformation needs to be applied to the
visited objects.

------
_raul
Notice that while the linked page says "You can read the whole book, for free,
online", chapters 18 to 30 haven't been written yet (e.g:
[http://craftinginterpreters.com/types-of-
values.html](http://craftinginterpreters.com/types-of-values.html)).

~~~
SiempreViernes
Slightly below the button marked "start reading" there is a section entitled
"What’s the Catch?" that explains as much.

~~~
giancarlostoro
I was about to write that very comment. It's not like he's hiding it, and he's
giving the (e)book out for free, what more could you ask?

------
vectorEQ
i love these kinds of articles, but i dont understand why put the first 2
lines in it, which kind of contradict eachother.

" A handbook for making programming languages.

This book contains everything you need to implement a full-featured, efficient
scripting language."

The title makes it look like you would write a compiler /assembler or some
plugin for existing one. and then the first scentence dives down to the actual
content.

This is obvious from the title here. it just bugs me these kind of words
(programming language vs scripting language) are used like that.

Other than that, always interested to read about both topics :D

~~~
emsy
If you write a C interpreter, is it not a programming language anymore? Also,
the fundamental concepts of a scripting language (lexing, parsing,
compilation, but to bytecode) apply to compiled programming languages as well.
There is no actual contradiction.

