Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to adjust myself to JAVA

 
Tracy Tse
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff:
I used to be a JAVA fan when i first learned JAVA,but now i like C++ the best.Every time a idea hit me, my first response is how to implement it in C++.I know that JAVA is relatively simple and safe comparing to C++, but it is quite slow.

My puzzle is that i love android phone and wanna do something in the android development world.But i just hate coding in JAVA,there got to be a time for me to adjust myself.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tracy Tse wrote:but it is quite slow.


Hmm. it is java 1.7 now . slow? nope. there are many discussion here in javaranch regarding this.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tracy Tse wrote:... I know that JAVA is ... quite slow...

Why do you say this?
 
Jeff Friesen
author
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tracy,

In its early days, Java was quite a dog speedwise. However, the introduction of a just-in-time compiler and other improvements to the Java runtime environment have greatly improved Java's performance.

I believe that the main reason for slow Java applications lies with how those applications are coded. For example, an application that constantly allocates memory for objects and arrays, and releases this memory via null reference assignments may see the garbage collector run more often, which can provide intermittent pauses in the application's execution. (I call such pauses "hiccups".)

There are many ways to improve performance, and here are a few suggestions:

1) reuse objects

2) use System.arraycopy() to copy one array to another

3) take advantage of String internment for String comparisons

My book dives deep into the Java language, explaining such things as String internment. It also points out where you can directly access an object's private fields and call its private methods (for performance) without having to rely on the Reflection API (which is slow). I believe that a solid understanding of the language will help the developer create better-performing applications, and providing this knowledge is what I have attempted to achieve in my book.

Regarding Android, you might find the Inside the Android Application Framework video to be enlightening. Among other things, Google's Dan Morrill suggests that Java need not be the only way to create Android apps.

All the best.

Jeff
 
Tracy Tse
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Friesen wrote:Hi Tracy,

In its early days, Java was quite a dog speedwise. However, the introduction of a just-in-time compiler and other improvements to the Java runtime environment have greatly improved Java's performance.

I believe that the main reason for slow Java applications lies with how those applications are coded. For example, an application that constantly allocates memory for objects and arrays, and releases this memory via null reference assignments may see the garbage collector run more often, which can provide intermittent pauses in the application's execution. (I call such pauses "hiccups".)

There are many ways to improve performance, and here are a few suggestions:

1) reuse objects

2) use System.arraycopy() to copy one array to another

3) take advantage of String internment for String comparisons

My book dives deep into the Java language, explaining such things as String internment. It also points out where you can directly access an object's private fields and call its private methods (for performance) without having to rely on the Reflection API (which is slow). I believe that a solid understanding of the language will help the developer create better-performing applications, and providing this knowledge is what I have attempted to achieve in my book.

Regarding Android, you might find the Inside the Android Application Framework video to be enlightening. Among other things, Google's Dan Morrill suggests that Java need not be the only way to create Android apps.

All the best.

Jeff

Thanks for your advice.I need to re-consider JAVA.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic