Ask Lemmy
A Fediverse community for open-ended, thought provoking questions
Rules: (interactive)
1) Be nice and; have fun
Doxxing, trolling, sealioning, racism, and toxicity are not welcomed in AskLemmy. Remember what your mother said: if you can't say something nice, don't say anything at all. In addition, the site-wide Lemmy.world terms of service also apply here. Please familiarize yourself with them
2) All posts must end with a '?'
This is sort of like Jeopardy. Please phrase all post titles in the form of a proper question ending with ?
3) No spam
Please do not flood the community with nonsense. Actual suspected spammers will be banned on site. No astroturfing.
4) NSFW is okay, within reason
Just remember to tag posts with either a content warning or a [NSFW] tag. Overtly sexual posts are not allowed, please direct them to either !asklemmyafterdark@lemmy.world or !asklemmynsfw@lemmynsfw.com.
NSFW comments should be restricted to posts tagged [NSFW].
5) This is not a support community.
It is not a place for 'how do I?', type questions.
If you have any questions regarding the site itself or would like to report a community, please direct them to Lemmy.world Support or email info@lemmy.world. For other questions check our partnered communities list, or use the search function.
6) No US Politics.
Please don't post about current US Politics. If you need to do this, try !politicaldiscussion@lemmy.world or !askusa@discuss.online
Reminder: The terms of service apply here too.
Partnered Communities:
Logo design credit goes to: tubbadu
view the rest of the comments
That depends from the language you're using now. To really appreciate and understand Rust's borrow checker you need to have some experience in C or similar language. For someone who have used only Python before Rust will look really weird and messy
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.
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.
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.