34
8
u/G01denW01f11 Feb 19 '20
I'd better hurry and study up on this so I'm ready when we're allowed to use it at work in another 10 years.
33
u/shevy-ruby Feb 18 '20
Big surprise!
C++ is now more complex than before!!! \o/
(It's not totally fair; some changes were good. But still ...)
26
u/setuid_w00t Feb 18 '20
C++ proponents: "It's actually simpler because [insert new feature here] makes it easier to do [insert thing here] relative to [insert classic c++ foot-gun here]."
In reality, it just means that now everyone has to understand two ways do to [insert thing here] instead of one.
33
u/meneldal2 Feb 19 '20
The way it goes is:
Feature is missing
Templates are abused again to make it possible
It's a big mess.
???
People finally get a sane way to do it in the standard
Template insanity doesn't leave.
8
26
u/NotUniqueOrSpecial Feb 19 '20
it just means that now everyone has to understand two ways do to [insert thing here] instead of one.
God forbid they try to improve the way things are done in such a way as to make it easier to do the right thing.
I don't ever hear people complaining about things like this in other languages, e.g. with Python added format-strings.
8
Feb 19 '20
This happens with every language though. Code reflects the time in which it was written.
What actually matters is whether the cruft of old persists to the code of the future. It is undeniable that C++ has taken major strides to provide a more modern and sensible language that addresses the widely-documented shortcomings of its predecessors.
3
u/setuid_w00t Feb 19 '20
The one necessary step that c++ hasn't taken is removing old mistakes and thus the language just keeps getting bigger and more complicated.
7
u/corysama Feb 19 '20
Has any mainstream language ever removed features?
Here’s one: Python removed the print statement in favor of the print() function and that led to people waiting over ten years to upgrade their existing code. Python 2 is officially unsupported as of April and there are major packages out there being widely used that still can’t run on 3.
4
u/save_vs_death Feb 19 '20
if you think that whole thing was over the print statement I don't know what to tell you
you larger point indeed stands, people don't like it when you're perceived as removing features; for all intents and purposes, unless you're Swift, you're not gonna get away with backwards incompatible changes, so once you release a feature it's out for good
1
4
u/leirus Feb 18 '20
you need to forget the obsolete way and move on to modern way, simple xD
6
u/setuid_w00t Feb 19 '20
You can't forget the old way because there are millions of lines of code out there that do it the old way and you need to read and understand that code.
1
u/Ivan171 Feb 19 '20
You know you can still use [insert thing here] instead of [insert new feature here] right?
Because of backward compatibility they almost never remove old features.
3
u/AdamRGrey Feb 18 '20
Alright. Cool. So excited. I learned C++98 back in 2007, pretty sure I forgot everything. Should I start from scratch, or look for incremental upgrade tutorials?
21
u/Splanky222 Feb 18 '20
C++11 was the biggest language change. Everything from then on builds on top of it.
10
u/elder_george Feb 18 '20
the "Tour of C++" 2nd ed. is pretty concise and gives a good outline of C++17 (I think). You can upgrade on top of that.
3
u/pure_x01 Feb 18 '20
What are the top 3 festures? Great news btw.
20
u/dacian88 Feb 18 '20
concepts, coroutines, modules
5
u/ar243 Feb 19 '20
What are modules
15
u/maxhaton Feb 19 '20
Something that C++ should've had 20 years ago
3
u/jiffier Feb 19 '20 edited Mar 06 '24
OMG OMG
2
u/MonokelPinguin Feb 19 '20
Yes, they will probably transition gradually, but since great care was taken to make them mix well, the transition should be smooth enough.
11
u/dacian88 Feb 19 '20
It's a different way to structure code in c++. Instead of using header files to connect code in different translation units or libraries you use what is deemed a module. Modules are theoretically only processed once per build invocation instead of vs headers where they are processed for every single translation unit that
#includeit.2
u/kuikuilla Feb 19 '20
Basically instead of you doing the work of compiler by writing header files, the compiler works for you!
4
Feb 19 '20
I gave up on this language. Life is already complicated enough, why do I need C++ to make it worse? Sorry, Bjarne, it's just not a good language anymore. C? Sure. C++? Not so much.
15
u/loamfarer Feb 19 '20
Essentially every ++20 feature is there to make life less complicated, and C++ more worth while. If C++ is worse it's only for other languages that raise the bar, but C++ in fact has never been better. The features fundamentally simplify the language.
If you learn any other modern language you'll immediately see the equivalent features in wide use, so it's not like you win by writing these features off. In fact many of these features have been around for ages already, and were worth learning years ago had you been in another language.
The languages I consider "better" than C++ are honestly just as complicated if not more.
4
u/HoratioMG Feb 19 '20
Every time I try to learn the ins and outs of it I just give up. There are so many ways to do anything that every tutorial looks like it's using a completely different language to the next.
To be a newbie to the language in 2020 is unforgiving, and from my perspective it's a complete mess.
3
u/TheDevilsAdvokaat Feb 19 '20
Seconding. I went from c to c++ to Delphi to visual basic to c#...
I have no desire to go back to c++. c I'd be willing to try again.
0
2
u/VeryNiceTempAccount Feb 19 '20
Agreed. I feel like these new features are digging it a bigger grave.
1
u/ea_ea Feb 19 '20
Ok, this is video for fun. And where is the video with real introduction of core features?
1
u/Wastedmind123 Feb 20 '20
These adoption numbers are from 2019 -> https://www.jetbrains.com/lp/devecosystem-2019/cpp/
With 28% adoption of C++ 17, it will take roughly 5 years before half the developers adopt C++ 20. These numbers are probably only new projects, how many projects with continued maintenance will be left behind..
-34
u/_prototype_ Feb 18 '20
just give up on this insanely complex C++ nonsense and move on to next generation Rust please
11
Feb 18 '20
Another rust evangelist :/
25
u/PewPewLazors Feb 18 '20
Nah it's more likely one of those trolls posing as obnoxious Rust fan boys because they hate Mozilla for some reason (something about codes of conduct and liberals, I don't quite get it). You can find these guys at the bottom of a lot of Rust related posts on this sub.
3
2
u/bumblebritches57 Feb 19 '20
You know, C++ is a giant mess and that's why I'm proud to be a regular C programmer.
But rust is somehow even worse than C++.
0
Feb 18 '20
[deleted]
4
u/epicwisdom Feb 19 '20 edited Feb 19 '20
Yes unlike C++ where there's C++11, C++14, C++17, and now C++20, plus even older revisions of the standard which are still in common use. Not to mention GCC, MSVC, and Clang all having various incompatibilities and 20 different versions.
0
Feb 19 '20
[deleted]
-3
u/epicwisdom Feb 19 '20 edited Feb 19 '20
How is Rust having one compiler that comes bundled with an automatic updater in any way comparable to C++'s ecosystem?
0
Feb 19 '20
[deleted]
0
u/epicwisdom Feb 19 '20
Maybe because comparing C++'s ecosystem to rust's is like comparing a factory to a 3D printer?
Then maybe you shouldn't be pretending to make reasonable criticisms and turning around and crying foul when somebody points out your trite remarks are ridiculous.
or maybe because that crazy incredible feat of engineering can be replicated by just sticking to one toolchain in C++ for your project
Until you have to compile for a different platform or use a library written using some ridiculous, obscure feature.
0
Feb 19 '20
[deleted]
2
u/epicwisdom Feb 19 '20 edited Feb 19 '20
I was comparing C++ to Rust as language.
No, you weren't. You were making a snarky remark.
Give someone clang and rustc and see which one is more complex for them to start being productive.
Most people use cargo, not rustc by itself. Using clang + another build tool + OS package management is a headache compared to using cargo. There are downsides to the approach, but in terms of basic usage cargo is much better IMO.
Rust already exceeds that complexity by a mile while being less productive
I completely disagree. C++ is insanely more complex. The C++17 standard is 1605 pages long. It's completely founded upon arcane abstractions like lvalues and rvalues which require you to think about what the compiler is doing rather than the code you want to write, and are riddled with exceptions and legacy quirks. Even reading and writing types is quite complex.
Rust avoids raw pointers, it was designed with reference semantics in mind. It has proper ADTs, generics, typeclasses (traits), modules, and macros. In my experience these basic modern features make for much higher productivity with much lower complexity.
with a 1000 times smaller ecosystem and without any level of maturity for anything that has to do with real world scenarios in networking, async, or other server scenarios. Maybe everyone should just write non-IO stuff until rust is ready for that.
If you have a need that can't be met using Rust right now, there's no problem with choosing not to use Rust because of that. I would never say that everybody should switch to Rust immediately. However, a young language is not the same as a bad language.
With a huge list of extremely well maintained and widely used set of tools and modern libraries, that isn't a factor for new projects. I'm not trying to integrate and maintain vim for 50 platforms that don't exist anymore.
Compared to Java, Python, or JS, C++'s cross-platform story is laughable. Simply having to use a GUI or graphics library immediately makes it very clear how difficult it is to use C++ for cross-platform applications. There's a reason that Electron, which pretty much literally bundles an entire browser engine with your application, is popular, and it's not because cross-platform development on C++ is easy.
0
-10
Feb 18 '20
He writes only insert user name here
Rust is way more complex than C++
15
u/Full-Spectral Feb 18 '20 edited Feb 19 '20
I don't think that's true. But, I'll be generous and agree maybe they are equally complex. But a lot of C++'s complexity comes from trying to fight the tools to manually ensure that things are going to happen correctly (and still having no certainty that they are.) A lot of Rust's complexity comes from working with the tool to ensure that things are going happen correctly, with a very high certainty that they are (at least within the constraints of what compilers are responsible for, it's not going to prevent you from making logical errors.)
4
-6
Feb 18 '20
I meant complexity in terms of compilers actually. Sure it's still hard to make a C++ compiler but the ownership system in rust still seems like magic to me.
But for beginners, C++ is more complex than rust for sure.
9
u/Full-Spectral Feb 18 '20
I'm not sure what compiler writers would say, but I'd sort of bet that a C++ compiler is vastly more difficult, due to all of the backwards compatibility and evolutionary baggage and corner cases from all of layers of compromise over the decades.
2
u/flatfinger Feb 18 '20
What's ironic is that a lot of the "compromises" would never have been necessary in the first place if the Standard had either made clearer that the ability to meaningfully process certain constructs is a Quality of Implementation issue; implementations intended for purposes where the constructs would be useful should support them, but the Standard shouldn't force implementations to support constructs their customers won't need.
1
u/Y_Less Feb 19 '20
That sounds like you are saying that it would have been less complex of different compilers had done things in different ways, and you pick the one that matches your subset of requirements.
2
u/flatfinger Feb 19 '20
That sounds like you are saying that it would have been less complex of different compilers had done things in different ways, and you pick the one that matches your subset of requirements.
That's always been the actual state of affairs. The reason that a lot of low-level code won't work reliably on clang and gcc with full optimizations enabled isn't that the programs are defective, nor that the clang and gcc wouldn't be good for other purposes, but rather that while the authors of the C Standard explicitly stated that they did not wish to preclude the use of C as a "high-level assembler", they recognized that requiring that all implementations behave that way would make the language less useful for many other purposes.
The only problem with the state of affairs (but it's a big one) is that there is no standard means of specifying what particular features and guarantees are needed by particular pieces of code. If there were a means by which a program could say, e.g. "It would be acceptable for integer overflow to cause possibly-asynchronous abnormal program termination, set an implementation-defined overflow flag, or for it to behave as though it yields a result outside the range of the result type with non-deterministic upper bits, but it must have no other side-effects other than those above", then a lot of code could be written much more easily and safely than is possible in a language where people writing implementations for commonplace hardware think it reasonable to behave in ways contrary to the explicit documented intentions of the C Standard's authors (e.g. the way gcc processes
unsigned mul(unsigned short x, unsigned short y) { return x*y;}which sometimes jumps the rails for values between
INT_MAX+1uandUINT_MAX).2
u/CoffeeTableEspresso Feb 19 '20
Sure but wait 20 years and Rust will be in a similar place as C++ is today...
2
u/Full-Spectral Feb 19 '20
Quite possible. But, hey, at least we have 20 years until then :-) I'll likely have to have someone cutting my food for me by then, at best.
-3
Feb 19 '20
Loads of features robbed from D. sigh
4
u/bumblebritches57 Feb 19 '20
If you pay close attention, you'll notice one feature that is never stolen and the reason D hasn't and won't catch on.
Garbage Collection.
2
Feb 19 '20
...which is entirely optional 🙄
6
u/MonokelPinguin Feb 19 '20
*if you don't use the standard library or other libraries, that depend on it. (At least that is my experience).
1
u/kprotty Feb 20 '20
This is a similar story to most language features: Rust stdlib, malloc book-keeping in C/C++, etc. You pay for what you use and if you rely on people which use something you dont want out of, say, convenience - then thats a dependency problem rather than a language problem.
-2
0
Feb 18 '20
[deleted]
12
u/bstamour Feb 18 '20
Yes.
3
u/FatalElectron Feb 19 '20
At least, once everyone starts rewriting into or providing module definitions
0
Feb 19 '20
[deleted]
3
u/MonokelPinguin Feb 19 '20
Well, the standard is ready to be published, but since this is quite a major release, I expect compiler to still need about a year to catch up. GCC for example still hasn't merged the coroutine and module branches, iirc, but they are almost ready, just need some fixup for the latest spec changes and some bug fixing.
38
u/[deleted] Feb 18 '20
I'm really curious about where C++ goes. It just becomes less similar to C every new standard.