Building compilers & interpreters in Rust

Joined April 2025
3 Photos and videos
As a Rust enthusiast, as I learn more about Rust, I wish I had been a C/C programmer first.
9
Yeah, I watched it. But the irony is, Rust does this for you. 50% of this talk is about data alignment in your data structure. If you are using Rust, then most likely you don't have to worry about it. That means Rust will rearrange your data from largest to smallest to pack data efficiently. Unless you are using "repr(C)", Rust will not change your data alignment. But, as Andrew said, if your language does this for you, here is your explanation to understand how it is done behind the scenes. And I highly recommend this talk if you're into system programming. #rust #rustlang #SIMD #memory
I don't watch many talks but Andrew Kelley's "A Practical Guide to Applying Data Oriented Design" had a big impact on me. First watched it right around when I started working on Ruff.
1
48
Oh! I forgot. If you want a better and deeper explanation of data alignment in Rust, please read Chapter 02 of the Rust for Rustaceans book by @jonhoo.
8
My Current Reading List: 1. The Crafting Interpreters (currently reading) 2. Operating Systems: Three Easy Pieces 3. Rust Atomics and Locks 4. Bootstrapping Computing 5. The Making of Prince of Persia 6. The Art of Computer Programming 7. The Unicorn Project & The Phoenix Project (not sure yet) I will be extremely happy if someone or some company sponsor me some books.
1
5
1,031
13. High Performance Browser Networking
1
90
14. Data-oriented design: software engineering for limited resources and short schedules
1
Here is a roadmap, if you are interested in compilers and interpreters: - Let's Build A Simple Interpreter by @rspivak: Absolutely best resources for beginners, and will teach you about lexing, parsing, ASTs, and semantic analysis. - Crafting Interpreters by Robert Nystrom: Best book to master interpreters. - CS 4120: Introduction to Compiler and CS 6120: Advanced Compilers: Can't say anything about these because not personally tried them, but I have these on my personal roadmap - Beginner's Guide to Linkers: Again, haven't tried this one, but have it on my personal list While there are other helpful resources to learn more about compilers and interpreters, but, after these, you should focus on building things instead of covering more resources. These will be enough for you to learn to build compilers and interpreters. One more thing, if you are going to use LLVM for your compiler backend, I think you should follow the basic LLVM tutorial on the official website, i.e. "Kaleidoscope: Implementing a Language with LLVM." If you need any links or have any questions, feel free to drop them below. #Compilers #LLVM #Interpreters #Programming #LanguageLearning
109
I am starting a new project. A Simple TypeScript Compiler in Rust. After getting a handful of experience working with parsers, lexers and ASTs, I am pritty confident to move to building simple compilers. Privously, I started implementing a simple Pascal interpreter in Rust by following a great article series by @rspivak. This article series was a gold mine for teaching me about parsing, lexing, and semantic analysis. Even though I'm not done yet (currently at part 13), I am starting this project beside it. (I promise to @rspivak to complete his article series.) In this project, I will implement a simple compiler in Rust that can compile a subset of TypeScript to 32bit ARM assembly by following the book "Compiling to Assembly from Scratch". The simple or subset of TypeScript includes: - arithmetic and comparison operators - integer numbers - functions - conditional statements and loops - local variables, and assignments - and more If you need any kind of links or have any questions, please let me know. #Rust #TypeScript #Compilers #TypeScriptCompilers #RustCompilers
90
In Rust, you can't return dynamic types from a function. It has to be concrete. But sometimes, you want to return two or even three different types of data based on some conditions. In that scenario, you can use enums. Here is an example from my today's work: I was adding support for real data types to my interpreter. Now, my expression evaluation funtion have to return two types of data, i.e. either an integer or a real. But Rust can't do that. So, I have to extract those values to an enum and use that enum as a return type. Simple and easy fix for this kind of scenario. #Rust #DynamicTyping #Interpreters
10
Recursive descent parsing is all you need.
8
The simplest yet most powerful advice you can get. By @rspivak
1
1
175