Phobos vs Tango! What's your opinion?

Dan murpsoft at hotmail.com
Wed Apr 18 10:20:42 PDT 2007


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.



More information about the Digitalmars-d mailing list