Re: Java and Objective-C
Re: Java and Objective-C
- Subject: Re: Java and Objective-C
- From: "Michael Ash" <email@hidden>
- Date: Sat, 7 Jun 2008 21:51:30 -0400
On Sat, Jun 7, 2008 at 6:08 PM, Ken Ferry <email@hidden> wrote:
> On Sat, Jun 7, 2008 at 2:10 PM, Denis Bohm <email@hidden> wrote:
>>
>> On Jun 7, 2008, at 2:01 PM, Bill Bumgarner wrote:
>>
>>> Actually, any object oriented language that
>>> has the ability to inline methods such that they cannot be "out of lined"
>>> again at runtime cannot support the dynamism offered by Objective-C.
>>
>> Can you give a specific example of that specific point using some
>> Objective-C code?
>
> Are you familiar with key-value observation?
>
> <http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html>
>
> With KVO you say, "I would like to be notified whenever property foo
> of object bar changes", and you can pass some options about what
> information you want. It's a controlled form of aspect-oriented
> programming (since you come from Java and might have run into that).
> It was added in 10.3.
>
> Implementation wise (and this is not to be relied on), when you begin
> observing an object, the object's class is dynamically subclassed, and
> the property accessors are overridden. The overrides call the
> original implementation and also do the notification of interested
> parties. The original object changes class so that it is now an
> instance of the subclass.
>
> When you stop observing, the object's class changes back to the original class.
>
> An inlining JIT would have trouble with this.
No JIT worth anything should have any trouble with it. In fact this is
one of the big *advantages* of a JIT, it allows you to inline method
calls while still maintaining full dynamism.
A JIT will inline where it can. It will also watch for new code being
loaded which invalidates the assumptions made while doing so. When
that happens, it throws out the affected code and recompiles it on
demand. Because they run concurrently with the program they're working
on, JIT compilers can be much more flexible than regular compilers in
this regard.
Note that LLVM can run as a JIT compiler if desired. Apple is busily
adding ObjC support to LLVM and there are no indications that there
will be any particular difficulties involved due to the nature of
ObjC.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden