#crafting interpreters    	#garbage collector    	#interpreter    	#lox    	#memory management    	#mark and sweep    	#programming language

Crafting Interpreters with Rust: On Garbage Collection

submited by
Style Pass
2024-07-27 12:30:05

#crafting interpreters #garbage collector #interpreter #lox #memory management #mark and sweep #programming language #reference counting #rust #unsafe #virtual machine

I became interested in implementing programming languages a few years ago and discovered Crafting Interpreters by Bob Nystrom. At the time, I had experience with Rust and decided to use it to follow the book. Albeit, being a noob, I managed to implement a fully functional bytecode interpreter that supported every feature of the Lox language as described. However, my implementation suffered memory leaks due to reference counting. Back then, I didn’t fully grasp Rust to design and implement a proper garbage collector (GC)! Now that I have more confidence in the language, I decided to revisit the project and improve its memory management scheme.

As for the goals, I aim to implement a mark-and-sweep GC that is on par with the C implementation. You probably guessed that lots of unsafe statements will be thrown around. If you have the ick for unsafe, look elsewhere. Although I’m not an expert on this subject matter and might make many mistakes, I hope you’ll find something useful here.

Leave a Comment