Feel like everyone’s been telling me it’s the best thing since sliced bread. I’m just a hobbyist with like a single big project I’m maintaining but I’m starting to hate the code and idk maybe I should rewrite it in rust. Idk
Feel like everyone’s been telling me it’s the best thing since sliced bread. I’m just a hobbyist with like a single big project I’m maintaining but I’m starting to hate the code and idk maybe I should rewrite it in rust. Idk
You might want to take a look at C/C++ again at some point, you didn’t mentioned a single thing that I expected, I expected you to complain about memory allocation, double frees or stuff like that, instead you touched on lots of very accurate pain points for C/C++ that people who use it for years feel.
#ifdef _WIN32
, macros will change the code before it gets compiled, so they allow you to write meta-code, as in code that writes code. Rust takes this to a whole new level, so you might want to understand the basic concept before looking into advanced Rust. That being said, I don’t think these are complicated in and of themselves, nor do I think you’re having problem with understanding what they mean, and it’s more likely a question of why, and the answer is that some stuff should happen at compile time, e.g. checking if you’re on Windows or Linux do define how you deal with paths or something. But the same can be extended to knowing if a given feature is enabled so you can compile only parts of the program. The lack of package manager is a pain, but C/C++ predate lots of those concepts, and there have been lots of attempts. Also if you’re using Linux your system already has a package manager so using some common standard like CMake for your projects makes it all “just work” (most of the time)… But yeah, this one is a pain, no question about it, and Rust solved it properly.my_str += "something"
sounds like a very simple thing, but under the hood you’re allocating an entire new string, copying the content frommy_str
into it, appendingsomething
and then deleting the old one. C forces you to do that stuff manually so you have to be conscious of what you’re doing, string operations are not cheap, and you can gain a lot of performance by simply preallocating all you’ll need from the start. Rust is similar here, while they do have a String type, they make a very big difference between it and a slice of a string, so that makes you conscious of when you’re doing heap stuff.I spent years with C/C++ as my main language, and I can tell you that I would also not choose it for a random project. However I would also most likely not pick Rust either. Python is my go-to for “I need something quick”. Rust would be my go-to for “I need something robust”, or “I want to make sure this will work as intended”, it will mean a more tedious development cycle with a very slow iteration (much slower than C/C++, e.g. adding an enum value can mean lots of fixes on Rust, because most places where you’re dealing with that enum would fail to compile because you’re not taking the new value into consideration), but it will mean that every step will be solid (if it compiles after adding an enum value, I’m sure it’s being considered).
Do learn Rust, it’s fun and personally I see a LOT of future in that language, but it also abstracts some of the concepts away while still requiring you to know them, e.g. heap/stack. I think learning C/C++ for the core concepts is better, but if you know those concepts Rust is a better language overall.
Thank you for your wisdom. I hope one day I can be as knowledgeable as you people.