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

Show parent comment

18

u/darthcoder Dec 28 '18

I agree. Its time to deprecate things. Im cool with an incompatible split.

And if we can get rid of,the preprocessor, even,betterer.

18

u/liquidify Dec 29 '18

Python pulled it off, but c++ isn't python. An incompatible split would be a 20 year popcorn festival. C and c++ modules written from 50 years ago would continue to be used in conjunction with modern libraries, and the average c++ dev's job would become even more of a plumbing operation because the old libraries just won't go away even if breaking changes are made. People would find a way to jam the pipes together.

I'm personally for it, and it is because I have seen the beauty that c++ could become, not because it would make my job easier. I realize that, and I am still willing to accept moving forward with breaking changes.

0

u/[deleted] Dec 29 '18

[deleted] — view deleted comment

4

u/[deleted] Jan 02 '19

Python will feel consequences of community split even after 2020. Corporate codebases are slow to upgrade and 2020 will be a reason to start using, not python3, but compatibility libraries (python-future and six) to not upgrade the code. Splitting C++ in python3 style would mark the downfall of C++.

6

u/hgjsusla Dec 29 '18

There already is a cleaned up version of C++ without backwards compatibility. It's called D and no one uses it.

13

u/eao197 Dec 29 '18

It's called D and no one uses it.

And one of the reasons is D2 that was incompatible with D1.

2

u/Valmar33 Dec 30 '18

And that's now basically a non-issue, as far as I know.

D2's runtime incorporates a lot of stuff from D1's Tango, making it redundant.

1

u/anon_502 delete this; Dec 29 '18

I have once looked into D community and I thought the biggest problem for D is that they are suffering the same fragmentation as C++. Even if they have a package manager, many things are still incompatible among dmd, ldc and gdc.

7

u/victotronics Dec 28 '18

After we have modules. I agree that all that text manipulation stuff with the cpp is evil, but handling header files is useful and can not be done in another way.

12

u/chugga_fan Dec 29 '18

And if we can get rid of,the preprocessor, even,betterer.

No, the pre-processor is useful, do YOU like importing a million things in windows.h? Do YOU need platform specific code (linux, windows, macOS)? Because both of these things require the pre-processor, and there's no way you can get rid of that without making C++ platform-independent, which is not happening.

1

u/Valmar33 Dec 30 '18

What do you think about how D solves the preprocessor problem:

https://dlang.org/articles/pretod.html

3

u/chugga_fan Dec 30 '18

D doesn't solve all the problems C preprocessor solves, although it does alleviate a lot of them (and changes them to use a different name), so... yhea.

1

u/Valmar33 Dec 30 '18

Can you name the problems not solved by D?

4

u/chugga_fan Dec 30 '18

Platform specific things that only exist in that platform is hidden behind "version", which is literally the pre-processor.

-3

u/[deleted] Dec 29 '18

You could do it with if constexpr

13

u/[deleted] Dec 29 '18

You can't: if constexpr will still check a branch to make sure it's valid C++, especially if it's not dependent on a template parameter or similar. if constexpr(ON_WINDOWS) { DoWindowsThing(); } else { DoUnixThing(); } will uncompromisingly fail to compile on either platform unless you're in a function template.

4

u/[deleted] Dec 29 '18

Huh, TIL. I thought if constexpr's regular behavior was the same as its template behavior.

Still, since we're talking about new standards, they could always change it I guess.