Story Details

  • I wrote my own “proper” programming language (2020)

    Posted: 2025-01-22 09:54:25

    Mukul Rathi details his journey of creating a custom programming language, focusing on the compiler construction process. He explains the key stages involved, from lexing (converting source code into tokens) and parsing (creating an Abstract Syntax Tree) to code generation and optimization. Rathi uses his language, which he implements in OCaml, to illustrate these concepts, providing code examples and explanations of how each component works together to transform high-level code into executable machine instructions. He emphasizes the importance of understanding these foundational principles for anyone interested in building their own language or gaining a deeper appreciation for how programming languages function.

    Summary of Comments ( 13 )
    https://news.ycombinator.com/item?id=42791036

    Hacker News users generally praised the article for its clarity and accessibility in explaining compiler construction. Several commenters appreciated the author's approach of building a complete, albeit simple, language instead of just a toy example. Some pointed out the project's similarity to the "Let's Build a Compiler" series, while others suggested alternative or supplementary resources like Crafting Interpreters and the LLVM tutorial. A few users discussed the tradeoffs between hand-written lexers/parsers and using parser generator tools, and the challenges of garbage collection implementation. One commenter shared their personal experience of writing a language and the surprising complexity of seemingly simple features.