4 ms·
The use of manual memory management increases the cognitive load when reasoning about software. Working memory capacity varies considerably between people and i
by jandrewrogers 2y ago
The use of manual memory management increases the cognitive load when reasoning about software. Working memory capacity varies considerably between people and is a performance limiting factor when designing complex systems. You see analogues of this in other engineering disciplines too.
Over my many years of working in software development I have come around to the idea that most software developers do not have sufficient working memory capacity to reason about memory management in addition to everything else they must reason about at the same time. They may know mechanically how to properly do manual memory management but when writing code they drop things if they are juggling too many things at once mentally. It isn't a matter of effort, there simply is a complexity threshold past which something has to give. Automatic memory management has its tradeoffs but it also enables some people to be effective who otherwise would not be.
On the other side of that you have the minority that get manual memory management right every time almost effortlessly, who don't grok why it is so difficult for everyone else because it is literally easy for them. I think some people can't imagine that such a group of engineers exist because they are not in that group and their brain doesn't work that way. If you are in this group, automatic memory management will seem to make things worse for unclear benefit.
I've observed this bifurcation in systems software my entire career. In discussions about memory safety and memory management, it is often erroneously assumed that the latter population simply doesn't exist.
- mattpallissard 2y agoI think the rift comes from people thinking manual memory management is a bunch of random allocs and frees all over the place. That is gross and those of us who don't mind managing memory don't like it either. Personally my gripe is when people don't think about memory or space complexity at all. I don't care if it's a custom memory management strategy or GC'd language, you need to think about it. I have the same gripe about persistence, socket programming, and database queries. Abstractions are great, use them, love them. But understanding what the hell they are doing under the hood not only improves efficiency, it prevents bugs, and gives you a really solid base when reasoning about unexpected behavior.
- danielledias204 2y agoBut for most developers using GC (Garbage Collected) languages, not understanding these concepts does not affect their ability to earn a salary and continue working.
- mirsadm 2y agoAny professional developer should understand these things. It was taught at first year of my computer science degree. As you say it isn't particularly difficult if you have a strategy. If you can't manage memory then what about any other resource that needs to be manually closed (sockets, file handles etc ).
- da_chicken 2y agoI'm not sure I understand the causal link between something having a proven track record of being error-prone and not understanding it.
- prerok 2y agoThe problem is that automatic memory management means to some newcomers that you don't have to worry about it. Which is not true at all. These newcomers may have heard about it, may even understand it at some level, but it's not in their rote knowledge. GC is great if you know that every allocation you do is expensive and that you know that it will be taken care of properly, because it will be short-lived. But I have seen many cases where people just don't have it in their conciousness why allocating huge arrays is a problem or why allocating a new Character object for every single character in a string might be bad. As soon as I point it out, they get it, but it's not like they thought of it while writing their algorithm.
- Dylan16807 2y agoIf the automatic allocation tools are good, then they're doing the same thing as quality manual management but with much more compiler enforcement.
- 2y ago
- fragmede 2y ago> Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -Brian Kernighan.
- fransje26 2y agoI fully agree, and I've learnt that humbling lesson the difficult way. The transition from "I'm elated and proud of the clever solution I wrote" to "I'm too dumb to debug this so I have to rewrite my not-so-clever solution" was sobering. :-) We live and learn.
- hinkley 2y agoEven if you understand every bit of the code, when obscure bugs pop up you have to consider the whole system, and that will quickly overwhelm most people. That’s how pernicious bugs stick around for ages and make the team look like idiots. Sometimes all you can do is refactor around the problem until you can see it. Or push people to stop being that sort of clever in the first place and write more accessible code.