Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a surface-level meme that just doesn't reflect reality. In old C++ you had to spend all your time worrying about manual ctors and memory management. These problems have been erased by improvements to the language. You don't even use raw pointers any more. The language is less complex to use now than it was 10 years ago.

If you've moved on then your insight is outdated.



I think the third definition here sums up what complex means pretty well:

> a group of obviously related units of which the degree and nature of the relationship is imperfectly known[0]

It's impossible for any single person to understand how the C++ language interacts with itself without a reference manual: it's grammar can lead to the most vexing parse; it has metaprogramming builtin using templates or macros, allowing for arbitrary code execution at compile time; it has a ridiculous number of ways to construct an object (move constructors, copy constructors, default constructors, is the object heap or stack allocated, are you using bracket initialization or parenthesis, etc); and more.

Also, I pointed this out in a comment awhile ago, but as of C++17 and over 20 years of writing technical books about C++, Scott Meyers doesn't trust himself to determine whether a given code snippet is or is not valid C++:

> It's not that I'm too lazy to do it. It's that in order to fix errors, I have to be able to identify them. That's something I no longer trust myself to do.[1]

If this language isn't considered complex, I don't know what is.

[0]: https://www.merriam-webster.com/dictionary/complex

[1]: https://scottmeyers.blogspot.com/2018/09/the-errata-evaluati...


> In old C++ you had to spend all your time worrying about manual ctors

That doesn't even make sense. Maybe you meant "destructors" but even then it has nothing to do with reality


I mean constructors. It's the exception to have to do anything meaningful in the body of a constructor in modern C++ - you can do a lot with member initialisation lists, delegated constructors and defaulted/deleted constructors (remember boost::noncopyable?). And your assignment operators will actually be exception safe.


Constructors was a mistake. Stupid and simple initialisation like Rust and Go is the way to go forward.


Constructors induced exceptions, and once we have exceptions they became the failure reporting mechanism of the standard library, leaving us with goto-some-other-function-using-dynamic-scope as one of the foundation blocks of the language. Thus constructors are a reasonable contender for the worst design mistake in C++.


Kind of true, if we ignore all the code that is in production and no one is going to rewrite for C++20 ways of coding.


Which would not have its problems solved by halting C++ development or moving to a new language


Anyone working on those codebases needs to be aware of the new ways, while mastering the old ways.

The ideal modern C++ without having to worry about "deprecated" ways of coding, is more the exception than the rule.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: