Maybe it's just my school though.
I can only imagine what he told the kids who wanted to become civil engineers.
*edit: I say that firmly tongue in cheek. The Dragon book is one of the most important pieces of CS literature ever written. It's a fine book, the subject matter is just difficult:)
It would be great if there was a book on modern compiler techniques, including SSA, abstract interpretation, compiling high level languages, pointer analysis, compiling dynamic dispatch, garbage collection and closures, etc. Probably the closest are Appel's compiler books.
This was at least 6 years ago though, so my memories are a little cloudy.
I half-wish that there would be a way to teach a compilers class as the second class in a CS track (ie, right after the intro class), but the problem is that it just requires too much familiarity with the details in order to impose upon most beginner/intermediate students, even if a few really interested ones could potentially handle it.
It might be easier if you started off with Scheme and then went from there (a la SICP), but even then, you'd miss a lot of the more fundamental concepts assumed in the Dragon book that really just need a lot of time to be digested.
[1] Alright, there's probably a three-way tie for 1st, but it still counts. My education would not have been complete without it; I highly recommend the Dragon book to anybody who has the time and interest.
In the article, he mentions that the students don't get to compilers till 4th year. I find that a little strange. Some elementary understanding of how a high-level programming language translates to executable code is quite useful in other courses in a standard CS curriculum. At my school, in 2nd year we write a compiler for a tiny subset of C++ to MIPS assembly, and in 4th year you write a compiler for Java with a great deal of optimization.
When I attended my CS course, in the 3rd years I got some understanding about programming language structure and learned about compilers at the end. It's cool that you can learn about that earlier.
@dovyski: it's nice to see this coming from a brazilian university -- I'm from UFABC, São Paulo
Thanks and nice to see a brazilian fellow around here :)
Compilers seems like a pretty standard CS course at most schools.
On the third year at my university, there's a course centered around writing a Java compiler.
Then my language design aspirations languished for about 10 years until I had a Discrete Mathematics class based around writing a parser and interpreter for Datalog (subset of Prolog).
Then there was the programming language design class where we implemented interpreters for various language features in Racket, but by then I forgot most of how to write parsers and (read) takes care of most of the hard part there. It certainly would've been more fun if we'd had to design our languages, rather than just implementing predefined ones.
And several computer architecture & an operating systems class that dealt with "this is what C code gets turned into", but no details on the actual process of doing the translation.
So, I guess this kind of thing has been fairly well represented in my formal education, but not very well integrated. Just disjointed bits and pieces as they're relevant for some other subject. It'd definitely be nice if they were more coherent earlier on, before tackling Compilers head on.
If you have a chance, it might be a rare opportunity to point out some of the innovative ideas, after all the projects are done.
Tom spent awhile doing this in Waterloo Fortran, and when he presented me with the working compiler I said "Good job. Now execute the code." He blinked his surprise - until then I don't think he'd considered that the toy machine could have been interpreted. A revelation! He went back home and wrote the VM for the toy machine without any assistance; it worked well and I was as proud of him as I could be.
A couple of years later I hired Tom and a couple of years after that he lapped me, going on to better things. 30 years later I still keep a copy of his compiler and interpreter, reminding me from time to time of the bright kid who grew up to become a fine programmer and family man.
...I was once the precocious high-schooler; in my History class I put a .com file in the program's directory that ran a look-alike program which didn't in fact work - on perhaps the only IBM PC in the school.
(Since DOS executed .com's first, and only the .exe if no .com was found, adding a .com was a prank and harmless, but that didn't help my case.)
It was only a few years later, me interviewing for a job at a tech company that the manager told me he was my History teacher's husband, and had cleaned up my mess.
I could only thank him for both placating my teacher and then going on to offer me a job.
In hindsight, I could have figured out that the nicest PC in the school wouldn't be there just out of sheer random chance...
[0]I have taught courses where intro-level students write Scheme interpreters (in Scheme, in Java) and courses where students implement interpreters for higher-level languages, and courses (well, one so far) where they implement an actual compiler (for a subset of C).
That's my goal, not teaching about compilers or language structure. About that they will learn empirically.
It's interesting that you want them to make a procedural language, although if they started with C, it makes some sense.
I wonder if you could broaden the experiment slightly by relaxing your constraints and saying they either need to allow reassignment of variables, or else support lambdas, and in exchange they can assume immutability.
I think a procedural language makes more sense for them at this time. They are just learning OOP, so it would be hard to implement an interpreter for that.
About your suggestion, that's cool. I think most of them are already assuming immutability and using floats/doubles as the type of all variables.
If you relaxed the constraint on syntax and just stipulated Turing-completeness, it would be very amusing if someone implemented a clone of Brainfuck. ;) (Especially for the unlucky pair who has to write two programs for it!)
With the exception of barely 2 projects in uni, all my homework/projects were short and small scale, meaning I already knew how to complete 90% of it, and just had to learn the content from the latest lecture to complete the rest.
With this assignment I probably would have known ~40%, meaning I wold have to buckle down and actually get invested - figure out what I know and don't know, and self study to the answer. Because I wouldn't just be able to rely on my teacher and lecture notes, I would actually have to take (some) control of my learning to succeed (rather than expect the teacher and textbook to hand feed me everyone I need to know). Because I'm not hand fed everything, I would actually become motivated because my success (or failure) for once would be somewhat in my own hands. What a concept!!! Congrats.
You described my thoughts when I created the assignment :) Like I said, I was afraid to push them too hard. However I was denying them a real challenge, filled with surprises, learning experiences and fun.
It's a very slick implementation. BTW, we had a similar requirement for our "Programming Languages" undergraduate course: to implement our own language with a BNF grammar, parser, etc (done in ML). It was one of the best learning experiences we had!
The pipe dream part of me wants you to have them stick their results on github and work with each other, or start getting taught stuff by ... well, everyone.
My high-school comp-sci teacher is a large part of the reason why I can reason clearly about code, and he would push us in directions like this -- not as extreme, but similar in the "ok, here's an end goal that you can achieve by thinking about it and making combinations of what you know" sense.
I know a lot of programmers who don't grok compilers, even at a high level, and it's a shame -- a lot of things are a lot easier, and you open the doors to doing a lot more if you do.
About the github idea, I like it, but my students are not familiar with git yet. I will try to blog about their main ideas and language syntax in the future.
Interpreters, compilers, and games are the things that have taught me the most about programming and computing in general. Implementing programming languages pushes high-level CS concepts as well as firsthand understanding of how languages work. Games are a fun practical application of those concepts—embedded scripting languages in particular—plus trig, vectors, matrices, rendering, optics, audio, DSP, physics, you name it. And languages and games both provide plenty of opportunities to learn about optimisation.
I hardly know why CS is taught any other way.
I totally agree with you. My student's next assignments will be game-related: develop an agent to fight inside an arena and create a Guitar Hero like game.
I really think they will learn more and better if they have to accomplish that kind of assignments.
It is a great way to learn how a compiler works, but then again, in this day and age it seems less and less relevant to know that stuff, especially if you are going into a typical programming position.