Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Lifetimes are present in pretty much every language - Rust is the only one that makes them explicit and statically checked through a pretty unique type system (usually they only live in compiler analysis passes). That's great because instead of reasoning about it implicitly like in C/C++, you reason about it explicitly. It looks messier but at least nontrivial program properties are spelled out in greater detail. Systems programming isn't a trivial task and Rust reflects that arguably better than C/C++ do. Rust will feel really nice if you come from the logic/theorem prover side of things (which imo is how programming should be taught).
I think Rust is great, not just because of the very nice, fresh ideas in the language but also because of the toolchain. It's such a pleasure defining a project and using libraries (and cross-platform dev) compared to C/C++. Also not having to deal with decades of legacy crap really does make it feel nice and fresh. -
CptFox16194yLifetimes are the most original post of Rust's type system, but also quite possibly the best. Being able to specify "I need this reference to stay alive for exactly that long" is extremely powerful, as is the fact that the compiler ensures that.
Rust can be overly pedantic at times, but most of the time, it is right and will beat memory safety into your skull to the point that, when back to C/C++, you'll just keep specifying lifetimes and ownership in comments.
The only thing I miss in rust compared to C++ is generic specialization, but I am hopeful that it will come to stable some wonderful day. -
whiskey08974yI find that C is better than CPP in most things and I find that rust is better than both when it comes to package management (cargo).
Rust is good because it comes with a lot of modern idioms. But, in my opinion, rust will always struggle to be adopted in the mainstream for one reason - new programmers will be turned away from the language because of its strict compilation rules. -
CptFox16194y@iiii About pointer lifetime and ownership? Since when? Please send a link because I am properly interested in that 'o'
-
iiii92194y@CptFox it started several years ago, if I remember correctly
https://isocpp.github.io/CppCoreGui... -
Haven't really done much Rust myself but solely it's build+ packaging system (cargo) is magnitudes better than whatever tools you may use for C++
-
iiii92194y@LotsOfCaffeine even Bjarne himself (the creator of cpp) thinks the same 😁 that's why modules are to come to cpp
-
@iiii the modules in Rust kinda confused me at first, I'm used to C#'s "compile everything and have namespace declarations in every file" approach
But just having a package manager is so important -
CptFox16194y@iiii Thanks. It still doesn't really help with structures with borrowed fields (without shared_ptr to do it at runtime), but I'm happy to have a standard for the rest of the cases.
Said structures with borrowed fields (such as iterators) are where lifetimes shine, and will shine even brighter when we get generic associated types and lifetimes on stable. -
C++ is "good enough" for the odd bits of dev I do. If I coded closer to the metal often though, I'd probably make the effort to learn Rust properly.
-
I feel that C++ has effectively become two languages—C with Classes and Modern C++. I gave up on Modern C++ eventually as I thought it was just easier to go all-in on Rust.
what are your guys' opinions on rust vs c++? I personally prefer rust. the only thing that I really struggle with in rust is lifetimes. I definitely feel that rust is more modern and it's pretty similar to c++ from what I've seen
rant