5 ms·
This article breaks it down well enough to make me feel like I could write my own C compiler targeting AVR. (I probably could... but it would not be easy.) Nev
by Liftyee 1y ago
This article breaks it down well enough to make me feel like I could write my own C compiler targeting AVR. (I probably could... but it would not be easy.)
Never actually looked into how compilers work before, it's surprisingly similar/related to linguistics.
- measurablefunc 1y agoIt's b/c when Chomsky invented the theory of formal grammars he was studying natural languages & the universality of abstract grammar¹. Computer scientists realized later that they could use the same theory as a foundation for formalizing the grammatical structures of programming languages. ¹https://en.wikipedia.org/wiki/Chomsky_hierarchy https://en.wikipedia.org/wiki/Chomsky_hierarchy
- lukan 1y ago"compilers work before, it's surprisingly similar/related to linguistics." Since compilers transform languages with a clearly defined grammar ... the connection to linguistics is maybe not so surprising after all.
- dekhn 1y agoSimilar experience in DNA/genome analysis. A large part of DNA analysis was based on parser theory. This paper was my introduction to DNA analysis as well as Chomsky hierarchy: https://www.jstor.org/stable/29774782 https://www.jstor.org/stable/29774782 (I wasn't able to find a free copy). IIRC, pseudoknots in RNA require context-free grammars to parse.
- userbinator 1y agoYou should study C4, which is a C(subset) compiler in ~500 lines, but more interestingly, it can compile itself: https://news.ycombinator.com/item?id=8558822 https://news.ycombinator.com/item?id=8558822