Of late, my main side project has been rug, a stripped-down Git implementation which I’m building in Rust. I’m following along James Coglan’s excellent book Building Git where he lays out how he went about building the same project, in Ruby.
<img src=”/images/rug-status.png” alt=”rug showing the (git) status for it’s own code repository” style=”width: 420px;”/>
In essence, my project boils down to porting James’s code[^fn1] into Rust. But why bother with this at all? After all, porting code from one language to another is probably not on your top ten list of cool project ideas. Building something new will always be exciting. But I do think that at least as far as personal projects are concerned, porting a piece of code gets a bad rap. They can be a great learning experience and while it may not match the thrill of starting something afresh, can be plenty exciting to work on.
Working to re-write a piece of software in another language is a great way to dive deep into how the project works. With Git, you learn how the files, directories and commits in a repo are stored as objects, what happens as you are staging each hunk of your work and how diffing works. And so much more. To be sure, you could read an article or watch a video explaining how any of these things work but grappling with actual code to implement a functionality will give you a far superior understanding of things.
Besides the technical nuances of the software’s functionality, porting code will also expose you to how the project itself is architected. What are the entities the project deals with and what is the high-level structure of the project? What layers are there and why is it layered this way and not some other way? These are problems you will face when working on your own personal and professional projects. Choosing a well-designed system to study and port can give you some new perspectives on how to think about such things.
Translating a project from one language to another can also be a great opportunity to get acquainted with a new language. I had done some Rust before working on rug
but this project has been large enough that I’ve been able to go deeper into both the language and the ecosystem. For example, the last two days I’ve been working on replacing the ad-hoc CLI argument parsing code with a wonderful Rust library called clap
. With Rust, there are plenty of new concepts, and sometimes it just takes some practice using it to get used to the language.
Hopefully, I’ve convinced you that choosing to port a piece of software as your next programming side-project is at least worth considering. As I said earlier, building something entirely new has it’s thrills. But diving into a codebase and understanding it deeply enough to be able to port it to another language can also be immensely satisfying.
[^fn1]: Which itself is a port(sorta) of the original Git codebase,
but this is not really relevant for this post.