[HN Gopher] Lessons from Writing a Compiler ___________________________________________________________________ Lessons from Writing a Compiler Author : zetalyrae Score : 33 points Date : 2022-07-14 20:09 UTC (2 hours ago) (HTM) web link (borretti.me) (TXT) w3m dump (borretti.me) | _dain_ wrote: | What does the Austral language bring to the table? Are there code | examples? | tekknolagi wrote: | You might enjoy a read through the programming language's | website. I certainly did. | | https://austral.github.io/ | | The spec has some nice code snippets: | | https://austral.github.io/spec/ | zetalyrae wrote: | You can think of it as either "Rust: The Good Parts" or "Modern | Ada". It's a minimal language with linear types, capability- | based security, an Ada-inspired module system, and strong | typing. And it's designed with simplicity as the overriding | goal: it's small enough that it fits in your head, and avoids | becoming the Vasa[0]. | | By way of example: the borrow checker in the Rust compiler is | 24.7k lines of code[1]. Austral's equivalent is 600 lines, | because it's simply doing less. The linear type system is | designed so that the rules fit in a page of text, and you learn | them once and apply them everywhere, rather than fighting | against an ever-changing, opaque pile of heuristics. It's much | more like a normal type system and much less like static | analysis. | | There are a few example programs in the compiler repository[2] | and the website[3]. | | [0]: https://www.stroustrup.com/P0977-remember-the-vasa.pdf | | [1]: https://twitter.com/zetalyrae/status/1540883027743559682 | | [2]: https://github.com/austral/austral/tree/master/examples | | [3]: https://austral.github.io/examples/ | tsegratis wrote: | That was a useful write up, thanks | | It's more unusual to find writeups on implementation of semantics | or typchecking, but as you say, more important | | Keeping the env flat, and like a relational database (for | typechecking) sounds like an idea i will take | tester756 wrote: | >The prototypical compilers textbook is: | | Dragon Book? | [deleted] | astrange wrote: | Yes, which is why it's a bad book and you shouldn't tell people | to read it. Actual compilers tend to handwrite their parsers | rather than using theory; parser generators aren't good at | recovery and error messages. ___________________________________________________________________ (page generated 2022-07-14 23:00 UTC)