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
I used C++ and beriefly C before. I suck at both lol.
I get that manually managing memory can be a mess and easily create big problems. Garbage collectors seem like a cool solution but they need a runtime. Rust has no runtime but somehow forces you to manage memory well. Idk how.
But anyway more important to me is that it’s a modern language with good devex and tools and no runtime. So it’s like if C++ was remade today. At least that’s what I hope.
You tell the compiler which part of your code is responsible for each chunk of memory. Then the compiler gives you errors when you don’t respect that. Roughly.
Maybe check out Nim-lang? It does have mm (I hear arc/orc are good) though it can be turned off allowing you to manage memory manually.
If you suck at C, then switching to Rust will not magically change it. C is a small language and learning it is easier than learning Rust. Also, you probably suck at C++ because you started learning it before C.
Garbage collecting will make your life easier if you don’t need (or just want, as a hobbyist) fast code. It’s often worth it. Based on your other answers it sounds like you want the conceptual cleanness of not using it, though, which I totally get.
If so, Rust is the game in town right now. The caveat is that you might put all the effort in and still hate your code. And be even further away from finishing it.
It stuck around for decades because short of memory unsafety, there’s relatively few things wrong with C/C++. Rust was the first language that managed to do what Rust does, because it’s a hard problem. So basically, there isn’t any recommended third option.
The way human programmers think is very different from the way processors do. You either insert a runtime that can bring the two closer together, including garbage collection, or expose the difference to the coder. C exposes the difference as invisible memory leaks, segfaults and occasional undefined behavior. Rust exposes it as lifetimes and borrowing, with complicated enough rules most users just change things until it works.