lp0 on fire

My personal blog

Programming: Thoughts on Rust

Recently an online friend of mine has been getting into Rust. He's kinda the opposite of me; acedemic mind and problem solving, likes to try new things and follows hypes. It's refreshing because we both have a different view from which we both learn. So naturally the language came up in our discussion.

Background

Initially my views on Rust were quite poor, I'm not a big fan of hyped-up things nor the very vocal fanboys the language has. People turn the words "zero-cost abstraction" into a buzzword without knowing its actual meaning. Somehow the borrow checker would be the saviour of us all and make our programs magically more secure. Not the developers but dogmatic followers claim Rust to be a C/C++ replacement and love to mention that their favorite software was written in the language. My impression was that most of these people trying out Rust come from languages like JS/TS, Python, Java, etc and not system languages like C/C++.

I often hear claims like the following online:

No matter how brilliant of a developer he is, can hope to write safe C/C++ programs that are reasonably large, even if they use all the sanitizers and linters in the world.

I know some who can and have done so. It's not impossible, but it takes talent and experience to do so. But while it's possible, it doesn't mean it's a good idea in any language.

Everyone can write complex software, it takes a genius to appriciate simplicity. Why not split up a large program into many smaller ones (aka the unix way)? Instead of trying to write clever code with many abstractions, why not aim for the simplest functional solution and optimize where required?

Thoughs

We sat down and compared differences between various languages and solutions, showed me some code and helped him with data-oriented design (he's used to object-oriented design and paradigms), poked some holes in the tooling, try to optimize the produced builds, and then discussed some more.

Rust to me isn't a C killer, but it does look and write lot nicer than C++. It's also gradually growing as big as rust with every new feature added. Personally I'm not a big fan of the label: type = value notation. I'm not a fan of package managers for programming either, so cargo doesn't float my boat. For some reason, the language also feels quite convoluted. I want to know the specs of a language from the top of my head, but with Rust it's been pretty rough. Maybe I need more time and pratice.

Some of the basic features feel questionable to me (why should enums have multiple types?). While the borrow checker has it's limitations, it does make it much more viable to maintain programs for enterprises (where bodies count more than experience). It's nice that cross-compilation works without a hassle but it does include the full runtime by default into your application (can be turned off though).

First I thought that forcing immutability was stupid, but after two weeks of writing and checking my own code, I realized how little I mutate my variables. Now I miss this in C. The short type notation (i32 vs int32_t) is really nice too. Building is pretty straight forward, and vscode intergration is good.

Conclusion

Overall it's a language that tries to innovate, which is pretty cool. It's also a nice system language for more commercial applications with reach for a wider audience of programmers. There is plenty to learn from in language design and tooling, but I don't think it's a language that suits my specific needs however. I can see the appeal and value and appriciate the effort put into it.