4 ms·
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
by andrewflnr 7y ago
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.
- joe_the_user 7y ago"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.
- musicale 7y ago> 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.
- jcranmer 7y agoPersonally, 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.
- wrs 7y agoI 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.
- saagarjha 7y ago> 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?
- andrewflnr 7y agoI 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.
- davidcuddeback 7y ago> it's not going to be on the necessary track for a degree Compilers was a required 2-class series for my CS degree.
- crooked-v 7y agoI'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.
- userbinator 7y agoI 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 https://github.com/rswier/c4