Yesterday, after a long day of my day job, in which I spend all of my
time either hacking in Typescript and React or doing a lot of dev-ops, I
decided that I was finally gonna sit down and write a little Rust. I
picked a project off my stack: "Rewrite the Unix
locate program in
Rust." The last time I had tried this, my brain didn't work at all.
Both of the original versions of this program were in 90s-era C, the sort of code where function names appear mysteriously and without warning (or IDE support), where mutation is everywhere and controlled by nothing at all. Now, I lived and coded through the 90s, making contributions to a number of open source projects (the most famous of which, and which is still very much in use, is the Apache web server), so this sort of C used to be normal and natural for me.
But the last time I tried to do this was about nine months ago, when the company I had been working for folded. I was between doctors with my ADHD treatment, and it was the middle of the pandemic. I couldn't understand a word of it. Lines of code would just slide off my attention span without registering.
Yesterday, I had absolutely no trouble reading that code. It all made
perfect sense to me. I ripped through my understanding of both the
updater and the client for the
molcate version in about half an hour,
and a half-hour after that I had a very (very!) simple test case that
opened the database file, read the database header, and asserted that
the versioning information was present and correct.
I had to look absolutely everything up: the syntax and semantics of opening a file in Rust, of reading a file in Rust, of doing byte conversions in Rust. It was both awful and yet amazingly enlightening: the semantics of Rust itself were still deeply embedded in my brain, and I had no problems at all with the fairly simple memory management issues I faced just allocating a buffer, populating it, and analyzing it.
I have a job now, I have been fully vaccinated, and I have a new ADHD doctor who's put me on a slightly different medication regime, and it's made a huge difference. Anyways, I have a repo, but there's nothing there to see quite yet, just the binary header reader and a single test case. But it's good to have the repo anyway.