[Mono-list] Re: Is Objective-C support possible?

Martin Coxall coxall@cream.org
15 Feb 2002 21:59:37 +0000


> Were you to write Objective-C support for .NET the biggest performance 
> challenge would be getting selectors to work. The method dispatch system in 
> .NET is vtable oriented, but Objective-C is based on dynamic dispatch.

...

> You could use the reflection calls to dispatch a selector on every call, 
> but this would be slow.

Well, this is essentially what Objetive C does as well, so there's no
reason reflection can't be used to achieve all these tricks. And as for
it being slow, well, it doesn't matter since it's something Objective C
programmers are already used to... ;-)

> This was a design tradeoff by the .NET designers, vtables are fast and 
> dynamic dispatch is awesome.  Dynamic dispatch makes Objective-C what it is.
>   MS chose fast...

MS chose to make c# a statically typed language, but provided the means
of utilising dynamic typing via reflection. This is always going to be
slower, but then, dynamically typed languages always have been slower
than statically-typed languages, so there's nothing new here.

> Any by the way, Categories are __AWESOME__. They allow you to customize 
> classes in ways that are not possible in other systems. These people often 
> resort to hacks like __FACTORIES__.

Nah, it's just they dynamic typing vs. static typing issue again.
Categories are just dynamically-typed factories. Again, you could use
reflection. Again, it would be slower than factories.

> Quick lesson on Categories (not interfaces). Categories are not multiple 
> inheritance, they are still single inheritance. However the inheritance 
> chain is dynamic at runtime, so you can insert new classes into the chain.

Because c# is statically typed, objective-c is dyn... I think you get
the idea.

> However you could add the categories to the system using some re-naming 
> tricks at runtime by injecting new types into the system.

The reflection API can pull of all of these tricks. We just have to make
sure that our reflection classes are *fast*.

Martin