Java's execution speed

Hi:
   I'm new in the Java world, I'm still learning the basics about AWT and Swing. My question
is about the java speed, I've tried some shareware IDE's (included Java Forte) and all of them
are extremely slow.

   That's why I'm wondering if java is used for "real" applications or is just used to
make applets. And if some of you really use java to build applications, Is there any way to
make the execution of a .class or .jar file faster comperable to the speed of an executable build
in C++ or VB?
LVL 1
GustavoValdesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

msrikantCommented:
hi GustavoValdes,
      u see, java is an object oriented language, where everything is references and these references points to objects. The objects are created dynamically on the heap. This dynamic allocation is a very time consuming process. In a way that the language has to frequently do garbage collection of the objects in the heap which have no references pointing to it, for the better memory utilization. But u may ask how does the C++ differ from this language. The answer is: C++ does allocate objects in the heap but does not perform any garbage collection. The garbage collection is to be taken care by the programmer.
      And this is the main reason why any java program runs very slowly.
      If u still don't get what i explained may u contact me through e-mail.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
imladrisCommented:
Nevertheless, Java is used for "real" applications (I am involved in such a thing). It is not, at present obviously, suitable for applications that require top of the line performance. But that is not a requirement for all applications.
0
msrikantCommented:
Yes java is used in many real applications but most of them just hangs up. Let me give an example, I think u know about Applets in java. They literally run very slowly( I have written many programs in Applets in my course of study, similarly i have written many win32 applications. I find that win32 applications run much faster than the Applet programs). If I am wrong please correct me( please explain with examples).
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

GustavoValdesAuthor Commented:
msrikant,I undestand your explanation about the garbage collection (with a reference book in my hand of course), but what I really want to know is: Is there any way to make the execution faster? I've seen many bat files that start the execution of a java class with an assorted variety of command line parameters like -x32...? Are these parameters used to increase the performace of the program?
0
mbormannCommented:
GustavoValdes,

referring to msrikant's comment

>>>>>
The objects are created dynamically on the heap. This dynamic allocation is a very time consuming process.

this time is a little bit more in Java as compared to C++ ,which is still slower compared with C.
The reason is that this new MyClass() request goes to the JVM which is implemented in C or C++ which does the actual allocation on the client Operating System through calls to C/C++. Remember Java is portable but the JVM is not.

>>>>>
C++ does allocate objects in the heap but does not perform any garbage collection.

C++ also allocates local objects on the Stack which is blindingly faster than the heap.
0
mbormannCommented:
>>>>>Java is used for "real" applications (I am involved in such a thing). It is not, at present obviously, suitable for applications that require top of the line performance.

Very true ,spending $1000-2000 more on a hot shot PC is better than spending many more on a hot shot programmer,this is the statement by a hot shot head honcho,I forget but where

>>>>>Is there any way to make the execution faster?
(1)Compile it to native code
(2)Use Hot spot JVM
?
0
msrikantCommented:
Increasing performance is a difficult task but I suppose it can be done by creating the min. number of objects that are required. One more thing String Comparision is one more thing that one can minimize to increase the performance.
      I don't have much knowledge of java's Execution speed but make it a point that java runs slower than C or C++.
0
mbormannCommented:
Well I second imladris over here
:)
0
msrikantCommented:
to mbormann,
      what does this "second imladris" mean.
0
mbormannCommented:
imladris 's statement >>>
Nevertheless, Java is used for "real" applications (I am involved in such a thing).

is true and I am also working in such a application,also much of what you said abt Memory and speed is true but it is mostly applicable to Applets .and that is going as the Java platform matures faster than any Language in the past 40 years, I think that Sun can claim that they have made it a huge success. The speed differential of Java with C++ which was 20/30 a couple of years ago has dropped to less than 4 with all advances which are too numerous to mention here.

>>>Let me give an example, I think u know about Applets in java. They literally run very slowly.

This is not true for applications ,Server Side Java is running stronger than ever,that is the reason they are starting another New Topic at EE.
I have spent close to 15 months in Java and have used Applets very little,I can claim proudly that I don't know of everything related with GUI's that much.

But a person who is capable of designing ,coding & testing their own classes can easily and smoothly migrate to GUI's.

Whereas a person who is mostly used to inserting code which ur favourite IDE generates for you is going to find it very tough doing everything .

I also done some GUI stuff but by old fashioned typing ,no IDE stuff.
Hope u understood.
:)
0
msrikantCommented:
yes i understand
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.