Discussion on avoiding security vulnerabilities in C++

James Dennett jdennett at acm.org
Fri Jul 13 17:58:05 PDT 2007


Sean Kelly wrote:
> Walter Bright wrote:
>>
>> It's like I attended a presentation by Scott Meyers which was an
>> application of C++ template metaprogramming. Most of the presentation
>> was about how to do arrays of types. With D, that's trivial (as
>> tuples), and the presentation would have been over in 5 minutes.

With C++, it's trivial too, if you pick up a pre-built version
(as you automatically do when you pick up your D compiler).  The
corresponding talk for D could have been on how to implement
this inside the compiler rather than as a library.  The library
version has the advantage of working with many different
underlying compilers, which is a non-issue for D at this time
(given that there are 1.5 competing D compilers).

> I was trying to figure out how to determine the return type of a member
> function using C++ template code the other day.  Something that would
> take me two seconds in D had me tearing my hair out in C++.  The result
> is that I simply don't do much serious metaprogramming in C++ because
> the machinations required are often just a complete mess.  In D however,
> it's so straightforward that in most cases a novice could understand it.
>  This is a huge win IMO.

C++ will be on its second standard, with easy support for
such things as extracting the return type of a function,
before the D community is involved with straightjackets
such as standardization.

(There's a published ISO Technical Report for C++ which also
provides some interim support for this via std::tr1::result_of,
though that's markedly less elegant than the C++0x equivalent,
and can trivially be implemented in terms of decltype.)

If you're free to use the latest greatest D, you may well be
free to use not-yet-standard C++ features too.  In which case
what you mention above is trivial in C++.

I do tire of this silly C++ bashing.  D's actually not bad;
why not let it stand on its own merits rather than badmouthing
the language which most directly inspired it?

-- James



More information about the Digitalmars-d mailing list