|
|
|
|
|
by thinkski
1644 days ago
|
|
In embedded systems, space can be a premium (e.g. a recent project has 75MB for a rootfs). With C++, need to link to libstdc++ and libc, with C only need libc. I find a number of developers reach for C++ because they aren’t comfortable with C or low-level development. For instance, will copy memory into a std::vector or std::string just to use the STLs search functions where a simple finite state machine would be more appropriate. I also find a correlation between C developers having a better understanding of things like file descriptors, poll/select/epoll for an event loop, while a C++ developer is more likely to use std::thread and then have to deal with proper locking. Working in a constrained environment, I like C exactly because it “does less”. It’s more explicit, simpler, hides less behind abstractions in practice. |
|
The STL was specifically designed so that pointers are iterators and you are able to pass a pair of pointers to pretty much any STL algorithm. This you should never need to copy memory into a container such a vector or string to be able to use the STL algorithms.