3 ms·
The GNAT Ada compiler is open source, generates good code, and has really good error messages. There's a story behind its development, which I tried to summariz
by dwheeler 6y ago
The GNAT Ada compiler is open source, generates good code, and has really good error messages. There's a story behind its development, which I tried to summarize here:
https://dwheeler.com/essays/make-it-simple-dewar.html https://dwheeler.com/essays/make-it-simple-dewar.html
- e12e 6y agoThank you for posting that. Especially interesting in light of Walter Bright's comment(s) in this thread. I didn't quite understand why someone who wrote a c++ compiler would think Ada was insurmountable - this adds some context. In my nativité I'd have guessed that writing an Ada compiler was on par with Pascal (but with more types and stuff). This is probably the same (wrong) reasoning by which Mr Bright tricked himself into writing a c++ compiler ;) Ed: note, I was introduced to Object Pascal - not plain Pascal - so that's the comparison I'm alluding to.
- Lucretia9 6y agoOh Ada is so much more complex than Pascal. I think getting something with the numeric types is doable in a smaller timeframe, the OO, tasking stuff would be much harder. You could knock out an object-Pascal / Oberon compiler in a matter of weeks imo.
- pjmlp 6y agoOberon and Object Pascal as initially introduced yes. On their most up to date variants, Active Oberon and Delphi/Oxygen/FreePascal it will take much longer than just a couple of weeks.
- neverartful 6y agoI had always heard that PL/I and Ada are much more difficult languages for producing a suitable compiler.
- dwheeler 6y agoAs noted in the article I posted earlier, Ada isn't that difficult a language to compile, it's just that early Ada compiler developers assumed it was hard, so they made it hard. The GNAT Ada compiler is OSS, so you can look it yourself. It has a hand-crafted lexer (for speed), but otherwise it's not complex. It uses recursive descent (for good error messages), but lots of compilers do that & it's not hard to understand either. (If you don't understand creating a recursive descent parser then you'll need to learn that, but it's a one-time cost to learn about that). Ada is really easy to parse compared to C++. There aren't the backwards-compatible-with-C historical stuff that makes things complicated. Ada has built-in support for tasks, including safe communication mechanisms for them. Many other languages today do too, so that's not such a big deal today. Generating very good code is hard in any language. GNAT "cheats" by building on gcc, which already works on this problem. GNAT parses source code & then generates the internal structures needed for gcc to do its thing. Many language implementations parse & then pass things on to an infrastructure (gcc or LLVM), so that's not unusual. PL/I is complicated in part because of its baroque "automatically figure out all the conversions" rules. Ada in general makes you be explicit about types, so that is a non-issue.
- jmnicolas 6y ago> In my nativité I think you meant "naïveté", what you wrote translates to "nativity" :)
- specialist 6y agoFrom TFA: "Dewar personally told me that when implementing the GNAT compiler, whenever they looked at the language specification and thought it might be complicated to implement, they assumed they didn’t understand the language specification and looked for a simpler way to do it. This mindset that “there is probably an easy way to do this” seems to have been different from others, who seemed to assume that complexity was always an inevitable part of the job." I've been on the losing side of this battle my entire career. While I thought striving for simplicity was core to the job, it's only harmed me. Though it's nice to read about another person who apparently thinks like me. If any one needs me, I'll in the basement with my stapler, sipping my now cold coffee.