3 ms·
So, I quite like C. I don't use it very often, but I think that it's like a sharp knife. I don't quite see the point of C++ though. Can someone explain me why
by sargun 10y ago
So, I quite like C. I don't use it very often, but I think that it's like a sharp knife.
I don't quite see the point of C++ though. Can someone explain me why we should continue to bow into it?
- adrianN 10y agohttp://programmers.stackexchange.com/questions/29109/is-there-any-reason-to-use-c-instead-of-c-perl-python-etc http://programmers.stackexchange.com/questions/29109/is-ther...
- johannes1234321 10y agoThe really short summary is that C++ provides abstractions, which allow to write more complex code simpler while many of those can be eliminated by the compiler leaving no runtime overhead. Sure there are things (i.e. virtual classes) which cause an runtime overhead, but even when doing the same thing in C you'd need similar logic to what the C++ compiler produces for you.
- fredsanford 10y agoIf you're interested in modern C++... https://www.youtube.com/watch?v=zBkNBP00wJE https://www.youtube.com/watch?v=zBkNBP00wJE
- RossBencina 10y agoIf you want a C-level sharp knife, and you want to work with abstraction (not just OO and abstract data types, but also generics and metaprogramming), then C++ is one of the few choices. D is maybe another option (if you can live with GC). Maybe in the future also Rust, but my impression is that the Rust generics and metaprogramming story is not quite there yet. C++ is mature, so it's a safe choice in that respect: large installed base, ISO standardised, mature tooling with multiple vendors. If you don't need the C-level sharp knife, then there are a lot of options -- and a lot of reasons to choose them over C or C++. Personally, I value that C++ is multi-paradigm (I can use classes when they are a good fit, generics when they are a good fit, asm when it's a good fit, etc.), also: trivial interop with C and assembler, no GC, runs directly on the metal. These are reasons to use C++, but not necessarily reasons to "continue to bow into it." Did I mention generics and metaprogramming? Even if you don't use these directly, their availability makes for flexible and powerful libraries. The STL container library is the obvious example, but modern C++ metaprogramming goes way beyond that.[0] [0] For example, see Hana: CppCon 2015: https://www.youtube.com/watch?v=cg1wOINjV9U https://www.youtube.com/watch?v=cg1wOINjV9U https://github.com/boostorg/hana https://github.com/boostorg/hana