Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mac OS X Java Performance



Could you please provide some examples of the elegant solutions which are prevented?

Sure. If all you care about is Java - hit delete now.

Since you have a Mac, if you get some time, try to learn to write a Cocoa application with ObjectiveC. ObjectiveC is about the best compromise you could make between C and Smalltalk. Or you can download Squeak at squeak.org. Anyhow here's the idea.

In java if you have someObject.doSomething(argument) the method doSomething *must* exist. The idea that it might not is simply inconceivable.

A little syntax - someObject.doSomething(arg1,arg2) is written someObject doSomething: arg1 and: arg2. I know it looks weird to you because its new - but in time you get to prefer it because you can read this out loud and it makes sense. The name of the Smalltalk (or Objective C - they use the same syntax) method is doSomething:and:. Its just syntax.

The key difference is that there is no guarantee that there is a method on someObject called doSomething:and:. There might not be. The compiler doesn't care. These are both message sending (vs function calling) languages. Each object is like a little server. You send it a message - it tries to respond. Like a web server. If there is no method (methods are handlers - messages are requests), then a different method called (depending on language - I'll stay with Smalltalk for the moment) doesNotUnderstand: aMessageContext gets invoked.

The implementation of DNU in Object (top level thing) will typically halt the current thread and toss up a debugger so you can see how you got here. You can override this and do other cool things though. For instance, you could be a proxy for an object across the internet and wrap the messageContext up as a network message and send it out a socket. What's cool is you only need one kind of proxy class to proxy for all classes - as opposed to Java's RMI which uses code generation to generate a different proxy class for every kind of object. Really wasteful.

Another capability DNU allows is the ability to be a proxy for some chunk of data in a database. Its essentially a query waiting to be triggered. On first invocation of DNU, the object executes the query and does a become: queryResults forward: aMessageContext which replaces itself with the results of the query and reinvokes the original message. Thus you get object faulting.

The use of function calling rather than message sending prevents these techniques. Leaving a rather staid and boring programming environment with no opportunities for creativity. Plus, its still edit, compile, debug. Smalltalk is more alive.

For instance, I was debugging a message handler stepping through code that pulled events from a queue and processed them. It was getting tedious stepping to the message I was interested in - so I popped open an inspector on the queue and saw that there were about 30 message in the way - so I executed the script [queue peek type == typeIWant] whileFalse: [self next] to pull all the extra messages out of the queue. That sort of thing isn't really doable in Java (I suppose you could use BeanShell and make an inspector and some other things - but the debuggers don't support this for some reason).

Cheers.

On Thursday, July 31, 2003, at 06:36 AM, Thorbjxrn Ravn Andersen wrote:

Todd Blanchard wrote:


Anyhow, it is true that Gosling was trying to create a language that appealed to C++ developers and pretended to prevent a number of classes of stupid mistakes. It does. At the expense of preventing a large number of elegant solutions.

Could you please provide some examples of the elegant solutions which are prevented?

I would like to know what I miss, since I have only programmed in plain C, where string handling is a bit cumbersome.


--
Thorbjoern Ravn Andersen Scandiatransplant
Skejby Sygehus, indgang 3
+45 89 49 53 01 DK-8200 AArhus N
http://biobase.dk/~tra
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Mac OS X Java Performance (From: Thorbjørn Ravn Andersen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.