Posts with the tag Rust:

Rust vs. Zig and testz

Earlier this year I made the switch from using C++ on my hobby projects to trying out Rust. I spent about 6 months of hobby night-time programming time porting over my 2D game engine and the bulk of my 6502 CPU emulator project. There are a lot of aspects of Rust that are great, but I got tired of fighting the borrow checker left and right. I still feel like I have a hard time expressing myself in Rust.

I had heard about and looked at the Zig programming language before and really liked some of its core concepts such as comptime for doing meta-programming in a much cleaner way than I’ve seen before. This was back when it was around 0.7 and it was pretty rough around the edges in many other areas though.

I had another look towards the end of summer and found with version 0.11 it struck a chord with me and I’ve been using it ever since, getting further into a new porting exercise for my 2D game engine and 6502 CPU emulator in less than half the time it took me in Rust. I also wrote a small unit testing library for Zig called testz to improve my testing development flow.

Rust unit test layout

I’ve been succeeding in my fourth attempt at learning to use Rust. I come from mostly a C++ background, and I’ve struggled the first couple of times I’ve tried to pick up Rust, ultimately stopping the effort to work on the next shiny quarter. I started porting over my Nintendo 6502 processor emulator from C++ as a larger project to play around with. One thing I had done in the C++ one is have tons of tests for the different instructions - checking clock cycles and internal register states for the emulated CPU.