www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos vs Tango! What's your opinion?

reply =?ISO-8859-1?Q?Dl=e9?= <d.cavadini freesurf.ch> writes:
Hello people!

I'm working and studing this new (for me :-) ) language. I have some questions
and i think your opinion is so precious for me.

First, D is a new language.The official library is Phobos. Why another library
how Tango that is not compatible with Phobos? Because Tango is opensource and
the comunity can develop the library?

Why not a concept how java for example, where we have only one big family of
class?

Fundametals differences between Phobos and Tango?

Tank's!

I wait your opinions!

Dié
Apr 17 2007
next sibling parent reply Robert Fraser <fraserofthenight gmail.com> writes:
Phobos is mostly open-source, too, now. Tango is more community-driven, though.

In my opinion, they're both capable and complete libraries, but I prefer
tango's API, because it feels a bit more like Java's SE, which I'm used to,
rather than C(++)'s standard library. 

Dlé Wrote:

 Hello people!
 
 I'm working and studing this new (for me :-) ) language. I have some questions
and i think your opinion is so precious for me.
 
 First, D is a new language.The official library is Phobos. Why another library
how Tango that is not compatible with Phobos? Because Tango is opensource and
the comunity can develop the library?
 
 Why not a concept how java for example, where we have only one big family of
class?
 
 Fundametals differences between Phobos and Tango?
 
 Tank's!
 
 I wait your opinions!
 
 Dié
 

Apr 17 2007
parent reply Dan <murpsoft hotmail.com> writes:
Robert Fraser Wrote:
 First, D is a new language.The official library is Phobos. Why another library
how Tango that is not compatible with Phobos? Because Tango is opensource and
the comunity can develop the library?


Phobos was originally written by Walter Bright to provide a working library for DMD. Several attempts have been made to replace this library, the latest of which is Tango; all were community driven.
 
 Why not a concept how java for example, where we have only one big family of
class?


That's what Tango is going for.
 
 Fundametals differences between Phobos and Tango?


Apart from who implemented what, when, Phobos implements the "minimalist" approach, which I like, while Tango implements a "heavy-weight classes with everything" approach, which some people like. Fortunately, we have both libraries available for D, and I think the duality is definitely conducive to the language's development. I can also say that it hasn't been a problem by virtue of the fact that a program may use *either* library *or* both according to your preferences. If you're downloading someone else's code, having Tango and also Phobos on your computer would probably take less than 50mb, which is insignificant really.
Apr 17 2007
parent reply Bradley Smith <digitalmars-com baysmith.com> writes:
Dan wrote:
 Fortunately, we have both libraries available for D, and I think the duality
is definitely conducive to the language's development.  I can also say that it
hasn't been a problem by virtue of the fact that a program may use *either*
library *or* both according to your preferences.

Both? How do you use both Phobos and Tango in one program? I thought they were incompatible.
Apr 17 2007
next sibling parent Dan <murpsoft hotmail.com> writes:
Bradley Smith Wrote:
 Both? How do you use both Phobos and Tango in one program? I thought 
 they were incompatible.

Oh. Well then, My Bad(tm).
Apr 17 2007
prev sibling parent reply Gregor Richards <Richards codu.org> writes:
Bradley Smith wrote:
 Dan wrote:
 Fortunately, we have both libraries available for D, and I think the 
 duality is definitely conducive to the language's development.  I can 
 also say that it hasn't been a problem by virtue of the fact that a 
 program may use *either* library *or* both according to your preferences.

Both? How do you use both Phobos and Tango in one program? I thought they were incompatible.

At their core, they are incompatible, because their implementations of Object and such are incompatible. There is an almost-existent library, tangobos, that allows most Phobos software to compile over Tango. I'm going to get that released properly Any Day Now [tm]. (It exists, but I'm very busy today, don't have time to do everything) - Gregor Richards
Apr 17 2007
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Gregor Richards wrote:
 Bradley Smith wrote:
 Dan wrote:
 Fortunately, we have both libraries available for D, and I think the 
 duality is definitely conducive to the language's development.  I can 
 also say that it hasn't been a problem by virtue of the fact that a 
 program may use *either* library *or* both according to your 
 preferences.

Both? How do you use both Phobos and Tango in one program? I thought they were incompatible.

At their core, they are incompatible, because their implementations of Object and such are incompatible. There is an almost-existent library, tangobos, that allows most Phobos software to compile over Tango. I'm going to get that released properly Any Day Now [tm]. (It exists, but I'm very busy today, don't have time to do everything) - Gregor Richards

Tangobos will be great. Can't wait. How are you going to deal with toString/toUtf8? --bb
Apr 17 2007
parent reply Tomas Lindquist Olsen <tomas famolsen.dk> writes:
Bill Baxter wrote:

 Gregor Richards wrote:
 Bradley Smith wrote:
 Dan wrote:
 Fortunately, we have both libraries available for D, and I think the
 duality is definitely conducive to the language's development.  I can
 also say that it hasn't been a problem by virtue of the fact that a
 program may use *either* library *or* both according to your
 preferences.

Both? How do you use both Phobos and Tango in one program? I thought they were incompatible.

At their core, they are incompatible, because their implementations of Object and such are incompatible. There is an almost-existent library, tangobos, that allows most Phobos software to compile over Tango. I'm going to get that released properly Any Day Now [tm]. (It exists, but I'm very busy today, don't have time to do everything) - Gregor Richards

Tangobos will be great. Can't wait. How are you going to deal with toString/toUtf8? --bb

If you look at the tango object.di, there is a version(PhobosCompatibility) block which aliases toUTF8->toString
Apr 18 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Tomas Lindquist Olsen wrote:
 Bill Baxter wrote:
 
 Tangobos will be great.  Can't wait.
 How are you going to deal with toString/toUtf8?

If you look at the tango object.di, there is a version(PhobosCompatibility) block which aliases toUTF8->toString

That still doesn't allow classes to override toString (they'd still need to override toUtf8). Perhaps this should be filed as an enhancement request at IssueZilla (allowing classes to override aliases of member functions)?
Apr 18 2007
parent reply Dan <murpsoft hotmail.com> writes:
As I just said in a different thread.  Tango has this OO gleam in it's eye. 
It's implementing classes for the craziest of things.  Strings don't need a
class!  Implementing a class to store an array is *hugely* wasteful.

Especially since you can already use:

char[] foo(char[] s){
 s ~= " world";
}

char[] myS = "hello";

myS.foo();

Classes are the Microsoft Windows of the programming world; opague, costly,
slow, and they have burdensome licensing.
Apr 18 2007
next sibling parent Sean Kelly <sean f4.ca> writes:
Dan wrote:
 As I just said in a different thread.  Tango has this OO gleam in it's eye. 
It's implementing classes for the craziest of things.  Strings don't need a
class!  Implementing a class to store an array is *hugely* wasteful.

For the most part, I think Tango is OO when appropriate. The objects that exist do so to retain state, and it is rarely, if ever, necessary for a user to define their own objects to use Tango. But that aside, a String is an object, be it a class or a struct. I suppose there's no reason for it not to be a struct--it simply hasn't come up before, and no one has ever complained.
 Especially since you can already use:
 
 char[] foo(char[] s){
  s ~= " world";
 }
 
 char[] myS = "hello";
 
 myS.foo();

Yup. Tango may have a String class, but it isn't used very often. Its real advantage in my opinion is UniString, a generic parent class for String which doesn't restrict the underlying char type. This isn't something that's available with built-in arrays.
 Classes are the Microsoft Windows of the programming world; opague, costly,
slow, and they have burdensome licensing.

I disagree. Heap allocation may be slower than stack allocation, but reference passing is fast, and it is often useful to have control over copy semantics and such. Also, guaranteed reference semantics have some very real advantages in terms of what's possible in a language. Sean
Apr 18 2007
prev sibling next sibling parent Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Dan wrote:
 As I just said in a different thread.  Tango has this OO gleam in it's eye. 
It's implementing classes for the craziest of things.  Strings don't need a
class!  Implementing a class to store an array is *hugely* wasteful.

I think you may be a bit confused. Nobody was talking about a string class here. What we were talking about was the fact that Tango has renamed Object.toString (which returns char[]) to object.toUtf8, and now when compiled with -version=PhobosCompatibility has "alias toUtf8 toString;" added to Object. I was pointing out that classes that override toString won't work even with that line added, since aliases can't be overridden.
Apr 18 2007
prev sibling parent reply Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
Dan wrote:
 As I just said in a different thread.  Tango has this OO gleam in it's eye.
 It's implementing classes for the craziest of things.  Strings don't need a
 class!  Implementing a class to store an array is *hugely* wasteful.
 

From what I understand, the string class in Tango is handy because it handles Unicode text on the code point level. Thus you don't need to worry about whether it's in UTF-8, -16, or -32, and how this affects stuff like slicing. Of course, there's still the problem of combining characters and ligatures.
 Classes are the Microsoft Windows of the programming world; opague, costly,
 slow, and they have burdensome licensing.

I don't quite agree with this, but I do prefer free functions in many cases. I can accept having a File class for "heavy-duty" file handling, but I still find myself missing a simple function for just dumping an ubyte[] array of a file's contents. The "problem" is that Tango is currently just so much *better* than Phobos, idioms aside. -- Remove ".doesnotlike.spam" from the mail address.
Apr 18 2007
next sibling parent reply Alexander Panek <a.panek brainsware.org> writes:
Deewiant wrote:
 [...] 
 I don't quite agree with this, but I do prefer free functions in many cases. I
 can accept having a File class for "heavy-duty" file handling, but I still find
 myself missing a simple function for just dumping an ubyte[] array of a file's
 contents.

http://dsource.org/projects/tango/docs/current/tango.io.File.html auto contentOfAFile = (new File( "filename" )).read; There you go.
Apr 18 2007
parent reply Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
Alexander Panek wrote:
 Deewiant wrote:
 [...] I don't quite agree with this, but I do prefer free functions in
 many cases. I
 can accept having a File class for "heavy-duty" file handling, but I
 still find
 myself missing a simple function for just dumping an ubyte[] array of
 a file's
 contents.

http://dsource.org/projects/tango/docs/current/tango.io.File.html auto contentOfAFile = (new File( "filename" )).read; There you go.

Of course. But I feel uneasy with throwaway objects, like I'm fighting the library. There's probably no good reason to, but I do. -- Remove ".doesnotlike.spam" from the mail address.
Apr 18 2007
next sibling parent reply Alexander Panek <a.panek brainsware.org> writes:
Deewiant wrote:
 Alexander Panek wrote:
 Deewiant wrote:
 [...] I don't quite agree with this, but I do prefer free functions in
 many cases. I
 can accept having a File class for "heavy-duty" file handling, but I
 still find
 myself missing a simple function for just dumping an ubyte[] array of
 a file's
 contents.

auto contentOfAFile = (new File( "filename" )).read; There you go.

Of course. But I feel uneasy with throwaway objects, like I'm fighting the library. There's probably no good reason to, but I do.

I can understand that. I've got an issue with throw away objects, too, but given the fact, that you just want a file's content no matter what format it is... the whole process is a bit hackish, and I'd recommend to use other, less hackish solutions of tango's IO package. Even if that would mean two lines of source code more, you won't have throw away, and a proper, tested way of reading data from a file. Kind regards, Alex
Apr 18 2007
parent Deewiant <deewiant.doesnotlike.spam gmail.com> writes:
Alexander Panek wrote:
 I've got an issue with throw away objects, too, but given the fact, that you
 just want a file's content no matter what format it is... the whole process
 is a bit hackish, and I'd recommend to use other, less hackish solutions of
 tango's IO package. Even if that would mean two lines of source code more,
 you won't have throw away, and a proper, tested way of reading data from a
 file.
 

That's true. Sometimes, however, a hackish method is best. Maybe it's just my general "OO only where it's needed" philosophy showing itself: I'd rather read the raw file contents and work with that, than inherit a Tango file class, redefining methods to handle whatever file format I'm dealing with --- this, I suppose, is what would be the proper "less hackish" method in this case. -- Remove ".doesnotlike.spam" from the mail address.
Apr 18 2007
prev sibling parent torhu <fake address.dude> writes:
Deewiant wrote:
 Alexander Panek wrote:
 Deewiant wrote:
 [...] I don't quite agree with this, but I do prefer free functions in
 many cases. I
 can accept having a File class for "heavy-duty" file handling, but I
 still find
 myself missing a simple function for just dumping an ubyte[] array of
 a file's
 contents.

http://dsource.org/projects/tango/docs/current/tango.io.File.html auto contentOfAFile = (new File( "filename" )).read; There you go.

Of course. But I feel uneasy with throwaway objects, like I'm fighting the library. There's probably no good reason to, but I do.

The only state contained in File is a FilePath instance. Which means you can do things like this: auto f = new File("name"); if (f.path.exists) auto x = f.read(); else printf("file not found!\n"); But since you would probably wrap the whole thing in a try-catch block anyway, I'm not sure I'd ever do it like that. On the other hand, you could also create the file, delete it, get its size etc. So File basically combines FilePath and FileConduit into a single class, that's pretty easy to use. But since the FileConduit part is the most useful aspect of File, I'd also be more than happy if Tango just provided free functions to read, write, append etc. All in all, I haven't used Tango enough myself to really have an informed opinion about this issue. Other people might, though.
Apr 18 2007
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
Deewiant wrote:
 
 I don't quite agree with this, but I do prefer free functions in many cases. I
 can accept having a File class for "heavy-duty" file handling, but I still find
 myself missing a simple function for just dumping an ubyte[] array of a file's
 contents.

I prefer free functions in many cases as well. However, different people have different needs in this area. Some may want such functions to throw an exception on error, others may want a return code, etc. With this in mind, I feel it is often more appropriate to let the programmer define such things for themselves. Particularly since the process is typically trivial. The only issue with wrapping object libraries is the risk of overhead from the construction of disposable objects, but between 'scope' allocation for classes and Tango's tendency towards highly efficient designs (IMO), I don't think that's a concern here. Sean
Apr 18 2007
next sibling parent reply Johan Granberg <lijat.meREM OVEgmail.com> writes:
Sean Kelly wrote:
 I prefer free functions in many cases as well.  However, different
 people have different needs in this area.  Some may want such functions
 to throw an exception on error, others may want a return code, etc.
 With this in mind, I feel it is often more appropriate to let the
 programmer define such things for themselves.  Particularly since the
 process is typically trivial.  The only issue with wrapping object
 libraries is the risk of overhead from the construction of disposable
 objects, but between 'scope' allocation for classes and Tango's tendency
 towards highly efficient designs (IMO), I don't think that's a concern
 here.
 
 
 Sean

I disagree whit it being appropriate to leave the creation of shorthand functions to the users of a library. Of course it's unfeasible to define all the functions potential users might need but I think thouse most needed or used should be defined in the library. This can help to reduse code size of small programs or modules significantly. Regarding the exceptions or error codes issue it could be solved either by providing to versions of the utility functions or by choosing one of them, in the later case the rational is that it is easier to only have to do error handling yourself rather that having to do both error handling and class wrapping. Othervise tango looks great and much more compleat than phobos.
Apr 18 2007
parent Dan <murpsoft hotmail.com> writes:
Johan Granberg Wrote:
 I disagree whit it being appropriate to leave the creation of shorthand
 functions to the users of a library. Of course it's unfeasible to define
 all the functions potential users might need but I think thouse most needed
 or used should be defined in the library. This can help to reduse code size
 of small programs or modules significantly. Regarding the exceptions or
 error codes issue it could be solved either by providing to versions of the
 utility functions or by choosing one of them, in the later case the
 rational is that it is easier to only have to do error handling yourself
 rather that having to do both error handling and class wrapping.
 
 Othervise tango looks great and much more compleat than phobos.

A file doesn't require any sort of class in order to manipulate. It's a raw stream of data. Enter void[]. Want it to be a wchar[]? cast() is a wonderful way to do it. Want to slice off a chunk? Want to perform something on it? Cast it, run it through a function via the notation I suggested earlier. Walter thought of this when he designed the language, and was considered it a design feature that you didn't need to make classes to support primitives. That said, I can see if someone needs to perform operator overloading, wrapping it in a struct (which is transparent and smaller than a class) and then going to it. Classes are inherently big. Want to call a method? It looks up the offset inside an (offsite?) vtbl, and then you lookup &this+offset and call that. 2-6 extra cycles can be trivial, but an offsite vtbl would mean potential cache misses and that's just to call a method, *everything* with classes is messier that way. I honestly don't think classes should *never* be used, I just think they should be used sparingly, when you actually *need* the functionality that a class offers. Occams Razor.
Apr 18 2007
prev sibling parent reply %u <mike.capp gmail.com> writes:
== Quote from Sean Kelly (sean f4.ca)'s article

 However, different
 people have different needs in this area.  Some may
 want such functions to throw an exception on error,
 others may want a return code, etc.

Out of interest, have you seen Andrei's "The Power of None" paper? Quite a cute approach to this problem, and IIRC it should be doable in D. cheers Mike
Apr 18 2007
next sibling parent reply Johan Granberg <lijat.meREM OVEgmail.com> writes:
%u wrote:

 The Power of None

Link?
Apr 18 2007
parent David Gileadi <foo bar.com> writes:
Johan Granberg wrote:
 %u wrote:
 
 The Power of None

Link?

I found some slides at http://www.nwcpp.org/Meetings/2006/05.html which explained the concept quite well.
Apr 18 2007
prev sibling next sibling parent reply Paolo Invernizzi <arathorn NO_SPAMfastwebnet.it> writes:
Very very very cool! We'll use it for sure in our C++ works!
But is it really doable in D?
What about the casts? Or about the GC, and the throws in the destructors 
when the Likely goes out of scope?

cheers, Paolo

%u wrote:
 == Quote from Sean Kelly (sean f4.ca)'s article
 
 However, different
 people have different needs in this area.  Some may
 want such functions to throw an exception on error,
 others may want a return code, etc.

Out of interest, have you seen Andrei's "The Power of None" paper? Quite a cute approach to this problem, and IIRC it should be doable in D. cheers Mike

Apr 18 2007
parent reply Sean Kelly <sean f4.ca> writes:
Paolo Invernizzi wrote:
 Very very very cool! We'll use it for sure in our C++ works!
 But is it really doable in D?
 What about the casts? Or about the GC, and the throws in the destructors 
 when the Likely goes out of scope?

I haven't looked at the slides yet, but it is illegal to throw an exception from a dtor in D, just as in C++. Doing so in Tango will cause the app to exit under normal circumstances. Sean
Apr 18 2007
parent reply James Dennett <jdennett acm.org> writes:
Sean Kelly wrote:
 Paolo Invernizzi wrote:
 Very very very cool! We'll use it for sure in our C++ works!
 But is it really doable in D?
 What about the casts? Or about the GC, and the throws in the
 destructors when the Likely goes out of scope?

I haven't looked at the slides yet, but it is illegal to throw an exception from a dtor in D, just as in C++.

It's not illegal in C++, just generally ill-advised as it will terminate() the program if it occurs during stack unwinding while another exception is active. -- James
Apr 18 2007
parent Sean Kelly <sean f4.ca> writes:
James Dennett wrote:
 Sean Kelly wrote:
 Paolo Invernizzi wrote:
 Very very very cool! We'll use it for sure in our C++ works!
 But is it really doable in D?
 What about the casts? Or about the GC, and the throws in the
 destructors when the Likely goes out of scope?

exception from a dtor in D, just as in C++.

It's not illegal in C++, just generally ill-advised as it will terminate() the program if it occurs during stack unwinding while another exception is active.

True enough. Throwing from a dtor isn't illegal, just effectively prohibited. It's more than just a popular convention though, since many STL classes provide nothrow guarantees from their dtors. Sean
Apr 18 2007
prev sibling parent Sean Kelly <sean f4.ca> writes:
%u wrote:
 == Quote from Sean Kelly (sean f4.ca)'s article
 
 However, different
 people have different needs in this area.  Some may
 want such functions to throw an exception on error,
 others may want a return code, etc.

Out of interest, have you seen Andrei's "The Power of None" paper? Quite a cute approach to this problem, and IIRC it should be doable in D.

A bit difficult without copy semantics, but probably doable. It's an interesting idea. Sean
Apr 18 2007
prev sibling parent reply Daniel Giddings <dgiddings bigworldtech.com> writes:
Dlé wrote:
 Hello people!
 
 I'm working and studing this new (for me :-) ) language. I have some questions
and i think your opinion is so precious for me.
 
 First, D is a new language.The official library is Phobos. Why another library
how Tango that is not compatible with Phobos? Because Tango is opensource and
the comunity can develop the library?
 
 Why not a concept how java for example, where we have only one big family of
class?
 
 Fundametals differences between Phobos and Tango?
 
 Tank's!
 
 I wait your opinions!
 
 Dié
 

It is rather unfortunate having both. Ideally Tango should be a stand-alone library that is an optional (and useful) extra. [Aside: is it possible to get the incompatible code in some way included in Phobos so they can run alongside happily? - are the incompatibilities in Tango enough to break large portions of Phobos if they were moved to it?] They are incompatible however, forcing anyone developing to choose between the two and fragmenting libraries where developers haven't explicitly supported both.
Apr 17 2007
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Daniel Giddings wrote:
 Dlé wrote:
 Hello people!

 I'm working and studing this new (for me :-) ) language. I have some 
 questions and i think your opinion is so precious for me.

 First, D is a new language.The official library is Phobos. Why another 
 library how Tango that is not compatible with Phobos? Because Tango is 
 opensource and the comunity can develop the library?

 Why not a concept how java for example, where we have only one big 
 family of class?

 Fundametals differences between Phobos and Tango?

 Tank's!

 I wait your opinions!

 Dié

It is rather unfortunate having both. Ideally Tango should be a stand-alone library that is an optional (and useful) extra. [Aside: is it possible to get the incompatible code in some way included in Phobos so they can run alongside happily? - are the incompatibilities in Tango enough to break large portions of Phobos if they were moved to it?] They are incompatible however, forcing anyone developing to choose between the two and fragmenting libraries where developers haven't explicitly supported both.

From what I'm guessing based on what Gregor said, his "Tangobos" will be based on Tango, but will allow you from a Tango app to do things like "import std.string;" How he's going about it... I don't know. I think you pretty much have to create a modified copy of the Phobos source tree with all instances of toString changed to toUtf8. Then you need to make a compatibility std.gc module that delegates all the heavy lifting to Phobos. toString to toUtf8 should be pretty easy to automate with sed/perl/std.regex. The std.gc stuff used in phobos looks pretty minimal. Just file.d,outbuffer.d,stdio.d, and zlib.d seem to call the gc directly. Although toString is also a standalone function in addition to being a method on Phobos' object. So I guess that makes it a little trickier to translate. Oh, and there are exceptions to deal with too. And probably a few more things I haven't thought of but Gregor is knee-deep in trying to get working. --bb
Apr 17 2007