views:

256

answers:

23

I don't know what every university calls that, but I'm talking about a course that primarily teaches you compilation principles, and how to implement a basic compiler.

Do you think it's helpful for a programmer to have that knowledge (not necessarily one who wishes to develop a compiler in the future)?

+1  A: 

No brainer --> YES

JohnIdol
+11  A: 

Yes. Absolutely.

There are many classes of problems that become more trivial to solve once you understand the low-level workings, the 'behind the scenes' as it were.

George Stocker
+1 The more you know the better.
Mark Davidson
+1 - Absolutely.
Otávio Décio
I really don't understand these kinds of question. Do young people today ((c) daily mail) actually think that there are things that are BAD for them to learn?
anon
Of course not. But I actually can take another course instead. So it's good to know.
Leif Ericson
Well, I thought that'd I'd never need to know how a compiler actually worked. I mean, there's only so many hours in a day, and at the time it didn't seem like the 'bang for the buck' element was there. Boy was I stupid. It stung me, and it stung me hard. So, I've taken to learning those things that I once thought I'd never need to know.
George Stocker
+2  A: 

It's important to have a good sense for how the compiler acts on your code, so that you understand the sort of optimizations and changes it might realistically perform.

mquander
+8  A: 

Absolutely. IMHO a good CS education should include:

  • data structures;
  • algorithms;
  • a healthy dose of discrete maths (boolean algebra, Big O, etc);
  • databases including relational algebra and SQL;
  • operating systems;
  • compilers;
  • different methodologies: functional, procedural, object-oriented, declarative; and
  • a healthy dose of maths, particularly linear algebra and stats/probability.
cletus
+4  A: 

Yes, definitely. Even if you never write your own compiler, there are lots of problems that learning how to implement a compiler will better equip you to solve. See the article Rich Programmer Food by Steve Yegge for some good examples.

Bill the Lizard
+2  A: 

Learning to put abstract syntax trees into practice can really help you if you need to write some sort of complex validation system, and that's a lot of what I took out of my compilers class so I'd say yes.

Knowing how your code translates into machine language is important too, it gives you a basis for understanding why you should program things in a certain way.

Peter Turner
+5  A: 

Yes, every self respecting University degree in CS has at least one course on compilers. There is also a good book affectionately known as the "Dragon Book" that has been the standard ever since it was written in the 80s (still appropriate today).

Compilers: Principles, Techniques, and Tools (Amazon link)
by Alfred V.Aho, Ravi Sethi, Jeffrey D. Ullman

Peter Di Cecco
Accidentally, it's in the course material (or not so?).
Leif Ericson
+2  A: 

I took a "Programming Languages" course and it was basically what you described. My teacher was horrible but I actually learned a lot from the class. I even managed to implement a small scripting language in C#. I highly recommend it as it will probably teach you a lot.

smack0007
+3  A: 

Absolutely. My CS program had 3 senior tracks to pick from - Compiler, DB, or AI. I picked Compiler and I had no idea at the time how much it would help me later on. Understanding parsing and other compiler topics made it sooo much easier to learn languages, understand regular expressions, SQL, etc. A fantastic foundation!

n8wrl
+2  A: 
Norman Ramsey
+1. Thanks alot.
Leif Ericson
+3  A: 

A compilers course will teach you about computer languages in a way you will never get in any other computer science course.

http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html is a good link for it.

Paul Nathan
Has to be said, I somewhat disagree. I've been writing compilers for a while now and all the knowledge I use to do that was from my Games Programming BSc.
Rushyo
I'm not sure how you disagree...you seem to be speaking orthogonally to me.
Paul Nathan
thanks for article, very good read
ferronrsmith
+1  A: 

You can write compilers.

I'm not kidding that much, by the way. You could, some day, write your dream programming language. (I imagine it could even become a final project of some sort.) This is not only an interesting intellectual puzzle, but has a practical outcome too.

Also, it is a good test of the other skills you will have been learning at the same time - data structures, algorithms, etc.

Finally, being able to write parsers, even if not for a compiler, is a valuable skill - interpreters and DSLs are extremely useful in the real world.

Lucas Jones
+1  A: 

I agree with paul, I took a database elective instead of compiler design and I regret it. DB systems you will have to learn once you get a job anyway.

Byron Whitlock
A good database design course is very valuable as well. (A course that is more than basic SQL, but real large-scale optimization questions).
Paul Nathan
+2  A: 

I think understanding how your code is translated from a high-level language to a lower-level language is definitely a good thing. Most software today goes through several layers before getting down to machine code. If you always work at a high level (in a language like Java or Python), you'll short-change your understanding of how bits are actually managed by the CPU.

By studying and developing your own compiler (or modifying an existing one), you will gain a level of understanding that isn't possible simply by using a compiler. When your level of knowledge moves from "black box" to "open box" you can really make use of your tool chain.

Also: Check and see if the compiler course is research or industry oriented. That should help in determining how helpful the course will be to what you want to do with your degree.

Example question to ask:Does it focus on a project or on the theory of compiling code?

Will Bickford
+7  A: 

I found compilers to be one of the most valuable subjects I studied in grad school.

Unlike many other disciplines in computer science, compilers are a "mature" field: we're not doing a whole lot to make compilers better these days, since we've already "solved" the major issues. (This isn't to say we can't still make progress, just that we're not bounding ahead into vast uncharted territory, as in many other areas.)

This means a compilers course is mostly practical application of software engineering, and less theoretical analysis. In fact, I still employ some of the software engineering methods learned from compilers today.

The other major benefit of such a class is it bridges a gap most people don't explore between the high-level code we use to write most software today and the low-level behavior on the chip. In an architecture course you can learn about the low-level optimizations on a chip (pipelining, et cetera), and in a pure software engineering class you can learn about high-level abstraction (classes, namespaces, and libraries), but the piece in the middle is the compiler.

The only caveat I'll include is that I found particular benefit in studying compilers at the end of my grad school coursework, when I'd already studied "everything" else and moved on to project/thesis work. If you're planning to pursue a Master's or PhD, you might want to hold off. If you're going straight to work after graduation, then you should go armed with knowledge on compilers.

VoteyDisciple
+1 Good points.
DarkSquid
thanks for the excellent tip. Just finish registering :)
ferronrsmith
+2  A: 

I very much enjoyed my compilers course and feel like I got a lot out of it. Although I've never written once since, I did learn a LOT about compiler strategies for emitting machine code, how compilers structure data, why and how languages "are the way they are", and the like. The practical experience has been very valuable when I've needed to do some reverse-engineering or look at assembler.

Otherwise, you'll get a good chance to make something which actually "does something" which was (for me, at least) a bit of a novelty at university. So, you'd get my encouragement to tackle it.

DarkSquid
+2  A: 

Its a very specific topic, well suited for university style learning (and harder to pick up outside).

It gives you some perspective, and is a very good problem solving tool that you probably will find useful later on in your career.

Nader Shirazie
A: 

I'm primarily a .Net developer but I took an operating system pragmatics course in college where we created a very basic operations system. I learned a lot of really useful information, especially about multithreading.

Any chance you get to be guided through low level languages and system functions I highly advise you do it.

Spencer Ruport
A: 

In addition, learning about how CPUs work can aid in understanding Java IL and the .NET Framework's IL. You'll probably never have to deal with those at a low-level, but it is interesting how the IL's work.

Jon
A: 

I strongly advice you to take the course.

It is a very big leap (which is good) and is a good lesson that not all software can be developed by "hacking", but requires planning/documentation.

Taking the compiler course will elevate you above the ordinary.

Peter Mortensen
+1  A: 

Anyway I'll just chime in and say I wanted to take a compilers course, but the place I am getting a masters degree at says that it is outdated and they refuse to teach it. So I'm jealous of you...

But anyway the compiler involves parsing (including lexical analysis), representing what you parsed in an intermediate form, optimizing the intermediate form, and then generating code. But you don't need to be writing a compiler to use those techniques.

For example when parsing text files, if something is "flat" you can get away with regular expressions, a few if statements, etc.. Once something gets overly nested you need to resort to parsing techniques. And basically the parsing part of compiling is something that you will do with configuration files, data files, program commands, etc. throughout your programming career.

Also Perl 6 can always use more volunteers :)
And you never know when you might want to create a new language :)

Cervo
:). sorry man. I wish u could do it, u can read the book
ferronrsmith
ferronrsmith
I purchased the "Dragon Book" and plan to read it. I can already understand BNF rules and create parsers (using YACC/LEX), and I build code generators all the time (particularly for SQL out of spreadsheets), but my hope was that a compiler class would make me even even better at these things :)
Cervo
A: 

Knowing how to write a compiler is also a great first step towards a deeper understanding of your program as data, which is an old notion, but I think an increasingly useful one, ie, in terms of program transformation and the like.

Svend
A: 

It might be the start of a lifelong passion. In my case, I did two undergrad compiler courses, and I'm just finishing a compiler PhD now. My plan for the future: compilers!

There are some more tangible benefits though. Since good geeks tend to be interested in compilers, a good grounding increases your stature in the eyes of your peers, which can't be a bad thing. The large majority of really really smart geeks I know took the compiler elective. This often extends to employers, who seem to think highly of compiler courses - rightly, I might add - since you typically could have chosen much easier electives.

Paul Biggar
nice passion. ROCK ON!!!
ferronrsmith