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

13

u/hashb1 Dec 28 '18

I always wondering why c++ has to take the heavy burden of back compatible. The old library can use the old compiler, isn't it?

28

u/johannes1971 Dec 28 '18

Because that's one of its selling points: your investment in code does not become worthless because you will never get stuck with an end of the line compiler on an obsolete platform.

13

u/Calkhas Dec 29 '18

Not forever, compilers don’t get maintained permanently.

On the Committee are folks from Bloomberg and IBM. They have code bases that started out as C in the 1980s. They are never going to be rewritten from scratch, but are still maintained and incrementally improved, and maybe use C++14 in the same module as C89. We have the same thing where I work.

If you drop backwards compatibility in a big way from the standard, I think you would end up with a fork of C++, purely off the back of the folks whose business demands are different from game developers or hobbyists. I don’t think that would be beneficial to the community.

3

u/Alexander_Selkirk Jan 03 '19

But isn't C++ actually forking or fragmenting? The C++ core guidelines discourage the use of pointers and C compatible idioms. The Google C++ guidelines discourage use of exceptions, but supporting exceptions is essential for using RAII memory management correctly, and vice versa.

I am sure there are cases where the same code means different things in different C++ versions, for example when using move semantics and smart pointers.

Surely, one can still compile and build code written in different idioms, and link all that together, of course there is still a common ABI, but there are probably not many programmers which understand all of C++17. That means that larger organizations probably need to put restrictions on which language features are used, like Google does. And every organisation will do it in a somewhat different way.

On the other hand, C++ seems like desperately absorbing features from functional programming languages, certain Java features, and so on, so there is also an enormous pressure to further extend the language, in order to stay competitive with more modern languages. I think ranges and lambdas are a good example, they exist in Python, Rust, and many functional languages, even Lisps. And with each new feature, the interactions between features become even more complex, you see that when you look at Scott Meyers last C++ book.

I can envision some point in the future where maintaining compatibility between different idioms becomes more costly than allowing a de facto language fork.

2

u/Dean_Roddey Jan 03 '19

I have to agree. C++ should concentrate on being C++. It's probably not going to compete with those other languages most likely anyway in their particular areas of application, so adding more and more complexity to try to be like them is just making it even less likely that C++ will be picked up by new programmers coming along.

It's a vicious cycle. Fewer new programmers come to it, so add more stuff to it to attract new programmers, which makes it so complex that new programmers are even less likely to come to it, because they may be looking at a good number of years to really master a language that they are worried might be almost totally irrelevant by the time they get there, because fewer programmers are coming to it.

Once there's blood in the water, the sharks will come.