3 ms·
I usually like matklad's writings but I have to be overly dismissive for a change. This is a skill issue. C, C++, Rust, it doesn't matter - if you have a syst
by duped 2y ago
I usually like matklad's writings but I have to be overly dismissive for a change.
This is a skill issue.
C, C++, Rust, it doesn't matter - if you have a systems problem where you are concerned about resource constraints and you need to care about worst-case resource allocation, you must consider the worst case when you are designing the program. RAII does not solve this problem, it never did, and anyone who thinks it does needs to practice programming more.
It is not "hard" to solve though. It's just another thing your compiler can't track and you need to be reasonably intelligent about. There are sections of a program that cannot tolerate resource exhaustion, for which you set some limit, which is then programmable in some way, which then uses some shared state to acquire and release things of which RAII may help. But you still must handle or otherwise report failures.
This is a bread and butter architecture concern for systems programming and if you're not doing it, get good at it.
- flohofwoe 2y agoJust like writing memory safe code in C is a skill issue right? ;) (I write mostly C code myself, but I'm also not immune to f*cking up now and then even though I write code for decades now).
- dapperdrake 2y agoASCII NUL terminated strings and double free don’t sound quite the same as gauging hardware requirements. Either you need a certain amount of memory or you don’t.
- writebetterc 2y agoYou sure can write C which makes you less prone to making memory safety mistakes, yes. Knowing how to do that is a skill issue. As you say, sometimes our skills fail us, and that's where tooling comes in. ASan, borrow checker, whatever. There's a reason that a lot of Rust programmers find their programs filled with Arc<Mutex<T>>. That's because they didn't have the skills to write memory safe systems programs in the first place. To be clear, of course I'm also not immune to fucking up :-).
- dzaima 2y agoAs long the language in question is turing-complete, everything is equally a skill issue.
- dapperdrake 2y agoNo. You seem to be thinking about computable functions. Not hardware dimensioning. It’s about resource usage on a finite physical computer. A Turing machine has a countably infinite tape.
- dzaima 2y agoYeah, I was being overly dismissive of your comment :) But beyond obvious hard differences in what languages in question allow about a given topic (of which indeed there are none between C/C++/Rust/Zig on the topic of memory utilization & co), everything is still just a skill issue. More seriously, afaict the article in no way even mentions RAII solving anything about resource constraints (not even as a hypothetical thing to disprove); only about RAII simplifying doing basic management logic (at the cost of worsening reasonability about resources!). Thinking about resource constraints is unquestionably harder than not thinking about them, which is what the article is about.