News for hackers. Stuff that matters.
Re:Thought Experiment: An Introductory Compilers Class by andrewflnr on Monday February 17, 2020 @03:41PM (#22350531)
I disagree a bit with the premise. I feel that the most important part of a compilers course is communicating that compilers are not magic, that none of this is magic. Good developers need to be able to see through their abstractions when necessary, and it's too easy to treat compilers as a black box.

As a slightly different concern, I think the curriculum above runs the risk of giving the impression that even if compilers aren't magic, they definitely need a lot of heavy duty abstract math. I'm not in favor of this either.

With that in mind, my ideal compilers course would probably take an intuituve approach to lexing, recursive decent parsing, and extremely simple tree-walking, stack-based code generation. Keep calm, it's all just data and basic algorithms.

My college education had the effect of lowering my expectations of my fellow students, so a more sophisticated course may be appropriate in some cases. YMMV.

Re:Thought Experiment: An Introductory Compilers Class by jcranmer on Monday February 17, 2020 @06:15PM (#22351845)
Personally, I feel that a compilers course should actually be about learning how to build a compiler. After all, the only reason to take a compiler course is because you want to--it's not going to be on the necessary track for a degree. The attitude of "you're not going to remember anything about compilers anyways, so let's make this an advanced math class" is quite frankly insulting, most especially to people who actually want to take a compilers course to learn about compilers.
Re:Thought Experiment: An Introductory Compilers Class by andrewflnr on Monday February 17, 2020 @08:02PM (#22352510)
I mean, I wouldn't object to having compilers be mandatory. Out of the other side of my mouth, I like to say that a compiler has great properties for teaching actual software engineering, e.g. managing complexity, dealing with changes (hey kids, we're adding a new syntax feature! Now we're adding closures!), while still teaching you that compilers aren't magic... so that's another approach I would endorse. At that level, you actually would want some formality, but you could add it gradually.
Re:Thought Experiment: An Introductory Compilers Class by wrs on Tuesday February 18, 2020 @11:37AM (#22357265)
I think it is required at some institutions (pretty sure it was at CMU when I was there), because not only is it useful to understand such a fundamental daily tool at a deeper level, but as the post says:

>everything in compilers is packed to the gills with absolutely gorgeous algorithms

So you get to see practical usage of some advanced things rather than just abstractions.

Re:Thought Experiment: An Introductory Compilers Class by davidcuddeback on Monday February 17, 2020 @09:38PM (#22352982)
> it's not going to be on the necessary track for a degree

Compilers was a required 2-class series for my CS degree.

Re:Thought Experiment: An Introductory Compilers Class by saagarjha on Monday February 17, 2020 @06:25PM (#22351911)
> After all, the only reason to take a compiler course is because you want to--it's not going to be on the necessary track for a degree.

I think that depends on the program?

Re:Thought Experiment: An Introductory Compilers Class by joe_the_user on Monday February 17, 2020 @04:12PM (#22350817)
"I disagree a bit with the premise. I feel that the most important part of a compilers course is communicating that compilers are not magic, that none of this is magic"

It depends what you mean by "magic". I think compilers are one of the hardest things for a programmer to learn naively. I've had co-workers who were semi-self taught and who simply didn't get the idea of an abstract language - it really is a mathematical construction that's somewhat difficult (making a language into a "object" is generally a mistake). For example, it's much more coherent to write a parser that will check whether X string properly specifies file than to just start writing loops and checking values (of course, you really want to just ask the system but that's a different point).

A smart-ish person can just wing-it for a variety of programming tasks, say simple string-processing tasks or computer games, but there are definitely places in compiler construction where you have to know what you're doing, where you have to learn an abstract idea and not just a bunch of specifics.

What I'd like, in a sense, is a map showing which parts of this process are parts where nothing standard and which parts are all kind of the same because it doesn't seem like most compile-construction mark out their in anything like this way.

Re:Thought Experiment: An Introductory Compilers Class by userbinator on Monday February 17, 2020 @11:01PM (#22353352)
I agree strongly about the "not magic" part, and think that there's no better way to show that than to have the goal of the course be to create a self-compiling compiler.

As a matter of fact, a whole course could be devoted to the study of this masterpiece: https://github.com/rswier/c4

Re:Thought Experiment: An Introductory Compilers Class by musicale on Monday February 17, 2020 @05:08PM (#22351324)
> Keep calm, it's all just data and basic algorithms

This is a good approach for all introductory systems courses. It's also a good approach for most real-world systems.

Re:Thought Experiment: An Introductory Compilers Class by crooked-v on Monday February 17, 2020 @10:30PM (#22353219)
I'd agree with this general take on things, because while I've never actually built a 'real' compiler and probably never will, even a shallow level of lexing and tree-walking has been majorly useful several times in my career even working mostly in frontend web development, since it makes for highly efficient DSLs and configuration tree transformation.