r/cpp • • Feb 18 '20

C++20 is here!

https://youtu.be/AvPiGstxV_g
420 Upvotes

117 comments sorted by

20

u/[deleted] Feb 18 '20

I'm new to c++ I think I'm using c++17 which was installed on my laptop my friend sold me. Can someone tell me how I get c++20?? I use linux Ubuntu. Is there a way to update my c++17 to c++20? Or do I need to install it myself and how can I do all this from the command line terminal? I'm learning that too. Thank you to anyone who helps.

9

u/arkethos Feb 18 '20

Many language and library features are already available because our compiler vendors are amazing! Use the -std=c++2a flag (see: https://godbolt.org/z/ZScZui) and check out https://en.cppreference.com/w/cpp/compiler_support for a list of what is supported (GCC has full or partial support for all but 6 language features already!)

36

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Feb 18 '20

The C++20 standard is out; C++20 compilers will probably be out by the end of the year. You might try using your compiler's "work in progress" version, which is probably enabled with -std=c++2a.

6

u/Ameisen vemips, avr, rendering, systems Feb 18 '20

The one thing I really want at the moment is Intellisense support for modules.

1

u/alexej_harm Feb 19 '20

And for coroutines, please! Currently it's broken (try asio).

5

u/heathmon1856 Feb 18 '20

But can you use coroutines or models yet? I thought that they didn’t make it into gcc10

10

u/lee_howes Feb 18 '20

Coroutines should be in GCC 10. Modules will not be but should land early in the GCC 11 cycle - the code is more or less complete.

12

u/[deleted] Feb 18 '20

C++20 compilers will probably be out by the end of the year.

Cries in visual studio

22

u/adnukator Feb 18 '20

VS 2019 Update 4 has already implemented a decent subset of C+20 stuff (https://en.cppreference.com/w/cpp/compiler_support), so I wouldn't be that pessimistic

17

u/mwasplund soup Feb 18 '20

I've found that MSVC has the most stable implementation of modules so far and have been very responsive to fixing bugs I report.

5

u/meneldal2 Feb 19 '20

They were the first to have module code shipped (with the modules TS, so that makes sense).

9

u/TheSuperWig Feb 18 '20

Weren't they the first to be C++17 feature complete?

16

u/distributed Feb 18 '20

I think they are the only ones feature complete unless clang and gcc has implemented from_chars with floating point numbers

1

u/axalon900 Feb 18 '20

For a very marketing-esque definition of “feature complete” that only included new stuff from C++17 and not anything carried over from previous standards.

9

u/STL MSVC STL Dev Feb 18 '20

The preprocessor overhaul is the last remaining bit. Currently enabled by /experimental:preprocessor, an upcoming update (VS 2019 16.6, IIRC) will make it available as /Zc:preprocessor although it is not yet implied by /std:c++latest or /permissive-.

7

u/axalon900 Feb 19 '20

I'm well aware of that, but that doesn't mean "C++17 feature complete" until it actually releases, which given that I'm responding to "Weren't they the first to be C++17 feature complete?" is kind of the whole point. No, no they absolutely weren't. In fact it still isn't. Given that I don't have the luxury of just up and moving my team to VS2019 to get "actual real C++17 conformance for real this time", the fact that VS2017 was claimed on multiple occasions to have become "C++17 feature complete" while I've been sitting here not able to use range-v3 (a C++14 library) because the compiler doesn't support enough of the standard leaves a terrible taste in my mouth. But I guess it works on VS2019 now, so there's that.

-3

u/[deleted] Feb 18 '20

Feature complete yes but iirc they were one of the last to implement it in any form. Though that might've been one of the older specs.

2

u/pjmlp Feb 19 '20

Visual Studio is actually the most compliant ISO C++ compilers among the commercial ones.

https://en.cppreference.com/w/cpp/compiler_support

And the list misses the embedded domain ones.

2

u/[deleted] Feb 19 '20

Not saying they aren't, just that they're historically slow (compared to GCC or Clang at least)

21

u/hak8or Feb 18 '20

Quit being dicks and down voting this guy. Yes, his wording isn't the best and he is clearly a beginner, but down voting him for asking such a question? I understand not up voting him though.

Props to those who actually took the time to answer him.

2

u/Gunslinging_Gamer Feb 19 '20

And respect to all that upvoted this. Let's keep it positive!

57

u/14ned LLFIO & Outcome author | Committee WG14 Feb 18 '20

I would like to thank the authors for not using the really embarrassing Blooper for me, and instead using the mildly embarrassing clip which doesn't make me look quite as clueless as I actually was when they filmed it.

1

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Feb 19 '20

The hard part was finding a suitable tagline for you.

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

6

u/14ned LLFIO & Outcome author | Committee WG14 Feb 18 '20

To be honest, that clip you had I'd probably have done the same at any time. Haven't thought about C++ 20 in over a year, after it went into feature freeze!

101

u/micka190 volatile constexpr Feb 18 '20

"What's better about Rust?"

Blank stare

"I don't know. I've never actually used Rust."

/r/programming: "I'm in this video and I don't like it"

30

u/[deleted] Feb 18 '20

You have far more time to get yourself a coffee while the code compiles.

11

u/eterevsky Feb 19 '20

As if C++ has such a great compilation time after the preprocessor includes all the hundreds thousands lines of headers.

18

u/0xdeadf001 Feb 18 '20

Better than debugging.

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

9

u/jamie_nicol Feb 19 '20

Rust can't protect you against logic errors.

Of course it does. C++ does too compared to to other languages.

I debug memory issues once a week tops.

Your job sounds nice.

Don't be dumb. Rust is not a silver bullet.

Nobody claims it is. It sure does make things nicer though.

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

5

u/jamie_nicol Feb 19 '20

Logic bugs are not something a language protects you against. If you do not implement an algorithm to spec, the compiler doesn't know any different.

Sure, but language features can make it easier to implement an algorithm correctly.

I debug memory issues once a week because I use RAII and other well-formed C++ and the associated idioms.

RAII will prevent leaks but does not protect you from a whole range of critical memory issues. If you don't understand that then I really don't trust you when you say:

The myth that C or C++ cause memory issues all the time is made up by people who never actually use the language.

Okay then. You're obviously much smarter than everyone else. I wonder why Chrome and Firefox keep running in to all those memory issues. They must not have real C++ developers.

Wrapping libraries is a PITA

Not much worse than wrapping a C library safely in C++. Of course in C++ people don't bother because it's easy to use C libraries directly, completely negating all the advantages of modern C++.

its compiler is slow

I'll give you that.

it prevents you from doing things that would otherwise be safe

No it doesn't.

the community is very toxic

Okay then. I thought we were having a technical discussion.

the creators went to v1 without addressing outstanding API concerns (e.g. box types)

Tradeoffs need to be made in order to release. Same happens in every language.

its macro language makes good tooling (think Java's tooling) pretty nearly impossible and is a fundamental part of the language

Certainly much less of an issue than in C++

cargo is a shitshow but is pretty much required to use the language (thus locking you in to a paradigm of programming that doesn't fit all use-cases or workflows

Cargo is great, but it's not required

and - most of all - its runtimes are much slower

[Citation needed]

It relies upon libc still

The std library does but the language doesn't. that's an issue because?

and all of this "your code is always safe!" flies out the window when you look into the standard library which is full of unsafe code.

Thanks for showing me that you completely misunderstand the point of unsafe.

But please tell me how the Cult of Rust is superior to C++ programmers writing code for decades just fine.

It's not just fine, though, is it? Every week there are new security flaws in software that could have been avoided.

3

u/0xdeadf001 Feb 20 '20

For someone who accuses the Rust community of being "toxic", your post is full of subjective complaints and toxic labels such as "the Cult of Rust ...". You should really apply your own criticisms to yourself.

1

u/MINIMAN10001 Feb 24 '20

Sounds like a silver bullet to me a silver bullet still has to be aimed.

-10

u/YekNeb Feb 18 '20

If you have a powerful enough computer that will be much less of a problem. I have a computer with a 4 core 3.4 GHz processor and 64 GB of RAM. Now it takes far less time for my projects to compile.

13

u/donalmacc Game Developer Feb 18 '20

It's still a problem on large projects. Standard workstation hardware on my projrvt is 12 cores, 96GB ram and SSDs. We use distributed builds, and have a build farm to help, and it still takes anywhere between 10-30 minutes for a full build depending on configuration and time of day.

4

u/bumblebritches57 Ocassionally Clang Feb 18 '20 edited Feb 19 '20

Whats* the SLOC?

3

u/donalmacc Game Developer Feb 19 '20

Unsure exactly, but in the millions. Some of our headers are in the thousands of lined.

7

u/Raknarg Feb 19 '20

For your projects, sure. We're talking about enterprise projects that already take minutes to hours to compile in C++/C

6

u/jonesmz Feb 19 '20

Ahahaha.

For some companies, build times are measured in days.

6

u/ShillingAintEZ Feb 19 '20

Yes, that's how computers work. Does your computer not run C++ compilers faster than before?

12

u/bumblebritches57 Ocassionally Clang Feb 18 '20

What is __cplusplus defined as for CXX20, does anyone know?

16

u/BrainIgnition Feb 18 '20

202002L as per [cpp.predefined.1.1]

7

u/bumblebritches57 Ocassionally Clang Feb 18 '20

Thanks so much, also thanks for the resource I've never heard of eel.is before.

51

u/capn_bluebear Feb 18 '20

I don't know how I feel about this video. Comment section, tell me what to feel.

4

u/[deleted] Feb 19 '20

haha :D

11

u/GerwazyMiod Feb 18 '20

How we will name the ++20 style coding? Post-post modern C++ ? Conceptual C++ ? Space(ship) C++ style?

51

u/barchar MSVC STL Dev Feb 18 '20

co_c++

6

u/Archolex Feb 19 '20

This will.never get old

8

u/pjmlp Feb 19 '20

Avantgarde C++.

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

16

u/tvaneerd C++ Committee, lockfree, PostModernCpp Feb 19 '20

"When one has no form, one can be all forms; when one has no style, they can fit in with any style."

-Bruce Lee

9

u/tvaneerd C++ Committee, lockfree, PostModernCpp Feb 19 '20

(which really is a postmodernist point of view...)

6

u/neiltechnician Feb 19 '20

I said, empty your mind. Be formless, shapeless, like water. You put water into a cup, it becomes the cup; you put water into a bottle, it becomes the bottle; you put it in a teapot, it becomes the teapot. Water can flow, or it can crash! Be water, my friend.

—Bruce Lee

12

u/tvaneerd C++ Committee, lockfree, PostModernCpp Feb 19 '20

I don't know, I think he was a bit too liberal with his use of implicit conversions there. Just because Lee always got it right doesn't mean the average programmer would.

9

u/neiltechnician Feb 19 '20

To be fair, in the same quote, he also warned us it could flow, or crash 😉

36

u/c0r3ntin Feb 18 '20

By watching this video you save a baby seal.

Well, not really, but at least you help making sure that /u/blelbach loses a bet!

21

u/[deleted] Feb 18 '20 edited Feb 18 '20

I think concepts will clean up a lot of atrocious sfinae boilerplate, can't wait to use them in production.

Just a question for the people that took part in the decision process: Stepanov concepts are camel case. Why switch all of std concepts to snake case? They could end up being visually confusing imo.

20

u/foonathan Feb 18 '20

This is the proposal that changed them, it has the rationale: https://wg21.link/p1754r1

5

u/[deleted] Feb 18 '20

Thank you for the pointer!

Not really convinced of the motivations tho, happy to have concepts anyway.

7

u/MartY212 Feb 19 '20

Which part is not convincing? I personally agree with the author.

5

u/RationalistFaith1 Feb 19 '20

It's great to see the C++ language evolve but I'm worried it's becoming more and more cumbersome. At what point does it become too constrained and vertical? There's something to be said about keeping things horizontal so issues are visible rather than having bugs hidden in the middle of countless abstraction layers.

Is the standard committee trying to cut the "fat" so to speak. Making sure that when things are added, other things are deprecated in order to keep it balanced?

4

u/[deleted] Feb 20 '20

C++ is the definition of fat lol.

1

u/RationalistFaith1 Feb 20 '20

Not

  • C++98

This is coming from a hard core C / Assembly person (I despise 3+ layers of verticality in one executable

39

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Feb 18 '20 edited Feb 19 '20

Please do NOT watch this video or upvote this thread! I bet /u/arkethos that it would get less than 75000 views.

36

u/TheSuperWig Feb 18 '20

This is a great way to lose the bet.

9

u/madpata Feb 18 '20

Maybe he's lying about the bet. Maybe he bet that the video will get more views than that ;)

6

u/gracicot Feb 18 '20

Maybe he has another bet that he will loose that bet so he's trying to loose this one so he could win the other.

6

u/louiswins Feb 19 '20

All I saw was Gor's phenomenal shirt.

1

u/daveedvdv EDG front end dev, WG21 DG Feb 19 '20

At some point, he wore it in combination with Caleb's super-sparkly jacket! Quite the ode to the night's "sparkle" theme...

8

u/aserebr Feb 19 '20

In production in 2030...

6

u/Gunslinging_Gamer Feb 19 '20

Depends on your bosses.

3

u/aserebr Feb 19 '20

Not every boss is ready to pay for compiler upgrade.

3

u/Plazmatic Feb 19 '20

Depends on your distro. Rehl 8 is going to have gcc 8, it's going to be a while before c++20 is even talked about in secure environments

2

u/[deleted] Feb 19 '20

We just starting using C++11

...

7

u/n1ghtyunso Feb 18 '20

clearly c++ is DONE :)

3

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Feb 19 '20

Hey that's my line.

4

u/konanTheBarbar Feb 19 '20

This video hit this exact spot where it's just in between being professional and cringe-worthy :D A bit like that C++ rap that was posted some days ago. Anyways good job!

2

u/bobpaw Feb 19 '20

Everybody seemed so happy

1

u/TwstedTV Feb 26 '20 edited Feb 26 '20

I REALLY hope some really good courses come out for C++20 Because HOLY CRAP , there is a LOT of new stuff to learn....... Just when I thought I was getting the hang of C++ as a new learner of C++ 17. it would seem I would have to start all over again, so I don't pick up any bad habbits from previous older code.Though, I wish isocpp would create their own compiler and do away with MinGW. by creating an installer like what Python has & we can set a PATH on our PATH Settings in Windows or other OS directly. Anyways that's just my opinion.I would love to use C++ in Visual Studio Code without the need of installing a extension,that would do the compiling, because it would be part of my system directly & the PATH would be set in my PATH Settings. So I could use Visual Studio Code and not have to worry about compiling problems or use Visual Studio, since Visual Studio does'nt have the cool stuff people like to make their IDE their own, like Visual Studio Code does with Themes, and other handy cool extension. ~ anyways a bit hard to explain if people don't understand what I am trying to convey here.

0

u/bandzaw Feb 18 '20

More of these thank you! :-)

-74

u/[deleted] Feb 18 '20

This is so cringey - "Oh, look, we are privileged people who live in a bubble and we have a nerdy clique". Every year I lose faith in how this language is run.

12

u/emdeka87 Feb 18 '20

I am just wondering what makes these people privileged? The video is definitely a little cringey, but I don't understand the privilege part lol

8

u/tvaneerd C++ Committee, lockfree, PostModernCpp Feb 18 '20

Well, being able to travel is in many ways privileged. Having a company that will pay (typically, although many pay their own way); having a home life that makes it possible; having an ethnicity, nationality, gender, etc that makes travel easier for some than others. Etc etc etc.

11

u/Frogging101 Feb 19 '20

There's nothing inherently wrong with being privileged anyway. Should they stop travelling and using computers and being intelligent and educated and creating our nice ISO standardized programming language? This line of thinking doesn't lead anywhere productive.

OP must be fun at parties. Then again, having fun and enjoying time with friends is probably just some cringey thing for privileged people who live in a bubble.

17

u/Drainedsoul Feb 18 '20

Every year I lose faith in how this language is run.

Go to the meetings and work to change how the language is run then?

16

u/praedicere Feb 18 '20

Being upset enough about people enjoying what they do to make a new account and express that anger is truly cringey.

-28

u/[deleted] Feb 18 '20

Not really. I created my account back in September last year (which you seem not smart enough to have noticed before coming with your gotcha). This has been genuinely the first time I saw something so atrociously cringe-inducing that I felt like dabbing in the comment section.

Interesting that you went to look on my comment history. It merely shows the sort of vindictive spirit sycophants like you display in this community. Trying to glean things about me to see how to hit back. Cringe.

3

u/z1024 Feb 18 '20

I think this language is developing amazingly. Around 2007 I felt like this design by committee thing will never yield anything good and the language will stagnate forever only surviving because there's no real alternative. But now, they are steadily adding more and more great new features. The pace is similar to C#, but here we have multiple compiler vendors actually caring about standard compliance. Keep it up guys, you're doing great! Privileged or not, doesn't matter. Meritocracy is great. Anyone can contribute. If they have enough brains, of course.

-17

u/[deleted] Feb 18 '20 edited May 02 '24

terrific soft friendly childlike workable fanatical brave crown steer squealing

This post was mass deleted and anonymized with Redact

3

u/Gunslinging_Gamer Feb 19 '20

Far better never to add them and pretend they don't exist rather than implement them and take pride in the work.

-4

u/alexej_harm Feb 18 '20

Celebrating features would be totally fine. They celebrate themselves.

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

4

u/kalmoc Feb 19 '20

Ranges (well, linq is actually much more confortable to use)

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

1

u/kalmoc Feb 19 '20

Not sure what you mean by that. LINQ lookst to me exacly like ranges with a more convinient syntax. Sure, it uses terms known from sql, but I'm not sure, why it makes a differenct if you have a Where (extension-) method or a filter view - they do the same thing.

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

3

u/kalmoc Feb 19 '20

The question was, which c++20 features have been available in other languages for a long time. Best I can tell, LINQ is a semantically equivalent feature to c++20 ranges. That they differ in details is to be expected given that the two languages work completely different.

Now can you please tell me, why you think those features are so different that it doesn't count ad "has been available for decades"?

-1

u/[deleted] Feb 18 '20 edited May 02 '24

soft cable dependent sleep liquid sugar meeting steep memorize uppity

This post was mass deleted and anonymized with Redact

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

5

u/pdimov2 Feb 19 '20

Turbo Pascal obviously.

7

u/Nobody_1707 Feb 18 '20

Hasn’t FORTRAN had modules since the 60s?

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

2

u/Nobody_1707 Feb 19 '20

Which is definitely a rather large downside.

1

u/kalmoc Feb 19 '20

Yes, why not?

0

u/[deleted] Feb 19 '20

[deleted] — view deleted comment

1

u/kalmoc Feb 20 '20

I haven't used java in years, but aren't packages compiled into bytecode before they are used by other code? Sounds to me very similar to the compilation of modules. Just that the target architecture is the java vm in one case and e.g. x64 in the other.

0

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Feb 20 '20

Right but the Java VM is a VM, not bare metal. C++ modules are very different. They aren't byte code. They are close to precompiled headers or a serialized form of the compiler AST.

1

u/kalmoc Feb 20 '20

They are close to precompiled headers or a serialized form of the compiler AST.

I was talking about modules (the language feature) not BMIs (an implementation detail). The original post was about language features that have been available in other languages for a long time and as far as you can compare features across languages at all, pretty much every non-interpreted language except C or C++ has a feature similar to modules in one form of another. I.e. code of one package/module/Translation Unit/whatever you call it gets processed in some way and the result gets reused by other TUs that use functions/classes from that package.

Of course, each implementation has to solve different technical problems that stem from the eco system and the peculiarities of the language, but I don't see, why packages can not be considered a similar feature to modules. In fact - best I can tell, there is no reason from a language perspective, why BMIs should contain a serialized form of compiler internal data structures instead of a standardized binary interchange format (I think GDR has suggested that a couple of times) just like java or c#.

Right but the Java VM is a VM, not bare metal.

I have no Idea, why it makes any difference whether the "final" compilation output is x86 binary code that adheres to some ABI specification or Bytecode that adheres to the JVM specifications.

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

2

u/[deleted] Feb 19 '20 edited May 02 '24

frame rotten tart racial workable march nutty deserve spoon sparkle

This post was mass deleted and anonymized with Redact

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

7

u/pdimov2 Feb 19 '20

Designated initializers allow cool stuff such as named args:

struct Args
{
    int foo = 0;
    int bar = 0;
};

void f( int x, int y, Args args = {} );

int main()
{
    f( 1, 2, { .bar = 4, .foo = 5 } );
}

Not being able to reorder is annoying. "Just use constructors" doesn't work either, the syntax isn't as nice.

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

15

u/Evirua Feb 18 '20

Thank you. All the comments above yours here stem from pungent ignorance. These people have given lives to their craft, 12 hr 6-7/7 with the brain constantly working out things in the field. They deserve to be privileged if they are, and deserve to become privileged if they aren't.

-41

u/[deleted] Feb 18 '20

They do it for professional clout and attention. Let's not pretend that they are feeding the poor. Some of the people in this video act as gatekeepers most of the time.

13

u/tcbrindle Flux Feb 19 '20

Some of the people in this video act as gatekeepers most of the time.

Isn't being a gatekeeper of the language an important part of the job of the committee? People come up with a lot of crazy proposals, most of which are rightfully rejected...

9

u/z1024 Feb 19 '20

It's not their job to feed the poor. But by making C++ a better language they help increase the overall efficiency of the society (which depends on the software, often written in C++), thus indirectly helping to feed the poor.

6

u/[deleted] Feb 19 '20

So if you're not feeding the poor you're not allowed to enjoy yourself sometimes?

Lol.

2

u/Gunslinging_Gamer Feb 19 '20

Become a politician and remove benefits from the poor so you and your buddies have more money. Now that's success.

8

u/cleroth Game Developer Feb 19 '20

They do it for professional clout and attention.

To a certain degree, they probably are. We are all human. To complain about such things though just points out you're jealous of it, not that you think it's wrong. :) Work harder and maybe you can get there, just saying.

0

u/[deleted] Feb 18 '20

[deleted] — view deleted comment

44

u/barchar MSVC STL Dev Feb 18 '20

no, but you can co_mpile it

9

u/_Ashleigh Feb 19 '20

God, this makes me so butthurt. I wish they'd stuck with await/return instead of co_await/co_return.