9 ms·
Why take a compiler course? (2010)
- wolf550e 4y ago(2010), though as relevant as ever
- jononomo 4y agoCopernicus proposed heliocentrism in 1543 and it is still relevant today. Some fields just seem to stagnate, I guess.
- agiacalone 4y agoUni CS lecturer here. One of my mentors in grad school was the compiler professor, and I learned a lot from him. I also got a chance to actually teach compilers for the fist time last year and it was one of the most difficult courses I have ever taught. Used the dragon book and had my students create their own lexer/parser based on an invented language that I came up with. Compilers is one of the few topics that none of my colleagues seem care about, but IMHO it's so very important to learn how to do. In my Uni, the course only gets taught once every few years (it didn't help that our last department chair didn't care for the course at all and never scheduled it). I count the day that I finished my LL(1) parser and lexer for my own compiler course as a student as the day I "earned" my chops. Edit: Since there seems to be some discussion on this thread, I'll throw in the actual project that I gave my students (warts and all). https://github.com/agiacalone/cecs-444-semester-project https://github.com/agiacalone/cecs-444-semester-project
- ethicalsmacker 4y agoMost never "earn their chops" in a traditional sense. These days, it would seem earning your chops is done by running create react app, cobbling together several dozen random javascript libraries and putting out a laughably designed website in a few days.
- fsckboy 4y agowhen I use those sites I think, in a very traditional sense (the French Revolution and the Reign of Terror), "oooh, they've earned their chops!"
- vram22 4y agoVeering a bit more off-topic: - La Guillotine - Madame Defarge and friends - etc. from A Tale of Two Cities. IIRC (may be wrong, read as a kid), those ladies used to signal which aristocrats should be chopped vs. not, by signalling with their knitting needles, or a nod or shake of the head, or some such - while sitting in the front row before the guillotine. Ghoulish. Of course, as a kid, you (I) lap up and relish that stuff, like breakfast cereal. Edit: Links: https://en.m.wikipedia.org/wiki/Madame_Defarge https://en.m.wikipedia.org/wiki/Madame_Defarge https://en.m.wikipedia.org/wiki/A_Tale_of_Two_Cities https://en.m.wikipedia.org/wiki/A_Tale_of_Two_Cities Wow, I did not know before just now seeing the Wikipedia article above, that, to quote it: [ As Dickens's best-known work of historical fiction, A Tale of Two Cities is said to be one of the best-selling novels of all time. ]
- havblue 4y agoThe Georgia Tech cs2130 class, languages and translation, the third required cs class for the major, was notorious as being a weeder course around 1999. The professor made it clear that there would be no partial credit for code that could be core dumped by the teaching assistants. If you weren't good at the class you should probably look forward to writing business applications for IBM, allegedly. So some people used to be hardcore on this subject.
- 4y ago
- the_snooze 4y agoThe big value I got from taking compilers as an undergrad was that it brought everything together. It's basically where computer architecture, theoretical CS, and software engineering (and a hint of systems security) collide in a very practical manner. Compilers make it very clear how all those seemingly disparate topics apply in real non-trivial systems.
- josephg 4y agoI feel the same way about taking Operating Systems. It’s a revelation seeing how all the pieces fit together!
- varrock 4y agoThese are precisely the type of "ahas" I hope to experience, too, when I begin studying computer science. I've been taking introductory college math courses at my community college to fulfill some prerequisites, and a way for me to stay disciplined in my studies is knowing that concepts like the ones you mentioned are coming. Thank you for sharing!
- shepherdjerred 4y agoYou'll have many of these moments! One of the best and worst thing about computer science is how many layers of abstraction there are. On one hand, they help you get things done. On the other, it can be _so_ hard to understand how things really work. Most programmers don't peel back too many layers, but that's okay. If you're really interested, the Code book is fantastic in explaining how computers work: https://www.microsoftpressstore.com/store/code-the-hidden-language-of-computer-hardware-and-software-9780137909100 https://www.microsoftpressstore.com/store/code-the-hidden-la...
- 908B64B197 4y ago> Compilers make it very clear how all those seemingly disparate topics apply in real non-trivial systems. Combined with a proper OS class, it's the first time a student can truly understand all the levels of abstraction from the language to the logic gate. And it also helps to recognize and solve parsing problems. How many programs end-up containing a parser, even if rudimentary, to read non-trivial input of perform validation? No, you can't use regex for that...
- ethicalsmacker 4y agoI really enjoy low level development... things like OS and compiler design. Emulation, simulation, etc. It's sad there's very little place for these "hobbies" anymore, other than that, a hobby.
- saagarjha 4y agoIMO compilers are a bit like kernel development in that the real learning was the friends you made along the way, rather than actually being able to understand how a compiler works, which is a nice side effect. For example, when you write an OS you learn a lot about how code interfaces with hardware. A compiler is many people's first and only introduction to soundness and formal analysis. Being able to put on the hat of a compiler author can be useful in many fields that have nothing to with compiler development, and that's even if you go beyond "I just want to see what my code is being transformed into".
- HervalFreire 4y agoAnyone know of any good free courses?
- erichocean 4y agoI would do the Crafting Interpreters book to begin with. It's free online.
- KineticLensman 4y agoAgree! Learned a lot from doing it myself. Now trying out the techniques I learned there to write a VM for lisp
- ajanicij 4y agoStanford Compilers course: https://learning.edx.org/course/course-v1:StanfordOnline+SOE.YCSCS1+3T2020/home https://learning.edx.org/course/course-v1:StanfordOnline+SOE...
- stefanos82 4y agoI currently study https://github.com/DoctorWkt/acwj https://github.com/DoctorWkt/acwj which is quite interesting I have to admit. I'm interested in this topic, because I want to participate in TinyC compiler's development; I use it quite often to run C demos of mine and its execution is instant. The least I can do is to either fix bugs or extend it to support more C99, C11, C17 features, and why not even C23 as soon as it gets approved? All I need is to gain the necessary knowledge and experience to jump right in and start fixing things.
- cellularmitosis 4y agoThis comment has some great recommendations: https://news.ycombinator.com/item?id=25388091 https://news.ycombinator.com/item?id=25388091
- dbancajas 4y agoCS6120 Cornell that has focus on optimizations and less on parsing. It got posted around within last month on HN.
- adrianmonk 4y agoMy unexpected side benefit: some compiler error messages became comprehensible. Oh, an lvalue is required? Since I now actually know WTF that means, I can deal with it. It also cleared up a situation that had always confused the hell out of me: sometimes I'd compile and get 1 or 2 errors, so I'd make corrections and try compiling again, but then I'd get 8 or 10 errors! Seeing that whatever I did made everything much worse, I'd conclude those most not be the right corrections, and I'd feel lost and maybe even get stuck. After taking compilers, I finally understood why: compilers have phases, and my corrections allowed the parsing phase to complete, which meant the semantic analysis phase could happen and give me errors. So for example, if I finally fix enough syntax errors that the compiler can tell I've written a function with some variables in it, then it can start giving me errors that they're not the right types.
- deleted 4y ago[deleted]
- NineStarPoint 4y agoAgreed on this, by far the largest benefit from a utility standpoint from my programming language design course was increased understanding of errors.
- einpoklum 4y ago> Oh, an lvalue is required? Since I now actually know WTF that means, I can deal with it. That's not so much a compiler thing as it's a language thing. Perhaps even a C (and C++) language thing... https://en.cppreference.com/w/cpp/language/value_category https://en.cppreference.com/w/cpp/language/value_category
- CuriousCosmic 4y agoYes and no. That specifically is a C & C++ thing but the general concept you'll learn in a compilers course. If you intimately understand how a compiler works (even just generally), you pick up a really concise understanding of how the errors come about and how they tie back to the language. Understanding the lexer and the parser explains a lot of common errors (missing/ semicolon or curly bracket) and why they often point to errors in otherwise perfectly correct & unrelated code instead of their source location. Understanding the compiler itself and how it operates over an AST means that if you get an error regarding a particular set of semantics, you can quickly learn what the implications are and how that maps to your code. A good example (other than the GP's) is the massive, ugly template or overloading errors. They make sense and explain to you everything the compiler tried to do and how it failed each time it tried. The compiler doesn't know what is wrong and therefore doesn't have a more concise error to give you so it just tells you everything "it knows". From that you can work back and see where what you intended the code to do diverged from what the compiler thought the code did. So it is a language thing but you build the intuition to pick up those language skills by learning/understanding compilers in general.
- erichocean 4y agoIf you are interested in modern compiler infrastructure that subsumes a lot of recent PhD level research topics, I can highly recommend MLIR. It's under the LLVM Foundation umbrella. If you just want to deal with lexing, parsing, and interpretation (from scratch) for a reasonably complex class-based language, I recommend doing the (free) online book Crafting Interpreters. The second half of that book re-implements the same language in C with garbage collection and a fast byte code interpreter.
- yeetaway1111 4y agoIt will teach most of the good programming and software engineering practices that apply to any nearly any project.
- WalterBright 4y agoWhile one may not be interested in writing compilers, the techniques are applicable elsewhere. For example, I once wrote a date/time "compiler" that could read dates and times in various human formats and construct a time_t from it. It's a giant mess if you approach it in an ad-hoc fashion. But if you approach it from a lexing then parsing standpoint, things work a lot better. I see too many attempts at reading a textual data format that are done ad-hoc. Even worse are the attempts to design a data format where the designer clearly had no awareness of lexing and parsing - the format is just one ad-hoc kludge after another.
- UltimateEdge 4y agoAs a Mathematics undergraduate I am not allowed by my university to officially take (and receive credit for taking) most non-beginner Computer Science courses, including Compilers. At least I'm allowed to attend the lectures and cram it in alongside my other pure math classes!
- epgui 4y agoGood on you for being more academically-minded than your university, and shame on them for not encouraging more cross-disciplinary credits! I went to a relatively small school in Canada, but they were very good about staying out of the way if you tried to take extra courses (with credit).
- actually_a_dog 4y agoWhen I was a math grad student, I technically could have gone through the process to get 1 or 2 CS courses approved to give credit toward my degree, but I never actually cared about the "credit" part, anyway. So, I did my regular course in the math department, taught for the math department, then hung out half the day in the CS department. I ended up auditing, and thoroughly half-assing, Algorithms 1, 2, and 3, Programming Languages, and Automata Theory. Still learned a lot, in spite of the half-assery.
- UltimateEdge 4y agoDid your timetable/coursework schedule allow you to audit a meaningful number of external courses? I find that I can only allow myself to attend one additional course per semester. I STUPIDLY started going to lectures on Computer Systems this year without doing my research first (I couldn't find the timetable for Compilers, and relied on being able to take it officially next year). Turns out I don't have enough (or any) background in C, and so I couldn't make sense of a lot of the lecture material. Oh well, at least now I'm learning C, and I still have the lecture recordings.
- nt591 4y agoI’m currently in a part time masters program for fun and taking the compilers course. I’m sure John’s experience is different than mine, but it seems the question should be put to universities. The professor of my course, by his own admission, hasn’t studied compilers other than his undergrad decades ago and as far as I can tell was assigned the course to teach. As a result the syllabus is relatively dates. I think I’m 8 weeks in and we’ve only discussed parsing theory. As far as I can tell there won’t be time for detailed study of code gen, optimizations, type checking, etc.
- bombolo 4y agoAt my university we had 2 courses. One was focused on parsing and type checking, and one was focused on code generation and optimization.
- frej 4y agoHow can a compiler course not be requeried for a comp.sci degree? We had that. And i’m surprised others do not.
- bombolo 4y agoWe didn't have compilers in undergrad, but we had formal languages being required.
- actually_a_dog 4y agoIt's been quite a while, but I believe my school required Automata Theory, which is at least diffeomorphic to Formal Languages.
- vishnugupta 4y agoI have done my share of compilers work a long time ago, my masters thesis was on this topic. The article mentioned a very important but not well known aspect right at the end which is compilers is not a homogeneous topic but has a fairly independent parts. Front end, optimizers, and target code generation. I dabbled little bit in optimizers and a lot in target code generation. It was quite fun to figure out how to produce optimal machine instructions, or use as few registers as possible etc. Along the way I also got to learn a bit about the OS because one has to know an executable file’s layout, how to utilize heap, make sure not to over run stack etc. And some fun algorithms too, such as a smart way to traverse tree by pointer reversal to avoid recursion as one can’t use recursion (extra space) while garbage collection.
- saghm 4y agoDespite the fact that my algorithms course was ostensibly about learning how to come up with efficient solutions to various problems, the two courses I took that have helped me the most with writing performant code in my career were my compilers course and my architecture course. The compilers course gave me a much stronger understanding of what actually happens when running a line of code I wrote and helped me understand better what types of optimizations could potentially be performed based on the way I write an algorithm, and the architecture course taught me about how a modern CPU actually works with regards to caching, out-of-order processing, branch prediction, etc. On the other hand, the types of things we discussed in my algorithms course felt very hit-or-miss with regards to whether they actually felt useful or not. I'm not just talking about high-level abstractions that can miss important details in the real world like "memory can be accessed in constant time" either, but solving problems that were so contrived to the point of being almost implausible. The example I always remember is that in one of our problems sets, we were asked to write an algorithm that sorted an array of size N with each element within K indices of the correct sorted position in O(n*log(k)) time. I can't think of any situation where I'd have data so large with a small enough strict upper bound on K that such an algorithm would be necessary, but even if I did find myself in that situation, that's the exact type of input that the naive quicksort implementation would perform more efficiently on! Maybe someday we'll have powerful enough tools that we can generate code that's performant without needing to do it ourselves, but at least for now, writing code that a computer executes efficiently is much easier when you actually understand what's being run on the computer and how it runs it, and a compilers course is a great way to start learning about the first half of that.
- jltsiren 4y ago> Despite the fact that my algorithms course was ostensibly about learning how to come up with efficient solutions to various problems The usual advanced undergraduate / graduate level algorithms class is not supposed to teach you that. It's an introductory class to various techniques used in algorithm design and analysis, beyond those included in the undergraduate algorithms and data structures class. Core algorithms classes then assume familiarity with those techniques. One of those core classes may be algorithm engineering, if your CS department has someone interested in the topic. And if the department assumes that there are enough students interested in it – the overlap between people interested in algorithms and software is often surprisingly small.
- jonstewart 4y agoI did not take a compilers class when I was in college. Many years later, feeling the lack, I bought the Dragon book. I didn't make it past Chapter 4 because I was inspired to write a new library and tool, which then brought me a modicum of career success. Regehr is right on the money here: parsers and interpreters are everywhere. Once you learn how approachable and applicable they are, you can solve problems faster and better. I now always recommend to college interns that they take their CS department's compilers course their senior year (along with their English department's Shakespeare course).
- pyrolistical 4y agoCompilers also show an application of pipelines which can be used architecturally at all levels. I’m a happy coder if I can translate my problem to a pipeline problem. Each pipeline step can be modelled as a pure function. Each artifact between each step can be inspected and cached. Pipeline failures can be resumed at the last valid artifact
- geophile 4y agoI was in grad school, 77-83. The first year was part time at NYU, and then I went back full time elsewhere, for a PhD. In that one year at NYU, I took two compiler courses, from RBK Dewar, of Spitbol and Ada fame. My specialty is not languages or compilers, but those courses were incredibly fascinating, and the exposure to the topics I learned has been useful throughout my career. - I learned about lexing and parsing. I no longer remember the details of LALR, for example. But I understand the basic ideas well enough to construct lexing/parsing software whenever I need it, often using parser generator tools, but also rolling my own on occasion. - I learned about code optimization, which is a fascinating topic. At the time, Dewar was working on SETL, a set-oriented language. And I remember the power of having sets as a builtin type, and how powerful that was for expressing flow analysis, for example. Those ideas combined nicely with what I later learned about relational algebra, and query optimization. (Codd's paper on the relational model was only seven years old when I started grad school!) - Exposure to the ideas of interpreters and code generators, and even more fundamentally, the idea of code as a thing that can be manipulated programatically, has been useful throughout my career. - Oh, and by the way, Dewar was a great teacher.
- jll29 4y agoCompiler construction is a part of practical computer science that includes - formal languages, Chomsky hiearchy and automata (DFAs, NFAs) - algorithms & data structures (syntax trees, symbol tables & hashing) - parsing algorithms - asymptotic complexity (of automata recognition/acceptance and parsing algorithms) - software architecture (single pass versus multi-pass, abstractions) - operations research (graph coloring based register allocation) - assembler & automatic code generation - virtual machines & interpreters It is a field where theory and practice come together beautifully (and works like the Aho et al. ¨Dragon Book¨ or Wirths ¨Compilers¨ are masterpieces that lucidly lay things out so after reading Chapter 2 of the former, or all of the latter short volume (barely 100 pages), a compiler is basically demystified to any undergrad).
- hardware2win 4y agoImo Formal langs theory is too weird and formal And dragon book is too focused on formal math
- mhh__ 4y agoIts too focused on the mathematical approach to parsing but almost no mathematical rigour or intuition for the actually interesting parts of compiler IIRC. These books really only help you for the first five minutes of each part of a compiler e.g. "Here's how to write a register allocator, go find the calling convention yourself and my office hours are never"
- AstixAndBelix 4y ago>why the hell should I take an electromagnetism course as a physics undergrad? I want to work in fluid dynamics dammit! unfortunately there are too many people who think a CS curriculum should be an advanced coding bootcamp instead of a place where you actually explore how your software works
- ramg 4y agoWe use gcc/javac/etc almost daily and having some understanding of what your toolchain is likely to be very beneficial. Here are a few things I've done with my compiler knowledge: 1. Wrote a simulator of sorts for a 68xx CPU. User passed in assembly files and I simulated the execution and spat out cycle counts. The real-time application had a fixed time window it could not exceed. I did this in my first year out of college with compilers fresh on my mind. 2. Wrote an automated test tool for a proprietary protocol. The protocol had the usual opcodes but they could only be played in a certain order (cannot send B before C or can send B any number of times and have it be idempotent). The QA engineers were doing this by hand. I asked them if they could automated the test case generation and they looked at me as though I was an idiot. I developed a tool with its own simplified grammar that they could use to build test cases which exercised all combinations/permutations of the opcodes. Saved us a ton of time and made the developers more productive. 3. My hackiest project was an SGML parser that was used to generate hypertext documents. Tech writer wrote docs in FrameMaker. My hacky parser found the places where the TOC and the Index could be linked and inserted hypertext links. Net result is we had a document that could be printed and viewed online. Think 1993/1994. I've sat with a number of engineers who thought the compiler was wrong and sat down and looked at the assembly with them and mapped it back to C only for them to realize the bug was in their code. Compilers are fun. You should take a compiler course just for that!
- einpoklum 4y agoMy two answers - based also on personal experience - would be: 1. If you are ever concerned with code performance, you need to know what the compiler (/interpreter) is doing with your code. With a compiler course, you'll get a basic understanding - enough to later actually look at what the compiler is doing with your real-life code. 2. If you write a software system which can handle computation tasks that are not fully known at compile-time - such as user queries in some domain-specific language - then you are likely to end up implementing a compiler in your software system. If you haven't learned about compilers, you'll (a.) may fail to realize that and (b.) are likely to do it more poorly than if you have. --- My beef with compiler courses, though, is the excessive focus on parsing. Text parsing, look-ahead grammars etc may be interesting in themselves, but IMHO they're mostly self-contained and not what you will be concerned with in the life-scenarios I've described above. I would have liked, in hindsight, to have more time devoted to optimization selection, passes and what goes in each of them, optimization work on the AST vs work on the IR etc.
- forinti 4y agoI've had the chance to build parsers for work. Once for a templating engine for SQL (taking values from the environment and using them queries). This was really nice for productivity and an intern could churn out dozens of reports a day. That was written with javacc. Another time by using a parser (written with Antlr) to extract bits of PLSQL packages (procedures, functions) and move them from one environment to another without having to send the whole package. Although this type of job is rare, it can be really useful when it shows up.
- thriftwy 4y agoSee also https://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html https://steve-yegge.blogspot.com/2007/06/rich-programmer-foo...
- LtWorf 4y agoI've written a compiler that people actually use[1]! Studying compilers at university was highly beneficial. Before that course the code was a mess… [1] https://ltworf.github.io/relational/ https://ltworf.github.io/relational/
- philiplu 4y agoI'm a self-taught programmer, starting in the mid-70s, and learned how to write compilers in a way that probably wouldn't work nowadays, but was great fun back then. The first thing I'd usually do when starting on a new architecture was write a disassembler. In the late 70s, I was mostly programming in 6809 assembly, usually in Microware's OS-9 operating system. Microware released a Pascal compiler, so I ran my disassembler over that. Turns out the compiler was self-hosting, written in Pascal, and the compiler output was almost completely unoptimized. So I decompiled the compiler back to Pascal by hand, just to see how it worked. I obviously had waaaaay more free-time back then. I eventually read the green Dragon book (Aho & Ullman, Principles of Compiler Design), and ended up at Microsoft on the C/C++ team in 1991. Over the years, I've written several domain-specific languages (DSLs), small languages for some limited purpose. That early exposure to lexing, parsing, and error detection was invaluable.
- jjav 4y ago> Microware's OS-9 operating system I loved OS-9 on the 6809. It was my introduction into unix-ish-like systems that led into SunOS and later Linux and the foundations of my career.
- jononomo 4y agoThis is a great comment. I love that people like you are on Hacker News and it is why I appreciate this site so much.
- philiplu 4y agoThanks! It's gratifying that the reminiscences of a graybeard like me can still resonate with readers here.
- murdoze 4y agoI also wrote a source-generating disassembler for a 8-bit i8080-based Soviet-designed computer, RADIO-86RK — because I wanted to improve software published in the magazine. And explore stuff.
- Garvey 4y ago
- pxeger1 4y agoI think there is a more general argument to be made than the one about predicting compiler optimisations. Being familiar with how a compiler typically works allows me to use one more fluently in various ways. For example, predicting and fixing compile errors, because I know roughly what the compiler will be looking for.
- jononomo 4y agoIt wasn’t until I took a compiler course that I truly understood how important Noam Chomsky is.
- tcmart14 4y agoAs part of my degree, I took linguistics as a humanities elective. I guess at my university, they don't have many CompSci/SoftEng students take a linguistics course. My professor asked me specifically why I took her a class. I told her that I knew Noam Chomsky, a god in linguistics, helped shaped quiet a few things in Computer Science. Really surprised her that I knew that and thought it was awesome. Also for anyone. If you get a chance to take a linguistics course, take it. It really is a fascinating topic. The implications on computer languages, but just in general it is just interesting.
- murdoze 4y agoChomsky is fine with formal grammars, but completely wrong when it comes to natural languages.
- thelittlenag 4y agoIn terms of cost/benefit, I think it makes way more sense to learn to think in terms of "algebras", and how to create both internal and external DSLs in a host language. I've found it incredibly helpful to have an algebra-first approach as I model a (complex) domain and service interactions. Being able to write business logic as the composition of algebraic actions in several lower-level services, along with interpreters just feels great. Of course this overlaps strongly with particular aspects of compilers, but I find that external DSLs, which is where the overlap is greatest, are the tool that I reach for least often and that elicit the greatest resistance from fellow engineers.
- chillpenguin 4y agoCan you give more info on "algebras"? I think I have heard the word used in this way before, but I don't exactly understand the meaning.
- thelittlenag 4y agoIn Scala this tends to manifest as either tagless final (https://www.baeldung.com/scala/tagless-final-pattern#1-algebras https://www.baeldung.com/scala/tagless-final-pattern#1-algeb...) or free monad (same thing, different encoding).
- amelius 4y agoCompilers are easy. The concurrent garbage collector is where the challenge begins, nowadays.
- deterministic 4y agoPro compiler developer here: Simple compilers are easy. You can do one in a weekend. High performance optimising production compilers take years.
- juancn 4y agoCompilers are like puzzles to be solved. They are so deeply coupled internally and so grounded in pure logic that in many cases, features of the languages implement themselves as the logical consequence of the way the compiler it's constructed. Learning them also teaches some skills on how to subdivide the solution to a really complex class of problems into comprehensible chunks. Heck, there are many seemingly unrelated problem domains that can borrow solution strategies from compiler design and implementation. It definitely is a nice tool to have in your tool belt.
- hibikir 4y agoTaking the compiler course changed my career from day 1. In my first job, back in the late 90s, I was working for a company that, having taken their biggest customer yet, had to split a very large C monolith into chunks that could run on separate servers. The architecture team of the company found all the places where the system should be cut, but that let them with hundreds of functions that had to be replaced with asynchronous calls relying on a queuing system. I was hired into the team that had to stub those hundreds of functions, type up serialization and deserialization for all the hundreds of data structures involved, and gluing it all together. So they had budgeted for 6 months of typing from a team of relatively new developers. As you might expect, that's not how anyone wants their career to go, but I had taken the compiler class. So I knew I could parse all the header files for the functions we needed to replace, parse the data structures along with it, and just generate all the boilerplate away. My dev lead thought there's no way we could do this, but his manager decided that, at works, giving me two weeks to try it would be a great opportunity to teach the new hire the limit of his knowledge. But as anyone that has taken the compiler course knows, parsing boring C structs and header files isn't magic. So two weeks later, the project was done, and it was working. As you might imagine, the dev lead, in his 40s, couldn't handle the results all that well, and left quickly. So I went from being stuck writing boilerplate from month to a quick promotion to team lead in under a quarter, all thanks to the compiler course.
- rehash3 4y agoThanks for the causal ageism from someone who is in their 40s or more now... The dev lead did not know something very useful for the project, this could be some one in their 20s, 30s, 40s or 50s... knowledge or lack of knowledge does not differentiate...
- n0w 4y ago> "knowledge or lack of knowledge does not differentiate..." I agree wholeheartedly. Knowledge, or even intelligence, shouldn't be the most highly valued skill in a team lead. But there are many people extremely confident in their confirmation bias that seem to be unwilling to consider anything that might challenge their ideas. Our industry has a problem with celebrating the intelligent arsehole. Not only is humility not incentivized, it seems to be actively counterproductive. I wonder how we can foster the kind of culture that values experience, encourages innovation, and is also able to get things done without chasing geese?
- stbenjam 4y agoI took the compiler class at Harvard extension school, after being a developer for a long time. I learned so freaking much. It’s such a hard course since you write a C compiler basically from scratch but it was without a doubt the best learning investment I ever made.
- nickysielicki 4y agoI think it’s completely insane that you can get a computer science degree without both a compilers course and a computer architecture course. It’s entirely normal for a developer to start their career without really knowing how code becomes assembly or how a computer processes assembly. That’s wack.
- deterministic 4y agoI have noticed that the best developers I have ever worked with knows how to write a compiler. And the not-so-great developers don’t. It might just be a random correlation of course. But perhaps not?
- hcks 4y agoLet’s be honest, there is little benefits to take a compiler course in 2023 (best one is to satisfy curiosity). 1/ there isn’t much to know about parsing and any good compiler course won’t spend too much time on it anyway 2/ and 3/ these points are not really about compilers in general and more about C compilers. You can also learn that trivia independently.
- porridgeraisin 4y agoIn lieu of this, Nand2Tetris [1] is an absolutely great online, free course where one can go through all of a computer's abstractions - logic gates to an assembler to a bytecode compiler to a stack based virtual machine with an interpreter and an operating system with display, I/O, etc, building everything along the way yourself. The hardware stuff is in a simulator of course, but that doesn't take away from the gold mine of revelations one gains from going through this course. The community is great as well, so many people did amazing things like build entire ray tracers in their own computer. Although I stopped at a sudoku game, seeing all of that is so good. [1] https://nand2tetris.org https://nand2tetris.org
- samsquire 4y agoI did not have a compiler course at university but I talked on r/programminglanguages discord and eatonphil's discord and I learned how to create a simple expression compiler in Python. You can run the code here: https://replit.com/@Chronological/Compiler3 https://replit.com/@Chronological/Compiler3 It's ~400 lines of code and it compiles the following AST program = Main( [ Assign("a", LiteralNumber(5)), Assign("b", LiteralNumber(6)), Println("Value is %d", Mul(Add(Reference("a"), LiteralNumber(7)), Add(LiteralNumber(8), Reference("b")))), Println("Hello world %d", LiteralNumber(10))]) Or in other words, the following expression: a = 5 b = 6 (a + 7) * (8 + b) If you run python3 main.py > assembly.S gcc -o assembled assembly.S ./assembled You should see Value is 168Hello world 10 It's barebones but I think it's the basis for a compiler.
- mad0 4y agoAnyone has suggestions for taking such course (books, websites etc.)? During my studies there was no compiler course on my university (which is saddening). I would also like to find some reputable OS internals course or book...
- eigenhombre 4y agoIf you're interested in compilers and language implementation, it may not be obvious, but one needn't be a university student or devote a semester to the topic. Taking a four-day compiler course[1] (now five days) whetted my appetite for implementing languages and learning new ones, and led to a number of toy language projects. Also mentioned here, the book Crafting Interpreters is wonderful. The world may not need many more programming languages, but making your own is a heck of a lot of fun. I find it especially satisfying when tests written in the new language start to surprise me by already passing, because enough of the language is working. [1] http://www.dabeaz.com/compiler.html http://www.dabeaz.com/compiler.html
- jheriko 4y agojust make a compiler. same result, less time, more learning. yes you should be able to "just do it" nothing involved is hard, everything i needed i had by age 14 in the 1990s without the internet. this means you have it too.
- absoluteunit1 4y agoI’d love to learn about compilers. I’m a self taught programmer; what books or online courses would folks here recommend ?
- techn00 4y agohttps://craftinginterpreters.com/ https://craftinginterpreters.com/ https://interpreterbook.com/ https://interpreterbook.com/ https://compilerbook.com/ https://compilerbook.com/ Cornell (advanced): https://www.cs.cornell.edu/courses/cs6120/2020fa/self-guided/ https://www.cs.cornell.edu/courses/cs6120/2020fa/self-guided...
- alphabetatheta 4y agoSome of the best programmers have come across had their origins in OS and compilers. This is where the real programming and fundamentals are built.
- norswap 4y agoShameless plug for my compiler class, fully available on YouTube: https://norswap.com/compilers/ https://norswap.com/compilers/