News for hackers. Stuff that matters.
Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by ilyak on Saturday September 19, 2009 @03:44PM (#832263)
I'd like it to be a stand-alone article. This way it would be a first-class citizen on HN.

I mean, more meat, examples, and soon quite a few more people know how to prototype a language in SML.

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by silentbicycle on Saturday September 19, 2009 @08:36PM (#832523)
Andrew Appel's _Modern Compiler Implementation in ML_ is probably what you want. (http://www.amazon.com/Modern-Compiler-Implementation-Andrew-...)

While it uses SML, it's not hard to follow if you use OCaml, and the bibliography / references are also quite helpful. The Ghuloum paper referenced elsewhere in the thread is also quite good (and uses Scheme, for better or worse).

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by ilyak on Sunday September 20, 2009 @04:16PM (#833485)
It's a damn book, not a quick article.

Sad.

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by silentbicycle on Sunday September 20, 2009 @04:33PM (#833503)
Compilers are a big topic. Any "quick article" of substance will have references to underlying tools and concepts the author will expect you to know.

If you're completely lost, try starting with interpreters first. Compilers build on many of the same ideas, but interpreters are generally simpler. Read "The Art of the Interpreter" and/or SICP, and do the exercises. The former is a short paper, the latter is an excellent book expanding on it.

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by RiderOfGiraffes on Monday September 21, 2009 @06:19AM (#834304)
I've written compilers, and even though I no longer have any reason to do so, I'd love to know more about writing better compilers in better languages.

There are dozens and dozens, if not hundreds of articles and "how to" style pages on the web showing a concrete implementation of a small compiler for a toy language using lex/flex and yacc/bison, yet when asked for something similar in ML, SML, Haskell, whatever, the response is to be pointed at books and scholarly articles.

Where are the popular accounts of better compiler building with ML? Are there any? If not, why not?

Yes, building an industrial-strength compiler for a real-world langauge is a big and complex undertaking, but I feel the field would advance more quickly if more hackers had more access to more articles of the "Build a compiler in an afternoon" variety.

And I'd appreciate learning from it too, despite, or perhaps because of, my existing knowledge.

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by silentbicycle on Monday September 21, 2009 @08:06AM (#834416)
Part of it is that the culture surrounding ML is quite academic. Most of what I've found has been written for journals or books (the Appel compilers book above, _Purely Functional Data Structures_ by Okasaki, etc.), not blogs. Also, the ML community is rather small, though FWIW I'm only really familiar with the OCaml side of it.

Here's[1] a post about an OCaml / LLVM article by Jon Harrop, but it's just an intro for an article in his (pay) OCaml Journal.

   [1]: http://ocamlnews.blogspot.com/2008/09/writing-bytecode-compiler-using-llvm.html
Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by RiderOfGiraffes on Monday September 21, 2009 @03:22PM (#835302)
And there, to some extent, is the point. People will continue to write "popular press" articles about builing compilers using flex and bison, possibly targetting C as an intermediate language, until the ML community (or equivalent) becomes less clannish.

I'd love to see how clever they are, applaud them for it, and build on their work. They don't seem to care.

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by silentbicycle on Monday September 21, 2009 @05:10PM (#835599)
Indeed. I think the ML languages have a lot of ideas that should see more widespread use, but the community (with exceptions, naturally) seems to be more motivated by reputation within academia than on blogs and other open discussions. That's their prerogative, I guess, but it does mean that little activity around ML is visible outside certain circles.

I'm curious about writing interpreters / compilers in Prolog (another language that seems particularly suited to prototyping them), as well, but I've already got plenty of projects.

Re:Writing Your Own Toy Compiler Using Flex, Bison and LLVM by ilyak on Monday September 21, 2009 @05:31AM (#834268)
Please no books and no research papers.

Just a short article showing how to get things done.

Exactly as one we're discussing.