News for hackers. Stuff that matters.
Re:Learn Modern C++ by pompino on Tuesday December 26, 2023 @11:47AM (#38773345)
Why do you feel the need to use every single feature? Are you constantly joining new projects that use vastly different features? Most programmers find a handful of features that gets the job done, and keep using them. Your knowledge from 10 years ago (C++11) is still valid and useful.
Re:Learn Modern C++ by bxparks on Tuesday December 26, 2023 @12:26PM (#38773746)
No, but I need to know them to read other people's code. Every C++ programmer has a slightly different subset of C++ features that they consider "basic", "fundamental", or "essential".

After 35 years of C++ on and off, I have pretty much given up it. I don't have the mental energy to deal with its complexity anymore. I will deal with parts of C++11 or C++14, mostly so that I can read other people's Arduino code.

I think I would rather learn a new language (Rust?) than deal with the hairball that is called "modern C++".

Re:Learn Modern C++ by 01100011 on Tuesday December 26, 2023 @12:52PM (#38774012)
This 100%.

The vast majority of programmers' lives is spent reading code. We need to be able to interpret, repair and extend the work of others.

I often hear this defense of C++, that you only need to know certain parts and the rest are for "library writers". This is an absurd argument, but not exactly surprising from the core C++ cult(and I say this with 26 years as a C/C++ dev). It's almost as if there are two separate camps, one writing and maintaining production software, and another group which only works on language internals and is becoming further divorced from reality.

Re:Learn Modern C++ by wiseowise on Tuesday December 26, 2023 @01:19PM (#38774314)
Absolutely this, 100 times. I will never understand “don’t use all features” argument. Open 5 C++ projects side by side and you’ll find 5 different languages and 5 different build systems that are nigh impossible to build if they deal with dependencies.
Re:Learn Modern C++ by UncleOxidant on Tuesday December 26, 2023 @01:46PM (#38774629)
Sadly agree. I used to know something that was called C++ (or at least parts of it) and even used to get paid to program in it. But now that C++ has become this kind of constantly morphing target (see the discussion here about what the most modern way to display text to stdout is) it's just tough to get my arms around it anymore. It seems like there was a noble attempt to modernize C++ and certainly there are some welcome parts of that, but it's gotten so far out of hand now. At some point you just have to admit defeat and start over from scratch with something that has a more unified vision. I'm looking at Zig and Carbon for lowlevel stuff and Julia for mathy stuff now.
Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @02:45PM (#38775310)
It is easy: Ignore the old parts, use the new parts.
Re:Learn Modern C++ by wiseowise on Tuesday December 26, 2023 @02:57PM (#38775426)
C++ is one of the oldest languages there is, it’s impossible to ignore old parts.
Re:Learn Modern C++ by angiosperm on Wednesday December 27, 2023 @02:39AM (#38779893)
Yet, anywhere I have a choice between old and new, I choose the new, and do ignore the old. Except println(), hard pass.
Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @01:58PM (#38774736)
Some new features are specialized, like standard library support for SIMD instructions, and you learn them where you want that.

But many offer better ways to do familiar things, that make the overall programming experience more pleasant. Use those as soon as the compiler you use gets support for them. Often they make bugs harder to write, and correct code easier to write. Now we can write

  for (auto const& [key, value] : map) { ... }
instead of

  for (Map::const_iterator_type it = map.cbegin; it != map.cend; ++it) {
    Map::key_type const& key = it->first;
    Map::mapped_type const& value = it->second;
    ...
  }
It is just better in every way.

Another example is extension of "constexpr" to more and more of the language; each eliminates the need for some range of template metaprogramming. Nowadays you can ignore almost everything written about template metaprogramming, because there are good, straightforward ways to achieve its aims with ordinary language features.

Re:Learn Modern C++ by sevagh on Tuesday December 26, 2023 @01:51PM (#38774670)
I saw `<< std::endl` when my brain was still developing, and now it's too late to stop using it.
Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @02:28PM (#38775105)
It is as easy to drop as it is to pick up "auto".
Re:Learn Modern C++ by pompino on Tuesday December 26, 2023 @07:35PM (#38777666)
Can you give a real-world example? Most code-bases have massive inertia that resists complete re-writes using new features.
Re:Learn Modern C++ by Buttons840 on Tuesday December 26, 2023 @12:10PM (#38773579)
In one of Bjarne Stroustrup's books he recommends focusing on software engineering rather than learning every language feature, or something to that effect. I think it's good advice. (And it's a good coping thought, but no less true.)

An actual engineer or carpenter doesn't master every conceivable tool before beginning their work, they can't, there's too many.

Say what you will about C++ programmers, but at least they are free from the burden of trying to use a perfect language and can focus on more important things.

Re:Learn Modern C++ by wiseowise on Tuesday December 26, 2023 @01:20PM (#38774332)
If you want what you describe you use Java.
Re:Learn Modern C++ by fsloth on Tuesday December 26, 2023 @02:14PM (#38774938)
You don’t choose C++ because you want to but because you need to due to constraints that Java likely does not fullfill.

As a C++ dev - If you don’t need C++ then choose whatever other modern language.

We keep up with C++ because of specific constraints other languages don’t fill.

Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @02:29PM (#38775121)
C++ is overwhelmingly more pleasant to code in than Java.

People use Java because they work in a Java shop. Similarly, COBOL.

Re:Learn Modern C++ by loup-vaillant on Tuesday December 26, 2023 @05:09PM (#38776629)
> Say what you will about C++ programmers, but at least they are free from the burden of trying to use a perfect language and can focus on more important things.

I would say most programmers, in any language, are free from that burden: once they picked their language they can focus on those important things.

Re:Learn Modern C++ by freeopinion on Tuesday December 26, 2023 @12:41PM (#38773900)
Generally true, but if you start from scratch and only learn "the good parts" you have to be careful that you don't accidentally wander into some syntax you didn't know had some other use.
Re:Learn Modern C++ by gpderetta on Tuesday December 26, 2023 @04:24PM (#38776206)
And if you end up learning something new it would be an absolute disaster /s

I learn something new all the time when I explore new codebases or even less beaten corners of existing codebases. Only a tiny fraction of the time it is a new facet of the language.

Re:Learn Modern C++ by angiosperm on Tuesday December 26, 2023 @01:59PM (#38774758)
That doesn't happen.
Re:Learn Modern C++ by 7thaccount on Tuesday December 26, 2023 @11:51AM (#38773387)
My problem is more about how to get started and use certain scientific libraries. Maybe I just need to dive in. I keep getting detered though when I find out that simple things like iterating through a text file seem to take up so much code. Then I need a dictionary and somehow have to figure out how to get that. Not trying to whine. It's going to be a lot of work though lol.
Re:Learn Modern C++ by protomolecule on Thursday December 28, 2023 @12:16PM (#38795703)
GPT-4 can be a good help here. It mostly gets simple things right.