News for hackers. Stuff that matters.
Re:GCC 11.1 by typon on Tuesday April 27, 2021 @10:13AM (#26956106)
I wish there was a C++ standard that didn't add any features, but only fixed bugs or deprecated old features, and possibly improved existed features, giving compiler writers a chance to actually catch up and developers a chance to stabilize their codebases. C++26?
Re:GCC 11.1 by beached_whale on Tuesday April 27, 2021 @11:40AM (#26957438)
Pick a C++ version and use that then. Compilers are not dropping old versions of the std, but the new versions are just that new. No deprecation affects an older version of C++ and no one is forcing developers(as seen by the 20-30% that still use C++98/03) to upgrade their code bases.
Re:GCC 11.1 by not2b on Tuesday April 27, 2021 @01:27PM (#26958914)
Yes, all you need to do, with both g++ and clang, is to specify the version of the standard that you want. Picking a mature standard makes it likely that most bugs have been fixed.
Re:GCC 11.1 by jcranmer on Tuesday April 27, 2021 @11:38AM (#26957419)
Compiler writers are pretty quick to add support for new features--I'd say it's about a year-ish between being added to the standard (which is not the same as the actual release it's in!) and actually being usable in a compiler.

Where the delay comes into play is that most projects require a minimum support of a compiler that's several years out of date. And if you're required to support 4-year-old compilers, then C++17 features aren't going to be available, despite them being available in the newest versions of all compilers. Back in 2018, I was working on a project where I gave up and used C++17 features (constexpr if) because I knew I could get away with only supporting a Clang that's a few weeks old.

Re:GCC 11.1 by sesuximo on Tuesday April 27, 2021 @11:09AM (#26956967)
Compiler writers aren’t that far behind? C++17 is mostly supported. C++20 is one year old!
Re:GCC 11.1 by SubjectToChange on Tuesday April 27, 2021 @03:15PM (#26960183)
"C++20 is one year old!"

The ISO standard was published in December of last year. So, technically, C++20 is only four months old.

Re:GCC 11.1 by seoaeu on Tuesday April 27, 2021 @04:16PM (#26960952)
> C++17 is mostly supported.

For essentially any other language this would be an absurd thing to say. For those languages you wouldn't consider a feature added until it was supported by the reference compiler

Re:GCC 11.1 by SubjectToChange on Tuesday April 27, 2021 @07:57PM (#26963691)
If you are using GCC, Clang, or MSVC then the standards support is excellent[1].

But putting that aside

> For those languages you wouldn't consider a feature added until it was supported by the reference compiler

Well, there is no reference compiler for C++. I don't think any language with either an ISO or ECMA standard has a reference compiler or interpreter.

There are gaps in support here in and there. But I would still say those mainstream compilers "support" C++17 for the same reason I would say that Chrome "supports" CSS3, despite it not implementing the full specification.

[1] https://en.cppreference.com/w/cpp/compiler_support

Re:GCC 11.1 by pjmlp on Wednesday April 28, 2021 @02:34AM (#26966378)
Only for languages that lack multiple implementations.
Re:GCC 11.1 by R0b0t1 on Tuesday April 27, 2021 @10:37AM (#26956459)
Some of the additions, like coroutine support, are roughly bug fixes.
Re:GCC 11.1 by pjmlp on Tuesday April 27, 2021 @12:28PM (#26958130)
Nope, Python 3 showed what happens.
Re:GCC 11.1 by PopsiclePete on Tuesday April 27, 2021 @03:29PM (#26960352)
What happens? You become the most-widely used language on the planet? The Python 2-3 wars are over. Python 3 won.
Re:GCC 11.1 by pjmlp on Tuesday April 27, 2021 @04:01PM (#26960763)
I just installed Python 2.7 on my new project because some critical libraries used by the customer don't care Python 3 exists.
Re:GCC 11.1 by xxpor on Tuesday April 27, 2021 @04:10PM (#26960887)
Open source ones?
Re:GCC 11.1 by pjmlp on Tuesday April 27, 2021 @04:48PM (#26961316)
To some extent yes, and no I am not going to mention which ones.
Re:GCC 11.1 by xxpor on Tuesday April 27, 2021 @05:36PM (#26961961)
I just can't think of a major open source python lib that hasn't added support for 3 if the functionality wasn't replaced by a new feature in 3.
Re:GCC 11.1 by pjmlp on Wednesday April 28, 2021 @02:01AM (#26966155)
Github is a tiny drop on the universe from enteprise computing.
Re:GCC 11.1 by tsimionescu on Tuesday April 27, 2021 @03:46PM (#26960573)
You get 10 years of headaches for everyone who gets close to the language. Even today, the python executable in Ubuntu is called `python3`, not `python`.

To be fair though, it would be less of a problem for C++ than it was for Python, since you wouldn't have to depend on the compiler from the end-user system.

Re:GCC 11.1 by PopsiclePete on Tuesday April 27, 2021 @03:27PM (#26960330)
backwards compatibility is a bitch.

But yes, there's a reason why high-visibility C++ projects like Chrome basically white-list 30% of the language and keep it that way, to some small sub-set they feel is "good enough".

The problem is the fragmentation this causes. I pick these 5 features of the language, you pick another 7, I can't use your lib, etc, etc.

C++ is becoming extremely bloated. Bjarne said as much in one of his recent criticisms at the highly-specialized use-case proposals that people wanted to make "standard".

I enjoyed his C++11 book but now that's probably all outdated "oh we don't do it that way anymore" stuff and I can't afford to just buy 2-3 1000-page books every year to keep up. Got better things to do.

Re:GCC 11.1 by overgard on Tuesday April 27, 2021 @10:48AM (#26956640)
Sadly, I really doubt it. The standards committee seems mostly interested in adding new template metaprogramming features at this point. What I /really/ wish they would focus on is modules. 100% of C++ developers suffer from horrible compile times, and yet it seems to always get punted.

(Not to mention that forcing developers to write header-only libraries to use templates pretty much makes them way less attractive anyway)

Edit: maybe I'm wrong? It looks like modules are in C++ 20. No idea if any compilers are supporting them yet.

Re:GCC 11.1 by sesuximo on Tuesday April 27, 2021 @11:08AM (#26956944)
Modules doesn’t even really speed up the build if you have a highly parallel build... and it’s unclear how build tools should support it in a uniform way. I think modules will go unused but I hope I’m wrong
Re:GCC 11.1 by qalmakka on Tuesday April 27, 2021 @11:00AM (#26956820)
Modules have been released with C++20, but no compiler has a complete implementation for them yet. Also the standard library hasn't been modularized yet.
Re:GCC 11.1 by zxzax on Tuesday April 27, 2021 @12:07PM (#26957830)
How is it possible that modules were released, if nobody has a working implementation? I was under the impression that proposals needed at least a proof-of-concept implementation from a sponsor. My exposure to this is searching the CMake tracker for this last year and seeing that it wasn't even working there yet.
Re:GCC 11.1 by jcelerier on Tuesday April 27, 2021 @12:35PM (#26958238)
> How is it possible that modules were released, if nobody has a working implementation?

there were plenty of experimental implementations over the years, some people have been using some flavour of "modules" with MSVC and Clang for something like 5 years... hell, technically it has always been possible to compile code as objective-C++ to leverage the objc module system if you could afford to use clang everywhere

Re:GCC 11.1 by qalmakka on Tuesday April 27, 2021 @02:14PM (#26959441)
As the other answer said, nobody has (yet) an implementation of the _released_ standard, but both GCC and especially Clang have had modules very close to what stabilized by C++20 for years. You can enable them by specifying a flag (-fmodules-ts) on any recent release of Clang.
Re:GCC 11.1 by zxzax on Tuesday April 27, 2021 @03:07PM (#26960078)
I know that but I'm just baffled that the text of the standard could be released at a point in time when nobody has succeeded at implementing it fully. That seems like it would almost guarantee that no one implements the standard as it's written, as there is no proof-of-concept that it's truly viable... I'd expect to see several revisions to this before C++23 as the compilers work out the issues.
Re:GCC 11.1 by vips7L on Tuesday April 27, 2021 @11:48AM (#26957553)
MSVC is expected to have C++20 feature completeness in VS 2019 16.10 Preview 3.

https://github.com/microsoft/STL/wiki/Changelog#expected-in-...

Re:GCC 11.1 by pjmlp on Tuesday April 27, 2021 @12:29PM (#26958144)
Watch the Visual C++ virtual day coming next week.
Re:GCC 11.1 by petters on Tuesday April 27, 2021 @10:57AM (#26956783)
The standardization work for modules is done. Now all build tools and code bases need to start supporting it in a good way.
Re:GCC 11.1 by nindalf on Tuesday April 27, 2021 @10:49AM (#26956661)
Isn't modules already a part of C++20?
Re:GCC 11.1 by xvilka on Tuesday April 27, 2021 @10:47AM (#26956623)
There is. It's called Zig[1]. Usually I would have written Rust, but it's good to give Zig more publicity.

[1] https://ziglang.org/

Re:GCC 11.1 by nsajko on Tuesday April 27, 2021 @11:28AM (#26957250)
This evangelism stuff has really got out of hand on HN - a whole new language is literally the opposite of what the parent asked for. To make matters worse, the languages you choose to evangelize are new/experimental, making your comment even less on point.
Re:GCC 11.1 by accusitive on Tuesday April 27, 2021 @12:26PM (#26958107)
Yeah. I like rust but I feel like its pushed way too hard. If its really 'that good', people will slowly pick it up.

I personally don't like c++, but I wouldn't enjoy someone going on a rust thread and shilling c++. So I won't shill rust on a c++ thread. Seems similar for Zig.

Re:GCC 11.1 by tene on Tuesday April 27, 2021 @10:51PM (#26964935)
As a huge fan of Rust, I am very interested in people writing comments about what C++ does for them that I'm missing in Rust.

I want more C++ shilling in Rust threads, and I don't think I'm alone.

Please, give me detailed examples of how you can use SFINAE or whatever to express useful misuse-resistant abstractions that can't be expressed with Rust's feature set. Please tell me about classes of bugs you can prevent in C++ that can't be similarly prevented in Rust.

Or maybe C++ isn't safer, but it's more performant? Easier to use? Easier to learn? Easier to troubleshoot and debug?

I agree that the Zig comment that started this sub-thread didn't contribute to the conversation. If we disagree, although I'm not sure we do, it's in that I'd rather call for higher-effort comments about the benefits of other languages instead of fewer comments about them.

Re:GCC 11.1 by pjmlp on Wednesday April 28, 2021 @02:41AM (#26966421)
- GPGPU programing ecosystem like CUDA and SYSCL (note eco-system, not just a compiler that generates PTX code)

- Game engines like Unreal and Unity

- GUI frameworks like wxWidgets, Qt, MFC, WinUI

- Being the language of choice to contribute anything to GCC or LLVM

- Being the language of choice for the native libraries ecosystem and runtime extensions to plug into Java, .NET, nodejs.

- Being the language to write drivers in macOS (IO Kit/Driver Kit), and Android alongside Java (Project Treble)

- Being avaialble out of the box on macOS, iOS, Windows, Android, Playstation, XBox, Switch SDKs and respective IDE tooling

So you can decide to deal with some of C++ flaws, and enjoy 40 years of history, or spend part of your application development budget into building a Rust ecosytem.

Re:GCC 11.1 by oblio on Wednesday April 28, 2021 @04:21AM (#26967024)
> Windows

The C++ SDK is definitely not available out of the box on Windows. You have to install it (and update it manually!).

Re:GCC 11.1 by pjmlp on Wednesday April 28, 2021 @04:51AM (#26967183)
Only for those that chose the path of not using the OS vendor tools and don't install Visual Studio.

Not only it is automatically selected in the respective workloads that depend on it being avaiable, it gets updated.

Re:GCC 11.1 by lasagnaphil on Wednesday April 28, 2021 @10:43AM (#26969925)
Eigen, although often criticized for its long build times, is still the only linear algebra library that can lazy-evaluate and optimize expressions in compile-time, thanks to C++’s template metaprogramming.

In overall Rust’s current type system isn’t good enough to match what C++ has for numeric computations, although there have been some recent improvements such as the min-const-generics feature. I’ll probably try the language again once const generics are finished.

Re:GCC 11.1 by seoaeu on Tuesday April 27, 2021 @04:20PM (#26961001)
> If its really 'that good', people will slowly pick it up.

Empirically, that's been happening?

Re:GCC 11.1 by Ericson2314 on Tuesday April 27, 2021 @01:30PM (#26958946)
It's just shilling.

OP asked for:

> only fixed bugs or deprecated old features

When you get right down to that, you do end up with something like Rust. E.g. C++'s move semantics are weird because for historical reasons copying is the default. Get rid of those historical reasons, and there's no reason not to do it the Rust way.

40 years of "no big breaking changes" really is a lot of cruft.

Re:GCC 11.1 by jcelerier on Tuesday April 27, 2021 @01:55PM (#26959220)
> and there's no reason not to do it the Rust way

memcpy everywhere is definitely not the best answer to every problem

Re:GCC 11.1 by Ericson2314 on Tuesday April 27, 2021 @03:56PM (#26960698)
If you want a copy constructor, it would work like this:

Copy : Clone :: Move : Relocate

I.e. there would not be the presumption that everything is automatically movable or coppiable, there would be magic traits to indicate memmove / memcpy and friends, and then plain old stdlib super traits for user-defined cloning and relocating.

This is the the right design for move constructors, full stop.

Re:GCC 11.1 by FreeFull on Tuesday April 27, 2021 @04:29PM (#26961103)
It's not like C++'s move semantics magically get rid of the necessity of copying data either.
Re:GCC 11.1 by Ericson2314 on Tuesday April 27, 2021 @03:21PM (#26960259)
I meant to write it's not just shilling.
Re:GCC 11.1 by dralley on Tuesday April 27, 2021 @11:42AM (#26957470)
OP didn't ask for a new language that is stable, they asked for a stable C++.

But yes, it's true that Zig aims to be a minimal, stable language - when they go to 1.0, which hasn't happened yet. It's still changing frequently.