Boost Productivity with Rust
Tags: rust, productivity, programming, codenewbie
Published: 2021-05-14 22:44:07

I know the title is going against what most of you heard about Rust. Rust, despite being known as the most loved programming language, is also known for its steep learning curve for new developers (Many, including myself, had been curious as to why a cryptic language like Rust can at the same time be most loved by its users). Talking about boosting productivity with Rust, let alone a strongly-typed language, seems like a stretch. But hear me out...

High-level programming languages, since the dawn of C and COBOL, all were created with a similar goal--programmer's productivity above the machine's performance. If this wasn't the case, we would all be merrily writing apps in Assembly. Just like computer design, programming language design is and has always been an exercise in trade-offs. When C was created, it wanted to overcome the extremely buggy Assembly code, while trading off some performance (In theory, a well-written C code can never be as fast as a well-written Assembly code!), but it never went quite high enough to eliminate pointer bugs. Java Virtual Machine was created with portability in mind, but at the cost of performance and complexity. Ruby traded everything for expressiveness and productivity, while Python traded everything for a promised simple, one-way-to-do-thing language.

Every language compiler, runtime, interpreter shares a similar goal of helping human users in the computer-human relationship. But like I said, they traded off a few things here and there for a "punchline" feature.

Rust, arguably trading off simplicity with its initial learning curve, puts you in the driver's seat, equipped with a very smart driving instructor riding shotgun. It is the only language I know of that had achieved a very high level of abstraction without trading off the benefit of being closer to the bare metal (zero-cost abstraction). That means once you've become fluent in Rust, you will be writing uncompromisingly fast program by default.

When you started out learning Rust, you need to adopt a mindset that you aren't alone in this human-computer relationship. Rust compiler can help you tremendously in learning your mistakes like no other compilers I've come across. Trust me, the bottom line is--Run `cargo check` often and early. Let Rust helps you. Because the compiler check is so accurate it is basically mentoring you.

I, like many, have had a somewhat "on-and-off" relationship with Rust. Because Rust is relatively new, most can't use it in their professional work yet (an early-stage start-up company where I used to work at had once cast a vote between using Go and Rust, and we went with Go). I have been dabbling in Rust for many years now, very often in streaks, followed by a long pause. You have to think this kind of learning shouldn't accumulate well.

Surprisingly, every time I revisited Rust, I found myself being better at it. Sure, it took time to brush up, but what was a week has shortened to days, and then to a day, recently. This type of residual, accumulative knowledge that spans over time has never occurred to me before in any programming language I've ever learned. Some languages are designed to be simple and monotonous that my brain could not easily form nodal connections for the knowledge I gain from using them, while some are too complex that my brain just runs out of different ways to comprehend them.

> ... This variety of Ways to Think must be such a substantial part of what we call "intelligence" that perhaps we should call it "resourcefulness".

> If you "understand" something in only one way, then you scarcely understand it at all--because when you get stuck, you'll have nowhere to go. But if you represent something in several ways, then when you get frustrated enough, you can switch among different points of views until you find one that works for you!

-- Marvin Minsky, [The Emotion Machine][1]

Every one of us has several different ways to learn and "grok" something, and when one way doesn't lead to an understanding, we simply keep switching to another one. This is how we learn. When we run out of these ways, we simply quit. Rust, it appears, can fit into different ways of thinking. This what makes learning Rust continuously over a long period of time possible and enlightening.

As someone who had worked with many programming languages, I think anybody with some programming experience can be productive in after the initial hurdle. Being productive in something doesn't mean being an expert in it. It simply means one isn't hitting the road block every five minutes. If you're thinking of a new language to learn or for your company product, choose Rust. Developers want to use Rust, and recruiting for a Rust position (with some leeway for initial learning, of course) can go a long way in terms of scalability, maintenance, and foremost human capital. This is because once you've learned Rust to a point of productivity, you get an automatic pair-programmer--the Rust compiler. 

It definitely feels like I'm pair-programming all the time in Rust, and it doesn't get more productive than that.

[1]: https://en.wikipedia.org/wiki/The_Emotion_Machine