3 ms·
I spent a few years coding C after using C++. The cognitive load needed to keep code correct was crushing, and switching back to C++ was massively liberating.
by moloch-hai 4y ago
I spent a few years coding C after using C++. The cognitive load needed to keep code correct was crushing, and switching back to C++ was massively liberating.
I didn't code any memory leaks, use-after-frees, or buffer overruns, but the effort to avoid them was ever-present, a continual drag and distraction from what the code was meant to achieve.
- sakras 4y agoI guess it really depends on what your program is doing. In my system, everything I do is linked to how I use my memory and its layout (so much that I don’t use malloc/free, just my own arena allocator), so I wouldn’t be able to avoid thinking about things like this in C++ either. I can see how if you have allocation-heavy code that making them more convenient to use correctly would be nice, but for me “allocation-heavy” is an anti pattern anyway.
- moloch-hai 4y agoMalloc misuse was just the tip of the iceberg, as regards cognitive load that C imposes to maintain correctness. Those are just the most visible.