Easter Bunny Day
What a reversal of weather in such a short period of time! It seemed like it was going to be a gradual thawing of Spring from last week, to an instant summer beach-and-bikini weather right now.
But it all has to happen while we’re locked in and unable to go out.
It isn’t a total lockdown, in the sense that one is still able to walk within a 2km radius in the neighbourhood. Which is good enough for me. In fact, just one hour in the sun today seemed like it’s a little too much, and I ended up heading home for some indoors entertainment instead.
Home or away, it’s still a long weekend holiday. Doesn’t bother me much, as the activities that I’m into lately are largely sedentary. On the flip-side, I actually have to actively think about getting out of my chair and get some workout.
So the beacon of gold-standard in handling the COVID-19 crisis has faltered; the containment process has gone sideways, and there’s a resurgence of community spread going on at the moment. It’s one of those genie-in-a-bottle situations: once out, it’s hard to put back in again.
This has led to an increased level of isolation measures imposed, or what the government termed the ‘Circuit Breaker’. Or ‘CB’ for short. ‘CB’ means quite something else colloquially, something you don’t say in polite company, but quite aptly decribes the situation we’re in ;)
Most of the SGinternets is having a field day out of being able to use as double-entrandes in official communication, such as:
“Boss ask me to go work, but cannot, I’m in CB right now”
“Eh, CB, cannot anyhow go out!"
… so on, and so forth.
Best Burger Ever!
The Girlfriend said that I made the best burger ever! (See featured image)
Ok, she didn’t actually say that…
But, it was darn tasty. We liked it enough that each of us scoffed down two for lunch, and ended up skipping dinner from overeating.
Some Rust Programming
After finishing the Rust book, I have been dipping my toes into Rust programming the last two weeks, and my verdict is quite positive.
First thing off the bat, completing the book helps. In fact, I’ll put it down as a must. When I thought of learning it last year, I had the notion that ‘it’s just another language’ and that I’ll just pick it up as I go along. In addition, having a mistaken sense in believing that with the experience I had under my belt with unsafe languages like ‘C’ and ‘C++’, it couldn’t be any much harder to learn a language with implicit memory safety, compared to them?
Turns out, I’m dead wrong. Not understanding the basic concepts with borrowing, lifetimes, meant a constant fight with the borrow-checker, and not understanding the (generally helpful) syntax errors. But that did put me off in thinking that Rust was complicated for no good reason, and I gave it up after some tinkering.
But learning it was still an item on my wish-list, given that I wanted to go back to writing systems-level code, which I hadn’t been doing ever since my new job.
Reading the book made clear these concepts, and the rationale behind them. Armed with that understanding, it made so much easier to understand what to do, and what the borrow-checker is warning me about.
There’s a few takeaways that I had from Rust that made me feel that it’s a game-changer:
- It may be a systems-level language, but they made it so easy that it can easily be used in replacement for scripting languages;
- The code and constructs makes it so much better for detecting errors in code, compared to C/C++;
- While it has no Garbage Collector, it doesn’t it have memory problems like use-after-free, or invalid pointer deferencing for example;
- The thread-safety constructs in Rust is a cut above any other general purpose language;
- Package bundling, and library dependencies are such as breeze. I don’t have to
pkg-configor whether if I’ve gotten the right path/version/ABI to link, and all those malarky.
These years, there’s an increasing sense that most managed languages are wrong with the idea of a Garbage Collector. It’s erroneous to believe that the responsibility of memory management can simply pushed from your everyday Joe-developer to just a few bright sparks tackling it, without context of what the application is doing.
The notion has been a flawed since the beginning - the fundemental problem
of memory exhaustion doesn’t go away just because you got rid of
Bad code still causes
OutOfMemoryErrors, just delayed (and harder to spot!)
On top of that, the GC introduces new issues like collection latency, violating real-time requirements (even in G1), ever-increasing collection times, due to the abundance of cheaper memory - things that you never had to deal with before.
These problems aren’t hypothetical, and are especially pronounced in enterprise deployments where huge memory usages are norm. Coupled with 2 decades of not having to worry about memory allocation, it leads people to write applications without concern for huge transient memory allocations, cos ‘the GC will take care of it’.
The GC is a huge anti-pattern that the whole enterprise computing industry has dug itself into. And I guess I’m cranked up with that because this is a reality that I see daily when dealing with the software stack at work.
I think reference-counting is the right paradigm and that developers have to take responsibility of memory usage, just that C++ just offered the wrong set of ergonomics for it. Rust definitely gets more of it right, and TBH, actually makes it easy for a general developer too. In fact, a novice, when primed with the right concepts from the start, probably will make faster headway that someone like me who has to make a mental shift and throw out the old for the new.
This week, I’ve finished my first application in Rust, and enjoying it.