There's certainly a lot of interesting things happening with Rust but I'm one or two problems away from deciding that Rust isn't a viable replacement for the situations where I use C.
There's certainly a lot of interesting things happening with Rust but I'm one or two problems away from deciding that Rust isn't a viable replacement for the situations where I use C.
What I wanted from Rust was basically a strongly-typed C and more modern tooling. I'm open to more checking than that, depending on what cost it has.
What I'm getting is strong typing and more modern tooling--cargo, for example, is excellent. But the borrow checker is extremely invasive, and `unsafe` doesn't actually make it less invasive. There are a number of cases where I still haven't figured out how to get the compiler to not complain about the lack of a `.clone()`. Borrow semantics are... pretty good, as it's basically enforcing a pattern I use frequently anyway, but the exceptions to that pattern are critical and working around the borrow checker causes more problems than it solves. It's possible I just don't know how to make "the Rust way" more workable, but if that's the case I am having a hard time finding how what "the Rust way" is for the things I'm trying to do.
That said, I can see how Rust is a great tool for what it was originally intended for (writing a browser). That's just not what I'm doing.
Also, unsafe is not meant to ease the borrow checker pains, that's like using void* everywhere in C because you don't know how to type a function pointer. Unsafe is meant for places where rust simply doesn't know better, like reading memory mapped registers.
I have given it a very cursory look, but ultimately it doesn't fit my needs for reasons unrelated to the features of the language. Specifically, I'm releasing my C work under the GPL and would not like to write off the possibility of integrating into GNU. Zig doesn't have a GPL implementation (Rust has one which is committed to reaching maturity).
Eh, one could argue that some of these "Rust simply doesn't know better" situations are often borrow checker pains. But in general, I'd agree that bypassing the borrow checker doesn't seem to be the point of `unsafe` in my limited experience.
But the bigger point I'm trying to make is that there doesn't appear to be any solution to some of the borrow checker issues I've run into. There are things you can do in C, which are strongly related to the reasons I'm using these low-level languages, that appear to be impossible in Rust.
Keep in mind the caveat that I'm new to Rust, so there may be some solution I'm just not aware of.
Been there. You are not alone.