Why I (Still) Won't Use D

Michiel Helvensteijn nomail at please.com
Thu Mar 27 18:28:09 PDT 2008


Walter Bright wrote:

>>> No, I don't agree that it is a silly example.
>> No one ever used vector<char> as a string and no one ever will.
> 
> Yet I'm always left wondering what is the difference between vector and
> string?

The implementation may be the same. The difference is in the interface.
std::basic_string<T> can concatenate, convert to c_str, find and extract
substrings, etc. More importantly, it is well-behaved when sent to a
stream.

std::vector<T> is meant as a container for any type, and has iterators, push
and pop functions.

>>>> I have to agree that C++ has a lot of baggage because of its backward
>>>> compatibility. It is its greatest strength and its greatest weakness.
>>> True, but that offers no reason to use C++ for new projects. Try writing
>>> an internationalized string processing app in C++, and you're in for
>>> endless pain and bugs.
>> 
>> There are toolkits like Qt that will make it a lot easier. Of course, the
>> Qt toolkit does this by introducing yet another string type. ;-)
> 
> It seems like every C++ library has its own (incompatible) string type.

Qt softens the blow by having a implicit constructor that takes an
std::string and a member-function toStdString().

> I was motivated in D to make the string type good enough to not motivate
> people to invent string classes.

What's good enough now may not be good enough in the future. And what's good
enough for you may not be good enough for other programmers.

By hard-coding certain behaviors in the core language, you've taken away the
freedom of the programmer to choose these hirself. Like the growth-rate of
dynamic arrays. Or the sorting algorithm used by the .sort property. Or the
datastructure returned by the .keys property of associative arrays.

I would still like to hear your views on my "library defines T[] and T[U]"
idea.

-- 
Michiel




More information about the Digitalmars-d mailing list