On Wed, 19 Feb 2025 15:58:48 -0000 (UTC)
Post by M***@DastardlyHQ.orgOn Wed, 19 Feb 2025 16:43:27 +0100
Post by David Browncontinuous supply of people who can write good C code. Far too many
people who program in C don't do so very well - those people would
be better off programming in some other language.
Often they're C++ programmers who didn't start out in C and so never
had to learn the messy world of pointers, managing memory yourself
with malloc+free, writing your own containers from scratch (the
number of times I've had to re-implement a doubly linked list when
using pure C back in the day I've lost count of), varargs (though I
still use them in C++), scanf() etc.
scanf() is as bad idea in C as it is in any other language.
When in C, always, but always, use strtol/strtod instead. Did I say
"always"?
std::from_chars() family, relatively recently added to C++ is a little
better functionally (not infected by locals), but worse because of
religious decision to use polymorphism in interface. Another minor
defect is use of reference.
Reimplementing double-linked list is fine if all you need is
double-linked list. It does not take more than 20 minutes and typically
you end up with code that fits requirements better than when you
take it from somebody else.
Now, std::vector is a different story. It has real value and not
worth reimplementing. And not only due to functionality it provides,
but but also because people that read your code has easier time
understanding your intentions. Even more so std:map/std::set and
std:unordered_map.