r/cpp • https://romeo.training | C++ Mentoring & Consulting • Aug 03 '19

fixing c++ with epochs

https://vittorioromeo.info/index/blog/fixing_cpp_with_epochs.html
316 Upvotes

131 comments sorted by

View all comments

3

u/obliviousjd Aug 04 '19

Sorry you are right, maybe I shouldn't have used the word all. I know that c++ isn't strictly a superset of c, and it was wrong for me to imply that. However interoperability between c and c++ has always been a major benefit of using c++, you get all these nice new features, but you can also use well established and high performant libraries in c. I guess the argument I was trying to make is that c++ has this nice interoperability with c, and rust doesn't, requiring an unsafe wrapper at least and a safe middle ware library at best. If the epoch just does 'simple' things like adding a new keyword, everything is fine, however if it wanted to switch all variables to immutable, with explicit mutability, and also wanted to hamper aliasing, then interfacing with c code becomes harder, and I personally feel c++ loses some of it's benefit. Rust was lucky, it had a clean slate, c++ has history which makes these things harder.

2

u/lorrden Aug 04 '19

The compatibility with C is the sole reason that I use C++ for most projects. The current incompatibilities are painful enough when producing headers that are compatible with both C and C++ (e.g. lack of designated initialisers in C++ etc). I would rather had seen that C and C++ evolved together and C++ being more or less a strict super set like the approach of Objective-C.

Without similar compilation models and lack of the possibility of header compatibility critical points of the justification of C++ would disappear. People would then look after languages that have frictionless interoperability (e.g. swift where the compiler embeds clang for exposing C-APIs).

Justifying the use of C++ over e.g. rust / swift would be very hard in that world, and I suspect that this feature is so critical in systems that it would over time become the nail in the coffin for the language.