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



On Thursday, July 31, 2003, at 06:08 AM, Peter Wayner wrote:

At 2:36 PM +0200 7/31/03, 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.

Consider language Foo with neat function/method/subroutine Bar. Can you do Bar in one line of Java code? Can you do Bar in only three characters with Java? Nope. I bet not. Ergo Java is not as elegant as Foo.

I was once at a programming interview. One geek, who didn't want to hire me, was giving me questions. He asked me to solve some problem so I wrote out 20 lines using primitives. He announced that I was obviously a loser because there's a library routine that could accomplish the same task in one line of code. One Line! That's elegance and efficiency.

After a few minutes I realized that no one knew how many primitives the library routine would execute. It could be hundreds because the library routine was pretty general and designed to handle regular expressions. After I pointed this out, the question of elegance and efficiency was dropped.

I think elegance is an important concept. It's great when people aim to make their solutions as elegant as possible, but I think it's hard to compare solutions and try to decide which is more elegant. Unlike execution speed, there's no good metric.

Of course the other side of that coin is how often will this mythical method be called? Once, twice, 10 times a second, etc. Would the "generic library" method be a performance issue in the real world?

Without knowing that you have no good reason to not use the provided "generic" method. It will result in less code you have to support in the future and at such time as is does become a performance issue (you profile right?) you could consider recoding it. It is almost always better to leverage platform provided framework/libraries/packages then roll your own (unless you hit profiled performance issues or bugs, also it is wise to use proven frameworks/libraries/packages). Doing so results in less code that you have to write, test, and maintain. It also makes you product compact, because it has less code in it.

I would call that the wiser solution...

-Shawn
_______________________________________________
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: Peter Wayner <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.