3 ms·
Ask HN: Is C++ a better language than C?
please refer to original question and discussion for better context:
https://twitter.com/brouhaha/status/1340919013929529344?s=21
- umen 6y agoLinus Torvalds don't thinks so
- wgrzmv 6y agohahaha
- krapp 6y agoYes. Function and operator overloading, default arguments and templates alone make it better.
- pasttense01 6y agoIt depends on where and how you want to use the language.
- alexvoda 6y agoAnd it depends on what you consider better. If C++ never had any (sort of) backwards compatibility with C, I would probably say that C++ is better. But the way it is today, C is a simple language (good) lacking a lot of features that have become common in other languages (bad). C++ is the most capable and featurefull language (good) but it is a continuously evolving monstruousity and (for the usecase of C) lacks a sable ABI. The downsides of each result in extensive use of metaprogramming or radically different stacks resulting in very little common ground between different programmers. There is no equivalent to "JavaScript the good parts". There is no one true way to write something like in Python. This puts a lot of responsability on the programmers instead of putting it on automated tools (compilers, linters, etc.). This is why I favour newer languages like D, Nim and Rust for low level (manual memory management), and something with a garbage collecting VM like Python, Go, C# for higher level. But in the end it doesn't matter which is "better". You will probably use the language used by the platform or stack you want to use. Or the language used by your employer or university teachers. If the question is which one to learn, that is entirely different and it's a question about career planning.
- rangoon626 6y agoIt makes string handling much easier, that’s for sure. However I always liked the way Objective C did OPP vs how C++ did it.
- ddgflorida 6y agoI never cared for C++. If C had a real string type it would've been so much better.
- lmedinas 6y agoI guess so, that's why its so popular. Despise of what some people say about it, it tries to make better for all C flaws and introduces modern features to bring continuity to the language.
- AnimalMuppet 6y agoIf what you're after is simplicity, then no, C++ is not better than C. If that's what you're after, look at Go instead. But I question the premise. C++ is a more complicated language, which lets you do certain things much more simply than you could in C. (It also lets you make bigger messes.) If you care about doing those kinds of things, then C++ lets your code be simpler, even if the language is more complex. As always, use only the parts you need, and learn enough about them to use them well.
- gradschool 6y agoThe advantages of C++ over C that account for its popularity boil down to three main things. 1. It's easier for managers to hire C++ programmers because there are more of them than C programmers. 2. C is designed to trust the programmer more than C++ is. In some organizations, this difference might be advantageous for containing the damage caused by the dumbest team member. 3. It's easier for a developer to appear productive to a manager using C++, especially a non-technical manager, because it requires writing a lot of boilerplate.