News for hackers. Stuff that matters.
Re:C++17 – better than you might think by daurnimator on Thursday December 29, 2016 @05:49AM (#13276673)
The thing I want most is for them to deprecate misfeatures. C++ code can be impenetrable as the language is so large and complex.
Re:C++17 – better than you might think by TillE on Thursday December 29, 2016 @05:55AM (#13276686)
I never, ever hear this as a priority from fellow C++ programmers. It's always just on HN.

If you're actually working with C++, old "misfeatures" simply aren't something which gets in your way very often. You can just code in the modern way and be happy.

Re:C++17 – better than you might think by codeflo on Thursday December 29, 2016 @07:00AM (#13276853)
That's great for you, but unfortunately doesn't match my experience. Large, old codebases tend to become a mix of all "eras" of C++. That's either because old code was never completely reworked, or because newer programmers pick stuff up in the wrong place, for example from an old blog post.

The problem then is that some of the advantages of modern C++ are a bit "all or nothing". Just to pick an example, for exception safety in the current sense to really work, basically all of your code has to be written in a certain style, which is something that's really hard to achieve.

Maybe that's less of a problem for codebases started after 2011 that have been written in the modern style from the beginning. But given the way the C++ language continues to evolve, my bet is that even those will eventually run into the same problem with whatever new feature is introduced in 2026. There really needs to be a way to deprecate old language features.

Re:C++17 – better than you might think by ansible on Thursday December 29, 2016 @09:17AM (#13277358)
Maybe that's less of a problem for codebases started after 2011 that have been written in the modern style from the beginning. But given the way the C++ language continues to evolve, my bet is that even those will eventually run into the same problem with whatever new feature is introduced in 2026. There really needs to be a way to deprecate old language features.

That's one of the things I think the golang project did right. The gofix tool can be used to update old codebases.

Re:C++17 – better than you might think by pjmlp on Thursday December 29, 2016 @08:08AM (#13277052)
True, but I also find a mix of all eras on JVM and .NET projects.

No language that lives long enough is safe from it.

Re:C++17 – better than you might think by akavel on Thursday December 29, 2016 @07:11AM (#13276871)
The problem is you must keep all those "misfeatures" in the back of your head when trying to code "in the modern way". If you'd really try hard to ignore them, they'll just show up now and then and wreak havoc, sprinkled with some bitter undefined behavior topping.

As a related question: I seem to vaguely recall some mention by someone on HN, that somebody is trying to get some kind of "safe/strict blocks" markers into C++ (or some compiler? I have the feeling it was to be MSVCpp?), where "misfeatures"* would be disabled. Is anybody aware of something like this? Or was that just a beautiful dream I had?

* -- for some unknown definition of "misfeatures"

Re:C++17 – better than you might think by DennisP on Thursday December 29, 2016 @08:29AM (#13277129)
Sounds like someone could make a decent language by just removing all the old misfeatures from C++ and calling it something new.

You could argue that anyone who wants that is already on Rust or whatever, but I bet there are plenty of people who like modern C++ and don't necessarily like Rust.

Re:C++17 – better than you might think by akavel on Thursday December 29, 2016 @10:25AM (#13277736)
As to the "related question", see answer I got in a related subthread here: https://news.ycombinator.com/item?id=13277071 That's probably what created my vague memories.
Re:C++17 – better than you might think by tomjakubowski on Thursday December 29, 2016 @09:01AM (#13277268)
> I never, ever hear this as a priority from fellow C++ programmers. It's always just on HN.

These aren't mutually exclusive groups. I'm a professional C++ programmer posting on HN to say that C++ is terrible, even when you can somehow confine yourself to "modern C++" -- presumably because you're free from legacy code originally written in the 00s, or earlier!

C++11 (and to some extent C++14) made C++ less awful, but it's still a turd. And even many of the best features of C++11, like move semantics, are blown away by their equivalents in Rust. By the way, even whenever concepts and concepts finally land (I've given up now), C++ templates are still going to miles behind Rust's trait-based generics in ease of use and readability.

Re:C++17 – better than you might think by daurnimator on Thursday December 29, 2016 @06:25AM (#13276766)
Not everything is a new cleanly constructed codebase. I regularly have to jump into and fix/debug existing C++ projects. Often issues are due to accidental interaction between poorly understood features, or a misunderstanding of what a given syntax/idiom does.

Every feature/syntax added to C++ is one more place mistakes can happen, and one more thing to watch out for when debugging. I wish there was someone in a position of C++ power pushing to remove a feature for each one added.

Re:C++17 – better than you might think by gpderetta on Thursday December 29, 2016 @06:54AM (#13276838)
And for those existing multi-milion line projects, which are often decades old, you certanly do noy want to break backward compatibility. Ever.

It is fine to deprecate small warts if there is an obvious semiautomated path forward or if are hardly used (auto_ptr, trigraphs), but things like ADL are very unlikely to be ever fixed completely.

Re:C++17 – better than you might think by tomjakubowski on Thursday December 29, 2016 @08:49AM (#13277211)
> And for those existing multi-milion line projects, which are often decades old, you certanly do noy want to break backward compatibility. Ever.

I don't see what's inherently wrong with deprecating and then removing features or standard library templates in newer standards. As long as compilers and library implementations continue to support the old features when you ask for an old standard (by passing `-std=c++11` or whatever), what's the problem if C++26 removes $BAD_FEATURE?

The standards committee doesn't seem to think there's an absolute problem with removing features or standard library templates, because they've already removed trigraphs, auto_ptr, and more in C++17.

Re:C++17 – better than you might think by gpderetta on Thursday December 29, 2016 @09:03AM (#13277288)
Those multimilion lines of code are not just legacy codebases, they are often continuously updated and slowly dragged in the 21st century by using more modern idioms and embracing newers standards. If c++11 and 14 had significant compatibility breaks, they wouldn't have had the uptake they did and would have split the community.

It is not just a theoretical issue btw, unfortunately compatibility breaks do happen outside the standard, especially during the early to mid 2000s as compilers started enforcing the standard more closely; enforcing two phase lookup has been particularly painful and I don't think anybody is willing to repeat that experience very soon; there are still codebases stuck on Visual Studio 6 which was infamous for its nonconformance [1] and was widely popular in the late 90s till the early 2000s.

[1] to be fair it parially predates the standard.

Re:C++17 – better than you might think by FreezerburnV on Thursday December 29, 2016 @11:14AM (#13278085)
Theoretically you could remove features by deprecating them (with warning) for a specific c++xx version, and removing them in the next. So if c++14 warned on some $BAD_FEATURE, and then $BAD_FEATURE was removed in c++17, there is still a migration path from c++11 to c++14, and eventually c++17 once all deprecation warnings are removed. (or even before, if someone wants to take the time to remove any remaining warnings in one shot) If the compilers were then able to support the exact set of warnings/removals per version by a flag, old codebased would continue to compile and theoretically would continue to move into more modern features as the next version would never actually break the code.

Probably would be nasty to maintain for the compiler developers though. Imagine having to do a bugfix for c++11 mode when you just released c++26 mode.

Re:C++17 – better than you might think by daurnimator on Thursday December 29, 2016 @11:08PM (#13282444)
> Probably would be nasty to maintain for the compiler developers though. Imagine having to do a bugfix for c++11 mode when you just released c++26 mode.

They already have to.

What you're proposing makes much more sense: it means if you write a C++26 only compiler, you don't have to worry about implementing all the old crap that no sane person uses.

Re:C++17 – better than you might think by DougBTX on Thursday December 29, 2016 @06:53AM (#13276835)
> Not everything is a new cleanly constructed codebase.

This is true, in lots of ways. Lots of code is rushed, corners cut, so was bad the moment it was written. Other code is written in a particular style, and would need to be cleaned up to match a more modern style.

One benefit of backwards compatibility within one language is that these pieces of code can be improved incrementally, without having to switch languages. So, a road to improvement, rather than a source of mistakes.

The key is to make the new code better than the old code!

Re:C++17 – better than you might think by lmm on Thursday December 29, 2016 @06:53AM (#13276836)
That's because the people who can't stand to deal with those things have found a way to stop writing C++. The rump of programmers still working in C++ are those who didn't care as much.
Re:C++17 – better than you might think by koja86 on Thursday December 29, 2016 @07:11AM (#13276874)
Is it to be interpreted that you switched to some other language and ended up being more happy using it? Willing to share any tips?
Re:C++17 – better than you might think by lmm on Thursday December 29, 2016 @08:07AM (#13277050)
I did a limited amount of C++ some years ago - it was never my primary language, but there was a time when my primary stack was Python with C++ extensions. I'm a full-time Scala developer these days and love the language - it's concise and expressive, with a powerful type system (I guess C++ template metaprogramming is probably as powerful, but Scala makes that power practical to use) and reasonable runtime performance.
Re:C++17 – better than you might think by koja86 on Thursday December 29, 2016 @06:52AM (#13276834)
Well, yes. Unless you happen to work with mammoth size legacy C++ code-base which due to C++ being 30+ years old and prevalent mindset about technical debt I assume is the norm.
Re:C++17 – better than you might think by Doctor_Fegg on Thursday December 29, 2016 @06:07AM (#13276723)
But if you're not already working with C++, just trying to learn it, it does make C++ harder to pick up.