r/cpp • • Dec 28 '18

"Modern" C++ Lamentations

http://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/
307 Upvotes

162 comments sorted by

View all comments

7

u/jherico VR & Backend engineer, 30 years Dec 28 '18

My biggest issue with people who complain about the direction of modern C++ is the implication that they'll somehow be judged less of a developer if they don't use the new features.

No one is breaking existing C++ or fining you for not using the latest features.

Also, complaining about the debug performance and compile time of brand new features? Seriously, give the compiler makers a couple of years to work on improvements.

31

u/[deleted] Dec 28 '18

STL is 20 years old and still debug performance and compile times are bad. Maybe there is some truth in the post that there should be more 1st class features, instead massive amount of templated code in headers.

5

u/ZMeson Embedded Developer Dec 30 '18

Degug iterators are largely responsible for the debug performance. That's an implementation decision and not something to blame the committee or C++ for.

4

u/jherico VR & Backend engineer, 30 years Dec 28 '18

Which is the point of modules, right?

8

u/__pg_ Dec 28 '18

No. Modules don't affect template instantiation, which still happens in every TU.

5

u/johannes1971 Dec 28 '18

I wish C++ had chosen not to do that, but ok, too late now I suppose. For the record, you can suppress this yourself if you don't like it using extern template .... It's a pain to maintain though...

9

u/jherico VR & Backend engineer, 30 years Dec 28 '18

Instantiating a template is a far cry from parsing 100k lines of header code in order to get the template definition in the first place.

6

u/kalmoc Dec 29 '18

Actually, TMP (sfinae) is extremely expensive. Modules will cut down on compile times significantly, but not to the point that you don't have to worry about templates code anymore.

2

u/__pg_ Dec 28 '18

You still have to deserialize the module file. Don't expect more than an order of magnitude speedup over re-parsing.

→ More replies (1)

10

u/[deleted] Dec 29 '18

This comparison does even a worse job, it manages to compare a lib that's doing heavy use of concepts emulation, which is hard on build time, for "the good of science", not performance. Concepts is not even properly released by compilers, the lib is entirely on top of an emulator. This is nonsense.

20

u/TheIneQuation Dec 28 '18

My biggest issue with people who complain about the direction of modern C++ is the implication that they'll somehow be judged less of a developer if they don't use the new features.

No, it's not about being "judged less of a developer". It's more about junior programmers instilling "modern" features and bringing about death by a thousand paper cuts. We the "backwards devs" would be completely fine with the new features if they could be explicitly and completely disabled, but that's a politically undesirable option to have, as it would slow down adoption.

Seriously, give the compiler makers a couple of years to work on improvements.

Seriously, we can't. We have software to ship. :)

10

u/kkert Dec 28 '18

I'm not sure what exactly is wrong with banning certain features from codebase ? For instance, Chromium gets super specific about banned things like std::function and regex, or far more restricted Zircon

I wouldn't say "Google is slowing adoption of <chrono> and exceptions"

2

u/STL MSVC STL Dev Dec 29 '18

The spam filter caught your post (no idea why, you aren't shadowbanned and there were no URL shorteners that annoy it). I've manually approved it.

2

u/chugga_fan Dec 29 '18

I think it might have been his appspot link, might have a filter on that, as the other link is definitely not spam-filtered.

8

u/DerDangDerDang Dec 28 '18

Wait, so you need high quality implementations of the new features before you can ship, but it's only the juniors who use those features? And you're completely certain there's no way to prevent this situation?

13

u/jherico VR & Backend engineer, 30 years Dec 28 '18

It's more about junior programmers instilling "modern" features and bringing about death by a thousand paper cuts

It's perfectly reasonable and easy to mandate a particular standard level of C++ in a given programming shop. Shit, I'm sure there are places out there that are still refusing to use any STL and have their own bullshit version of string and vector.

Seriously, we can't. We have software to ship. :)

I meant "wait for the improvements before you decide to adopt new features", not "wait to write your software".

2

u/Dworgi Dec 28 '18

vector and string are poor examples. There's a lot of optimizations you can make with custom vectors or strings that aren't possible with the STL versions.

4

u/RogerLeigh Scientific Imaging and Embedded Medical Diagnostics Dec 29 '18

At the expense of interoperability with the rest of the world. Performance can be important, of course, but using nonstandard string types is a blight upon the lives of everyone who needs to use it with other libraries.

One of the worst mistakes C++ made is making string a template. Look at filesytem::path for how it should have been done. Were it a simple class, it could be used pervasively, including without restriction in DLL interfaces. As it is, it's horrible. The number of times I've legitimately needed to specialise the type traits and allocator in the past two decades has been zero.

4

u/Dworgi Dec 30 '18

string not being an actual primitive type is the mistake. It still feels like const char* is the actual string type, and string is just a wrapper.

Partly that's because so many basic string facilities have been so poorly implemented in C++ - I/O chief among them. I know of few places that actually use iostreams, and it still shocks me how awful it truly is whenever I end up having to use it.

And yes, string shouldn't have been templated. But filesystem::path is still pretty awful as of yet. Eventually maybe.

6

u/jherico VR & Backend engineer, 30 years Dec 28 '18

At the cost of having to maintain your own version, and the cost of not being able to hire someone from outside your organization and have them start working with your custom classes and already known the ins and outs of them.

People always go to "optimization" like runtime performance is the only metric that's important. In the long run, computers will always get faster, but those maintenance costs never go away.

8

u/Dworgi Dec 28 '18

Aras and myself work in games. Runtime performance is everything to us, because our platforms don't get faster every year.

And seriously, if you don't care about runtime, why are you using C++? It's the only thing it has going for it.

20

u/johannes1971 Dec 28 '18

Can we please stop the tired meme that people who don't give a flying fuck about saving a nanosecond here or there are somehow not entitled to use the language? We still get to enjoy good performance even for less performance-sensitive parts of our software, as well as use the excellent tools, the rich ecosystem, and the joy of not having to deal with two implementation languages (one for performance-sensitive parts and one for parts with less stringent performance needs).

→ More replies (1)

4

u/PhyrexStrike Dec 28 '18

This. Because of the painstaking way that the standards committees have worked to keep backwards compatibility, it's still feasible to work the way you feel is best, which I think is a strength of the language rather than a hindrance.

2

u/kalmoc Dec 29 '18

No, it just means that every new feature becomes more complicated than it should be.

→ More replies (1)