2 ms·
C++ should have just copied D modules (and the modules that ImportC supports).
by WalterBright 2y ago
C++ should have just copied D modules (and the modules that ImportC supports).
- phire 2y agoYeah, maybe they should have, would have been a lot simpler. But C++ really wanted modules to be a more or less drop in replacement for #include (or at least a set of common use cases), which really pushed up the required level of complexity.
- pjmlp 2y agoThat it was already there via Apple and Google's work, header maps, but what we got was Microsoft proposal, after some collaboration with Google. Note at WWDC 2024, the module improvements regarding build times, in what concerns C++, it is based on header maps as well. Apple is not even bothering with C++20 modules.
- pjmlp 2y agoMaybe, however always telling what they should have done won't change the languages position on the market, so we get what we can have. Many things D might have done it first, yet it is hardly acknowledged, or has any impact on adoption without a major backer. I also keep telling WG14 should care about security, since Usenet days, fighting windmills.
- WalterBright 2y agoMany features of D have since found their way into C++, such as ranges, compile time function execution, thousands separators in numeric literals, conditional compilation blocks, etc.
- pjmlp 2y agoIndeed, and with them, the reasons for the industry to care about what D offers sadly diminishes. Also some of those features predate D, having shown first in Ada, Common Lisp, Eiffel, as discussed in the past.
- WalterBright 2y agoThere's not only the features, but how they are done. D users regularly tell me that it is just so much easier to program in D. Aesthetics do matter. I've pointed out many times that thousands markers in D came from Ada. However, no other language did them until D did. Yes, Lisp has compile time function execution. Where it remained until D did it with a compiled language. C++'s implementation of ranges is still based on pointers (an iterator pair), rather than based on arrays as in D. The language loses semantic information because there is no particular thing that connects the iterator pair as being the limits on an array. Basing ranges on arrays enables crucial things like array bounds checking. Yes, D's contracts are based on Eiffel. But they also went nowhere until D adopted them.
- WalterBright 2y agoI forgot to mention - I added contract programming to C++ back in the 80's. https://www.digitalmars.com/ctg/contract.html https://www.digitalmars.com/ctg/contract.html