discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: C++ templates (was: Re: To all german speaking 'steppers: article in


From: Tima Vaisburd
Subject: RE: C++ templates (was: Re: To all german speaking 'steppers: article in german C'tmagazine <VirusChecked>)
Date: Thu, 29 May 2003 22:16:37 -0700
User-agent: KMail/1.4.3

Hello everyone,

After some hesitation I send this. I apologize it went too long.
All the claims are striclty imho.

On Wednesday 28 May 2003 08:34, Chris B. Vetter wrote:

> On 21 May 2003 21:50:25 +0200
> Stefan BĐ–hringer <stefan.boehringer+usenet@uni-bochum.de> wrote:

>> The deeper reason for templates is, that C++ used to be crippled
>> before templates were introduces. How would one implement an array of

> You might want to take a look at
> http://www.kuro5hin.org/story/2003/5/26/22429/7674

This is a very interesting article, but it criticizes C++ from somewhat 
different angle. It says that generics can be done better, smarter that C++ 
templates, while Stephan's point is we do not need that kind of things at 
all.

With mandatory type checking and no garbage collectiontemplates become a smart 
solution, but that only suggests that mandatory type checking is an 
artificial constraint. And still, imho, generic (template) programming that 
C++ promotes is less convenient and more restrictive than Objective C way for 
most practical situations.

Examples:
-- it's awkward to create a good interfaces (e.g iterators not exposing 
underlining data structures, like NSEnumerator) that can be used as
a library interfaces or between processes. Things like
    template <class It> void insert(It first, It last); 
are only good within a dll or executable;

-- it's sometimes hard to localize the piece you're going to make a template, 
especially if template parameter has to be a key in a map, say.
Then one template pulls another, making half of your classes templatized, this 
leads to code bloat;

-- C++ has, like C, pointers to functions, but does not have good pointers
to methods. In C++ a pointer to method is a triple - method address,
object address and the method's _class_, which makes it hard to store and
yes, requires templates to manipulate (see e.g. Rich Hickey's callback library
http://www.tutok.sk/fastgl/callback.html, code at 
http://www.function-pointer.org/zip/callback.zip).
In Objective C it's just a pair selector - receiver, both normal variables.


There is another, less techical consideration. The article at kuro5hin.org
compares C++ to ML and Scheme, both quite away from mainstream.
That makes its criticism very much theoretic, for noone is really proposing a 
switch. In contrast, a swtich to Objective C is real.

That's why I support the idea of an article that would stress the power
of Objective C versus C++. Objective C promotion can help to make it
as widespread as should be.


Thank you,
Tima.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]