17 ms·
> Maybe an experienced C++ coder can destroy my preconceptions :) - Generally C++ uses the OS-level package manager, like rpm or dpkg. It's not cross-platform
by humanrebar 9y ago
> Maybe an experienced C++ coder can destroy my preconceptions :)
- Generally C++ uses the OS-level package manager, like rpm or dpkg. It's not cross-platform and it doesn't have a nice interface in the source code (#include is... unfortunate), but there is a nice solution here if your organization has the discipline and tooling expertise to make it work.
- Template metaprogramming isn't bad to use at all. Everyone uses it every time they construct a vector<>. It takes a lot of skill to write, though, and unfortunately even users of TMP can end up with nasty and bloated compiler errors. Hopefully this will be addressed by "concepts" in forthcoming versions of C++, but it might be a while before that filters down to stable C++ compilers and libraries.
- The real issue that should scare you is something called "undefined behavior". It's very easy to do subtle things that cause you programs to break in weird and hard to debug ways. Nasty side effects that could theoretically include any side effect. Like saving garbage to your production database. By doing something as innocuous as overrunning an array.
https://kukuruku.co/post/undefined-behavior-and-fermats-last-theorem/ https://kukuruku.co/post/undefined-behavior-and-fermats-last...
https://stackoverflow.com/questions/367633/what-are-all-the-common-undefined-behaviours-that-a-c-programmer-should-know-a https://stackoverflow.com/questions/367633/what-are-all-the-...
There are tricks and tools to avoid undefined behavior, but I find that most C++ engineering orgs don't prioritize the tooling (linters, UB sanitizers, etc.) needed to let engineers do this productively. Consequently, a lot of writing good C++ involves detailed coding standards and/or very detail-oriented gurus poring over code reviews.
- taneq 9y agoYeah, undefined behaviour was my thought too. There's a few warts with templates etc. but undefined behaviour is the granddaddy of all skeletons on the linguistic closet. Realistically, C++ isn't actually a well-defined language unless you specify platform and language. You don't program in C++. You program in a C++-derived language jointly defined by the compiler and the hardware.
- marcosdumay 9y agoBesides the confusing error messages, C++ templates also tend to be weakly typed.
- missblit 9y agoAnd array over-runs are just the beginning! (friends don't let friends use idices over iterators) Had a fun bug at work once where we somehow accidentally built against two subtly incompatible versions of the same library. This actually mostly worked until some random virtual function call sometimes called the wrong function silently...
- entelechy0 9y ago> And array over-runs are just the beginning! (friends don't let friends use idices over iterators) It depends on the context. If the data-structure that you are iterating over gets mutated in the middle of iteration, it makes more sense to manually manage an index into that structure to avoid errors/exceptions. Iterators are great for simple iteration however.
- petters 9y agoYes, C++ without a monorepo is very difficult.