Standard Library Concerns (Phobos / Tango)

Sean Kelly sean at f4.ca
Thu Feb 7 07:56:34 PST 2008


bearophile wrote:
> Sebastian Beschke:
>> Which is pretty much the point of OO.
> 
> I agree, but the lesson here is probably that some people don't understand OO well, or they don't want to use it everywhere, or it doesn't go well with their mindset, or they need to go faster and they want to program in a more C-style, etc. Java has OOP only, but D allows other kinds of programming too, so maybe it may be better to not have a std lib that is fully OOP, so it can be used when you program differently (like functional-style). Tango doesn't need to be perfect for everyone, but probably there are ways to modify its structure enough to make it look good enough for most people :-) I know very little about Tango still, but I have seen there are lot of people that think some changes may be in order before making it the D std lib :-)

I know I've said this before, but to me, the important thing is that a
library could be efficiently and easily applied to my needs.  And I
believe this has more to do with the assumptions the library makes than
whether it uses functions or objects.  For example, let's say that I
want to copy a file and I don't want any memory to be allocated in the
process nor do I want an exception thrown if a failure occurs, but
instead I want a return value to indicate the failure.  If the only
means provided for this by the library allocates a buffer to do so then
I'm sunk.  And if the routine or routines throw on failure then I have
to trap the exceptions, which means a loss of efficiency.

The Tango library was designed to make as few assumptions as possible
about intended use, and thus it is very modular.  It does have a fairly
considerable learning curve in some cases as a result, but in exchange,
I feel that it can be easily molded to the programmer's needs in many
more cases than would otherwise be possible.  Don't like objects?
Create wrapper functions to do the operations which require them.  Doing
so is trivial and it must only be done once.  In exchange, it is quite
likely that you won't be fighting the API because it made invalid
assumptions about how it should be used.

>> If you want to understand something in Tango, you can still read the source code.
> 
> The source code of Phobos is a simpler read to me (it's a matter of style too, I presume, not just of higher complexity coming from higher capabilities).

The source code of Tango is definitely more spread out, so you will
likely have to look at more files to sort out how to do something than
you would in Phobos.


Sean



More information about the Digitalmars-d mailing list