Higher level built-in strings

Jonathan M Davis jmdavisprog at gmail.com
Mon Jul 19 17:10:09 PDT 2010


On Monday, July 19, 2010 16:49:58 Marianne Gagnon wrote:
> Pragmatically, I seem to have noted that in languages with low level
> strings, people invariably come up with librairies that provide
> higher-level strings. C/C++ provided low-level strings only initially,
> then a not-so-powerful std::string; and we saw QString, wxString,
> irr::string, BetterString, countless others...
> 
> Java, on the other end, provided a powerful high-level String object from
> the start; and to my knowledge it is used consistently in all Java
> programs with no other string classes being made.
> 
> I do acknowlegde that D arrays are much better than C/C++ arrays. Still, my
> prediction is that if D chooses to stick to C-style function calls, and
> does not provide a standard high-level String object, then a myriad of
> string objects will start popping around. Because lots of people like OOP
> and don't like C-style calls.
> 
> Just my 2c :) I mean be wrong
> 
> -- Auria

For the most part, D's strings are plenty high level. Between how fantastic D's 
arrays are and the fact that you can call functions on them as if they were 
objects, D's strings are quite high level in terms of how you use them. Their 
solution for how to deal with unicode is also quite powerful. The problem is 
that the solution for how to deal with unicode makes it so that if you try and 
deal with individual chars or wchars, you're going to very quickly shoot 
yourself in the foot. If you want to avoid the problem entirely, you simply use 
dstring and they're at least as powerful - and arguably more so - than Java's 
strings.

The only issue with strings in D that I'm aware of is the danger with trying to 
deal with individual characters. But their are lots of great functions for 
dealing with strings, and they allow you to easily deal with individual 
characters by just using them as single-character strings rather than as chars 
or wchars. On the whole, D's strings are the best strings that I've used.

- Jonathan M Davis


More information about the Digitalmars-d mailing list