views:

285

answers:

7

When it comes to learning about C compilers LCC seems like the compiler of choice for many. Also, there is another StackOverflow article here on learning compilers in general. However, I've previously studied C compilers and am looking for something a bit deeper in terms of programming paradigms.

To be clear, what I am looking for are compiler projects which clearly demonstrate non-C programming paradigms. Documentation and books are also great. Even esoteric languages are fine, as long as they are reasonably well documented. Anything with different scoping rules or concepts like immutability would be ideal.

Thanks!

+6  A: 

Lisp In Small Pieces, Design Concepts in Programming Languages and Structure and Interpretation of Computer Programs spring to mind.

Luís Oliveira
Thanks for the book links. I did SICP when getting while doing my compsci undergrand and implemented much of Scheme in Scheme. I was really hoping for an actual compiler I could mess with.
Rick Minerich
+10  A: 

It's hard to find good stuff that's not C. A lot of it is old and out of print. But here are some recommendations for things I think are good:

  • Andrew Appel's Compiling with Continuations is really excellent but is expensive. Try to get it through interlibrary loan.

  • P.J. Brown's book Interactive Compilers and Intepreters is also out of print but offers an excellent and different perspective.

  • Simon Peyton Jones's book Implementing Functional Languages is out of print, but you can read it free online. It's quite good. There's also a tutorial book by Simon Peyton Jones and David Lester, which in my opinion is not as good.

  • There's a very old book by Bill Wulf, The Design of an Optimizing Compiler. That book is about a compiler for Bliss, which like C is (was) a systems programming language, so it may not provide that different perspective you're looking for. This is a good book and was very influential in its day, but probably most of the information there is in basic textbooks now.

  • There's Craig Chambers's doctoral dissertation, which was about a compiler to Self, a very interesting pure object-oriented language related to Smalltalk. (Disclaimer: I have not read Craig's disssertation, but I have read lots of his other work, and it is all excellent.)

Norman Ramsey
+1 for Chamber's Thesis. In fact, all of the Self papers are quite readable, especially the type feedback and type inference papers, which are head and shoulders above the other papers in the field.
Sean McMillan
+4  A: 
  • MacLachlan 1992: The Python compiler for CMU Common Lisp -- a high-level overview of the sophisticated Python compiler (used in CMUCL and SBCL).

  • Ghuloum 2006: An Incremental Approach To Compiler Construction http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf -- roll your own Lisp with GCC runtime. Really cool.

skypher
A: 

Paul Snively pointed these out to me on Twitter (@psnively):

Rick Minerich
+1  A: 

Here are my suggestions, in the order they should be read:

  1. Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Jay Sussman.
  2. Programming Languages: Application and Interpretation by Shriram Krishnamurthi.
  3. Lisp in Small Pieces by Christian Queinnec.
  4. Essentials of Programming Languages by Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes.
  5. Implementing functional languages by Simon Peyton Jones.
  6. The Implementation of Functional Programming Languages by Simon Peyton Jones.

I feel that items 1, 3, 5 and 6 deserve carefully study. Sorry that I cannot provide the links, as I am new user. May Google help you!

Vijay Mathew
+1  A: 

To complement the list of books I provided, watch the SICP lectures.

Vijay Mathew
A: 

Rather than drill deeper into the depths of compiler minutiae, have you considered programming in a higher level modeling language? I know Ivar Jacobson, one of the original contributors to the UML, has done a lot of work in this area and his company sells these kinds of tools. The last time I saw him present (2005), he was claiming they were achieving 85-95% generated code, with only having to hand-write the last 5-15% of tricky logic.

Some modeling tools even permit the architect to mathematically check designs for correctness.

ArgoUML (you can find it on tigris.org) is a pretty good Open Source modeling tool. It's definitely been getting better over the years (although it's still only UML 1.4)

A UML model is about as far from C as you can get (even though they'll generate C++ or Java under the covers.) It's certainly a different way of seeing your code.

John Deters
That is because Java and C++ are 85-95% meaningless boilerplate, not because UML is particularly valuable.
jrockway