

Ask HN: What is a good language to learn/use for writing compilers/interpreters? - sea6ear

I would really like to learn how to write compilers/interpreters in depth.<p>What are the best languages to concentrate on to write compilers or interpreters in?<p>Do the basic concepts transfer easily from one base language to another? That is, how much difference conceptually is there going to be between say writing a compiler/interpreter in C or Java vs Haskell, OCaml or Lisp (for example).
======
tomh-
I say Haskell, the way you can build abstract syntax tree's as data types and
do pattern matching on them is a very natural way to write a compiler, it is
almost a one-to-one match with a language definition.

~~~
hga
Scheme has traditionally been a if not the major language for doing this, but
it was established in this niche well before Haskell got big (Scheme had a
decade and half head start on Haskell, three decades if you want to go back to
the invention of LISP).

On the other hand there's a tradition of dogfooding in this area, one argument
being that if your (general purpose, let's assume) language isn't good for
building a compiler, what use is it? If you believe in your language....

------
starkfist
ML. Because the best compiler book these days uses ML.

If you are going to sell your compiler to you will have to write it in C++.

