views:

165

answers:

5

I need to pass a "General Compiler Design" test from a potential employer and believe the best way to do so would be to get to know a little about all of compiler design. If you think another method would be better, let me know. Now then:

I have intermediate to advanced knowledge of:

C C++ (not as much as C) C# Java Python Ruby Perl PHP

I know the differences between compiled and interpreted languages. I know how things work at a bit and byte level such as how data structures are implemented, truth tables, etc. I have looked over the posts here and found the "Dragon Book" is to compiler design what the "The C Programming Language" is to C.

I would like a book that goes over the basics, without too much depth, so I can kind of get the gist of it then delve into each specific topic on my own. Thanks in advance for any advice.

Also, I might be in over my head but learning can never hurt :)

A: 

You might be over your head (in that most colleges offer a computer-science "compilers" class at some point in their curriculum, and it's a full-quarter/full-semester class)... but it certainly never hurts to try learning something new! I'd probably start on Wikipedia, and go from there. (It also includes a reference to a list of compiler resources.)

JaredReisinger
Thanks, I Appreciate the direction.
Codygman
+8  A: 

You're in over your head.

"The Dragon Book" isn't like "The C Programming Language" at all. The C book is very accessible, and very basic. Dragon is the opposite end. It's formal, filled with greek letters, and you'll be befuddled as to what technique to use for what case.

Compilers, in general, tend to be fairly complicated pieces of software. Even simple compilers. A "simple" expression lexer and parser is a complicated piece of software. Modern tools can help (ye olde "Compiler Compilers"), but they're no panacea, and they're don't substitute for understanding what is going on.

With compilers, frankly, book knowledge isn't enough. You need to actually do the dirty work to at least some degree. They're complicated machines, and until you build one, you don't really know what's going on. They have a lot of moving parts.

If a compiler requirement is necessary for this position, "cramming" for it is, frankly, unfair to yourself and to the employer. Ideally they'll vet you out right away in an interview anyway, but even if you somehow skate by, having a compiler task dumped in your lap is not a pretty picture. Add to the compiler problem the secondary issue of code generation and runtime management, it's a complicated system all around.

Will Hartung
It's not hopeless, but I'd agree that the Dragon Book is not a good self-study/cramming tool. Without a professor to explain it, it's mostly gibberish. I'm not sure what to suggest in its place, but there has to be something more approachable/practical out there.
Kristopher Johnson
Oh, inevitably. There are several books for the "working programmer" on building compilers.
Will Hartung
@Kristopher This is basically what I was looking for. @Will I'll search for those books, but do you have any personal recommendations?
Codygman
@Will Hartung: The OP is actually looking for recommendations of such books, rather than a recommendation for or against using the Dragon Book as an introductory text. *edit*: yea, veritably.
intuited
A: 

Pragmatic Programmer's book Language Implementation Patterns is a good introduction to building your own little languages. It won't get you to modern compiler design, but depending on the rest of your experience, The Dragon Book might be too much too fast. (And I've heard looks pretty outdated by today's standards, too.)

sarnold
This book looks really cool! Thanks, for the recommendation!
Codygman
+3  A: 

The only one that comes to mind is Writing Compilers and Interpreters by Ronald Mak. It isn't quite the academic wonder that the Dragon book is but it is very readable. You won't be learning about the tools that you would actually use if you ever work on a compiler (ANTLR, Yacc, Lex, etc.) and you won't learn how to make a production compiler, but it will get you up and running with the basics in, oh, 900 pages or so.

If the job that you are looking into actually involves writing or supporting a production level compiler for anything beyond the simplest language, then I would recommend enrolling in a compiler course at a university. If you learn better by reading, then pick up O'Reilly's Lex and Yacc, the Dragon Book, and Levine's Linkers and Loaders. They will give you a good start.

If you want to look into the modern tools, then check out the ANTLR site. I haven't read Language Implementation Patterns yet, but it looks like a good reference for starting out. I've been meaning to look into ANTLR again but I haven't had the need to write a compiler of any kind for about 8 years now. :(

D.Shawley
Thanks for this! I should be able to get through the read the book and get some concepts in a few days. Exactly what I was looking for. The job doesn't require me writing or supporting a production level compiler, just having some basic knowledge of the subject.
Codygman
A: 

Create a language compiler is another link that goes through creating a very simple compiler. It would get the basics down for you in about 4 hours..

Mongus Pong