C++ traps that D2 doesn't avoid yet?

bearophile bearophileHUGS at lycos.com
Wed Nov 5 19:41:27 PST 2008


This page lists a lot of C++ traps and pitfalls in a short space. I assume D has to avoid or render meaningless a quite high percentage of them.
I'd like to list what of them D2 doesn't improve/fix yet, but my limited knowledge of C++ lets me understand only a certain percentage of such list of items (probably less than 75%) so probably I am not qualified yet to compare that with the D situation. Later I may try to write such differential list anyway...

http://www.johndeacon.net/Cpp/trapsAndPitfalls.asp

The nice thing of that list is that I think most (maybe 80-90%) of those traps and pitfalls (and several others that aren't listed, like allowing simple syntactical mistakes like putting a & where a && was requires or vice versa, etc) can be avoided by a language like D with little or no penalty in running space and time (and actually D avoids several of them already), but to avoid some of them you have to pay the price of sometimes having to step away from C/Java syntax, or probably worse having to assign a different semantics to some C syntaxes (Walter has explained that this is sometimes dangerous because most programmers know C/C++/Java and not D, but seeing the huge troubles C++ has gone to be as much compatible as possible with C I'd say that keeping the original C semantics when it is known to cause troubles is _always_ bad. In such situations I prefer a language that acts correctly than one that acts badly just to be like C, and maybe I don't even like a language that doesn't use some handy C syntax just because the semantics is now different).

Bye,
bearophile



More information about the Digitalmars-d mailing list