5 ms·
Want to Write a Compiler? Just Read These Two Papers
- DaniFong 18y agoAlternatively, you can learn macros, as PG might suggest. Fundamentally, compilers just translate one string of symbols into another. The ones we're familiar with just translate a high level language into assembly. But there are others -- every object relational model system has a defacto compiler.
- aston 18y agoIf you take a look at that nanopass paper, it's very much in the "just use macros" school of thought. It's even in Scheme. For the tldr crowd, http://www.cs.indiana.edu/~dyb/pubs/nano-jfp.pdf http://www.cs.indiana.edu/~dyb/pubs/nano-jfp.pdf.
- hsmyers 18y agoNot a new idea-- Griswold wrote Snobol as a set of 360 macros.
- aston 18y agoIn the world of programming languages, nothing's new; all of the good stuff was thought of by 1970. That's basically the extent of what I learned in college.
- DaniFong 18y agoI don't think that's 100% true. There are some good new ideas emerging due to new machine models: Erlang for example, which is like the machine language of concurrency. And Haskell wasn't really anticipated by the 70's, nor is much of Fortress -- especially the methods they're using for parallelism.
- cstejerean 18y agoErlang isn't exactly new. Development started over 20 years ago and it has been open source for 10 years. http://www.erlang.org/course/history.html http://www.erlang.org/course/history.html
- DaniFong 18y agoSure, but that's around 20 years after the 70's, and the usefulness of the ideas wasn't well known until some time after that.
- david927 18y agoAll the paradigms were discovered by the 70's, and a language is only really the View/Controller for the paradigm. At least that's true as far as what's currently published.
- KirinDave 18y agoThis is absolutely not true. A lot of great work has been done in the past decade on interpreters and speeding them up. Modern interpreters are just compilers where you use the code immediately (most are direct threaded byte-code interpreters), so all that work counts. It is strange that modern software engineering en masse took such a huge step backwards in the C++ era of the late 80's and early 90's, with tools falling back to primitive levels and languages becoming much less forgiving. It's only now that we're finally returning to the state of the art from 20 years ago. Of course, some people bucked the trend and used these somewhat neglected technologies despite a lack of public popularity. Paul Graham is one of them, and he ended up doing pretty well for himself. :)
- harshavr 18y agosome exceptions i can think of : clos and the meta object protocol - the idea of leaving the language open for the user to change by using a metaclass hygienic macros first class continuations monads functional reactive programming the first few developed in the 80's while the last is quite recent
- DaniFong 18y agoThat's an excellent paper, thank you. One of the advantages of realizing that compilers are 'nothing special' is that you can start to use them all the time to simplify your work. It lets you think at a higher level.
- DaniFong 18y agoThis should be a little lesson on the dangers of skimming over dense prose, and the power of recommendations on YC. I completely skipped past the nanopass paper, even though it's an approach I condone, and skimming a behavior I frown upon.
- mojuba 18y agoWith that approach you won't be able to write a compiler for anything other than a (suboptimal) Lisp derivative, which itself is just a small part of computing world. Take a look at the GNU Compiler Collection and see how far it is to write a working optimizing compiler from the Lisp macro paradigm.
- narag 18y agoAnd even if writing a more complete compiler wasn't difficult enough, there's more much to it. There are complex details like exception handling (stack unwinding, signals...), graphical debuggers, interface with GUI libraries, threads, etc. The fact that only commercial (and expensive) Lisp implementations have all these features is a hint that they're not trivial.
- mojuba 18y agoAnd in fact what we all need is a good, commercial grade open-source Lisp compiler + tools.
- KirinDave 18y agoI'm sorry, but I strongly disagree. Lisp's problems are not technical, they're social. We have a commercial-grade open-source lisp compiler. It's SBCL. And we have really excellent models for tools. If someone would extract SLIME from emacs and into an editor with less history behind it and more popular appeal, you'd have most of the tools you need. Lisp is suffering because its community is fragmented and it has no leaders. Name a popular language that doesn't have an iconic corporation or person behind it, rallying and focusing the community? That condition is actually quite rare.
- mojuba 18y agoSBCL: is it as good as Allegro? I haven't seen an IDE as beautiful and comfortable to work with as Allegro (although I'm barely a Lisp hacker, just a fan).
- hsmyers 18y agoSo did he spell Knuth wrong as a typo or through ignorance? Or is this some subtle insult? Doesn't seem to thing Perl qualifies as useful either...Oh well, one less opinion to worry about.
- gaius 18y agoIt was a joke, a mistake that a newbie intimidated by huge textbooks might make.