Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I recently started a project in pure C (coming from writing C++ professionally for a few years). I love it. Honestly, the biggest advantage for me is the massive reduction in mental overhead. In C++, every single line introduces something to think about: is this a reference or a value? Does this incur a memory allocation? Is this copy expensive? Has this been moved from? It’s all a huge mess.

Contrast with C: none of these problems exist (well, maybe the copy one if the struct is big) I can focus on implementing my design, even if it does take a bit more typing.



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.


I 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.


Malloc misuse was just the tip of the iceberg, as regards cognitive load that C imposes to maintain correctness. Those are just the most visible.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: