4 ms·
I work on a project that is a c & c++ codebase where there isn't really a great reason for it being in those languages vs a language "with a runtime" the hate
by chrsig 4y ago
I work on a project that is a c & c++ codebase where there isn't really a great reason for it being in those languages vs a language "with a runtime"
the hate is pretty simple:
- compile times
- vague compiler errors
- template syntax is incredibly hard to read, especially when using techniques like sfinae, or trying to write functional interfaces
- really bad names for idioms (raii, sfinae, pimpl)
- really bad names for standard library types & functions
- truly arrogant community (notice how the boost website doesn't advertise that it's the easiest to use library -- it's the "most expertly designed")
- class member function declaration is out of control (`virtual const foo bar(const baz& x) const override`)
- defaults are unsafe (mutable by default)
- package management is a nightmare (i've only used conan, which is starting to mature, but still has a limited selection of packages, and seems to
constantly break how they do things...because package building for an ecosystem as wide and unstructured as c++ is an intractable problem)
- cmake is the worst dsl ever. the program itself is fine, but the dsl is the worst.
- footguns everywhere (auto vs auto&...but auto* exists, and isn't necessary)
- N different ways of initializing
- it's incredibly hard to teach
- inconsistencies w/ C (brace initialization w/ named fields)
- incredibly subtle things can have a huge impact (class member variable declaration order)
- no standard way to document classes & functions
there are still certainly use cases where it's worth using, but the hate is pretty straightforward to me: it's just more hassle than it's worth most of the time. and there is some inner language struggling to get out that's probably nice to use. There are some nice things about it: notably static destruction.
and yes, some of those are more ecosystem based / my own opinions / not necessarily "the language" -- and there are reasons for why many of the warts are the way they are (backwards compatibility, control over construction order). it's still a giant pain in my ass.
- UncleMeat 4y agoMany of these things are indeed true problems. But they miss the big one: C++ is just plain unsafe. Applications written in C++ that process untrusted input are serious security risks. The industry needs a path a future where no C++ code is processing untrusted input. Rust is (mostly) safe, but the path to shift gazillions of lines of C++ to safe Rust is painful.
- drawkbox 4y agoGood points though many platforms/languages have similar issues, just C++ has been around longer and has been used the most. C++ has always been a sort of peak language and probably always will be because like C, or machine code directly, everything else is built on it: virtual machines, apps, compilers, platforms etc at the root. C++ is one of those things that when you grok it and can ship with it, everything else is easier. The years I have spent on C++ I have enjoyed because everything else looks easier and how performant it is. It is fun to code in as well. There are many ways to do things in C++ and that is a feature. I also feel like people use less dependencies and do more custom code in it but that may just be a gamedev thing. I like that style over using thousands of dependencies and less ability to control memory. While maybe it can be unsafe if done incorrectly, it surely has less attack vectors at the dependency level like other software today. Additionally, it seems like C++ is still a language where programmers/developers control the products over all the middle layers that control modern software, like the hellscape that is project management of software today.