3 ms·
I personally found it very relieving when I switched from C++ to C. (and I also rewrote some stuff, it did not get more complex.) I find readability of modern
by uecker 4y ago
I personally found it very relieving when I switched from C++ to C. (and I also rewrote some stuff, it did not get more complex.) I find readability of modern C code much better than C++. In C you see what you get: no templates, overloading, virtual inheritance, namespaces, exceptions, references etc you need to keep processing in your head just to understand what is going on.
- wizofaus 4y agoI don't doubt that can be true - but there are plenty of common operations like concatenating strings or converting between strings/numbers that are a good deal simpler to write and understand in C++ than they are in C. In particular there are far more ways to get them wrong in C!
- uecker 4y agoIf you code them by hand, then yes. If you a library, then it is the same. It is certainly true that the C++ standard library provides more functionality out of the box.
- wizofaus 4y agoAlmost any C library function that deals with strings is going to be more complex to use due to the lack of automatic memory handling, necessary for any use case where the max. size isn't sufficiently well-known at compile time for it to sit on the stack. I'd accept something like "atoi" or "strtol" is pretty simple to use (and hard to get wrong), but hardly win any awards for obviousness. And the less said about the need (or at least strong tendency) to use sscanf for more complex parsing (hexadecimals etc.), the better.
- uecker 4y agoA library can do the memory management for you: string a = string("test"); string b = string(" this"); string n = string_concat(a, b); ...
- another2another 4y agoI started doing this a bit myself too, but soon found that I missed RAII too much. Having things clean themselves up when going out of scope is very convenient, and means that the early return code style that I favour is much easier to implement.