Ask HN: What are the best books on creating a programming language? - sdegutis
======
e19293001
Compiler Construction Using Java, JavaCC, and Yacc, IEEE/Wiley, 2012

This book taught me how to create compilers. The author started from simple
principles in grammars then slowly introducing a very simple compiler
eventually adding more features to the compiler. I was able to adapt his
method in developing a compiler. In later chapters, the book does a great job
in presenting an application of what was learned from the previous chapters by
implementing grep using automata theory.

------
steve_g
Programming Language Pragmatics by Michael Scott

[http://www.amazon.com/Programming-Language-Pragmatics-
Third-...](http://www.amazon.com/Programming-Language-Pragmatics-Third-
Edition/dp/0123745144)

I haven't read a lot of language books, but this one has good information on
the various design choices one might make when building a language. Like the
others listed in the comments, it's more implementation-focused than semantic
design-focused.

~~~
sdegutis
Huh. This is the only book recommended so far that only has good Amazon
reviews. I think it may be a winner. But honestly it's so hard to judge a book
by its cover, or even by Amazon reviews (even though some of them _seem_ to
make really good points).

------
woolybully
Well, there's designing a pl and there's implementing a pl, and many other
subquestions as well. For implementation, yes, the Dragon book is fundamental,
but also look at other points of view, such as packrat parsing, or non-textual
syntax. For design, wow, hmm, does the world need another programming
language? If you're thinking of an OO language, look at the design space of OO
languages, for example, is inheritance class-based or prototype-based. if
you're looking outside OO languages, look at the crazy menagerie of languages
that have been created so far: APL, Plankalkul, Toontalk.

------
Ace17
For the actual implementation of a compiler (not design of the language
itself), I'd recommend "Modern Compiler Design" by Dick Grune. A lot more
practical and readable than the Dragon Book.

About the language design itself, you might want to have a look to:
[http://www.drdobbs.com/architecture-and-design/so-you-
want-t...](http://www.drdobbs.com/architecture-and-design/so-you-want-to-
write-your-own-language/240165488) These are very interesting guidelines from
Walter Bright, the man behind the D programming language.

~~~
sdegutis
The Amazon reviews on Modern Compiler Design aren't very favorable towards it.
Same for the Dragon books (all editions). I'm not sure what to make of this.

------
rjbwork
This will get you started on the compilers side of things.

[http://www.amazon.com/Compilers-Principles-Techniques-
Tools-...](http://www.amazon.com/Compilers-Principles-Techniques-
Tools-2nd/dp/0321486811)

You can also use [http://lmgtfy.com/?q=sicp](http://lmgtfy.com/?q=sicp) for a
deeper understanding of interpreted languages and language structure.

~~~
sdegutis
The dragon book is mentioned often, but usually only as "this book covers
these things," which isn't really a recommendation, only a comment. Is the
book actually good? Can you recommend it?

~~~
wbsun
Yes, it is a great book. Trust me. If you are scared by the lexing and parsing
algorithms, skip them because it is highly unlikely you will write them on
your own. You don't need to refer to other sources to implement your own
language with it.

------
sova
Learn Lisp. Or the more modern equivalent: Clojure. I think learning a LISP-
like language will make programming at its core that much more clear, and the
potential for a DSL (domain specific [programming] language) that much more
relevant.

~~~
sdegutis
Thanks for the tip. I've been doing Clojure full time for about 4 years now,
so I think I've got a good head-start. Now I'm looking for something that will
help me understand stacks in virtual machines and how to generate bytecode for
them from an AST, that kind of thing.

~~~
e19293001
The book that I've recommend will also help you understand what you mentioned.
I had a great time going through the book, enjoyed a lot and learned a lot.
Really.

------
sparkie
The implementation of functional programming languages by Peyton-Jones.

Engineering a compiler by Cooper and Torczon.

