Why the Standard Library

deadalnix deadalnix at gmail.com
Thu Jan 19 13:08:51 PST 2012


Le 19/01/2012 19:52, Zachary Lund a écrit :
> I've been wondering in the back of my mind for awhile now and it really
> hasn't bothered me much but I figured I might as well get it off my mind.
>
> Why is there a need for a default "standard" library? I can understand
> about some of the core stuff, but hell, even threads can be handled via
> a 3rd party library. Why must Phobos or any library be a part of D itself?
>
> I'm unfamiliar with the reason for C++ having a standard library as well
> (which I bring up when people bitch about poor design or something
> similar which I usually get no viable or any answer at all). More of an
> ignorant question probably but oh well...

For several reasons.

First, some feature can interract with one another. For exemple, Thread 
are supported by the language as a feature in D. GC must be aware of 
thread. It interract with shared/immutable and so on.

The experience of threading in C or C++ is a godd reason to think a 
standard lib is a good thing.

Second, you'll find generic piece of code that are usefull in almost 
every programs. And every libs. If everyone use it's own implementation, 
you ends up with two phenomena :
  - Most implementation are low quality, testing is spreaded and more 
bugs are produced and less discovered. If all languages user use the 
same implementation of that given feature, it is likely that all 
important bugs are discovered fast and fixed fast too. This is effort 
mutualisation.
  - You ends up mixin several implementation of the same things in your 
program. This can be a nighmare because you have to convert thoses stuff 
all the time to pass it from lib A to piece of code B. C and C++ string 
are a good exemple of that in C++ code.


More information about the Digitalmars-d mailing list