Why the Standard Library

Alex Rønne Petersen xtzgzorex at gmail.com
Thu Jan 19 13:34:48 PST 2012


On 19-01-2012 22:26, Zachary Lund wrote:
> On Thursday, 19 January 2012 at 21:22:23 UTC, Zachary Lund wrote:
>> On Thursday, 19 January 2012 at 19:06:41 UTC, Alex Rønne Petersen wrote:
>>> On 19-01-2012 19:52, Zachary Lund wrote:
>>>> 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...
>>>
>>> Without a standard library, interoperation between libraries becomes
>>> a huge pain, because there's no standard interface/design for various
>>> things such as threads, containers, bigints, networking, file I/O, etc.
>>>
>>> Not to mention, if a standard library didn't exist, you'd have to
>>> adapt your build system to whatever arbitrary amount of libraries you
>>> need to use.
>>
>> C++ has interoperability between containers and allocators which have
>> done much good. However, they hardly have any libraries that force
>> preferential design that doesn't require flexible implementation.
>>
>> Things like bigint and networking are not based on optimized or
>> flexible implementation but on ease of use. You generally choose a
>> BigInt library that is the easiest to use, not the one that has the
>> most flexibility when it comes to which implementation it uses or the
>> one that is most optimized. Also, I'm not sure who would reuse the
>> std.socket design. There are plenty of libraries that give a more
>> robust and clean interface to sockets.
>>
>> I don't mind robustness but I do not like being forced onto a
>> preferential design (which doesn't require flexible implementation)
>> simply because it is in the "standard". I do not think the etc.curl or
>> std.bigint promote library interoperability. Thus, I do not think
>> these modules belong in the library considered "standard".
>>
>> Also, libraries aren't really that big of a pain to add to a build
>> system. It's generally just a matter of finding where the library is.
>> On Linux, this is simple. On Windows, it generally requires either
>> environmental variable or user input. I don't see any way around this
>> nor do I find putting everything into one glob of a library a solution.
>
> I also forgot to mention about library reuse. You don't tend to use
> BigInt libraries all the time. In 6 years of programming, I've not used
> a single one. Nor have I used regex in a C program. Nor have I needed
> the constant use of MD5 hashing. And I sure as hell did not need the
> constant use of CURL or ZLib nor have I ever even used those libraries.
>

Right. But again: Nobody forces you to link to all of Phobos.

-- 
- Alex


More information about the Digitalmars-d mailing list