aspose file tools*
The moose likes Java in General and the fly likes java programs run slower than VB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java programs run slower than VB" Watch "java programs run slower than VB" New topic
Author

java programs run slower than VB

saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hi
anybody plz justify this ..
why java programs are very slow... when compared to other programs which r developed in VB or C lang.?

and morever according to java BUZZ words JAVA is high perfomance,multi threading,robust,simple,portable,scured... etc... are there


but there is no hi performance in any java application why?



cinux


A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Java programs aren't slow in general.

If you have a specific example of a slow Java program, we could discuss how to improve it.

Stated in such a general way, it very much sounds like trolling, thoug...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

I don't know where you get your information from, but you are way off base.

Java performance on numerical code is comparable to that of C++, with hints that Java's relative performance is continuing to improve.

Java Pulling Ahead?

The results I got were that Java is significantly faster than optimized C++ in many cases.

Java is Faster Than C++

And there's more where they came from. Now consider the fact that Java was not designed to be fast. It was designed to do two things:
Be platform independent
Fix the glaring flaws in other programming languages (like direct memory access and unchecked arrays in C and C++).
These and other features in Java make it easier to write an error-free program with Java. A programmer using Java can be more productive than when using C or C++. Since powerful processors are cheap and programmer time is expensive, the real advantage of Java is in cost-of-use rather than processing performance (which the links above prove is on par with C++ anyway).


[How To Ask Questions On JavaRanch]
Mark Wuest
Ranch Hand

Joined: Jun 07, 2003
Posts: 88
Originally posted by Joe Ess:

Fix the glaring flaws in other programming languages (like direct memory access and unchecked arrays in C and C++).


'Not to start a war (I'm bilingual and have *preferred* Java to C++ pretty much from the day I first started learning it), but the former "flaw" allows you to write device drivers (I can't imagine how you'd do it only in Java) and the latter has been addressed in C++ with the vector included At No Extra Charge in the STL. Programming self-help books (like the "Effective" and "Exceptional" series) encourage C++ folks to go for vectors over arrays.

Mark
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9


but the former "flaw" allows you to write device drivers (I can't imagine how you'd do it only in Java)

I don't know any real-world implementation, but apparently it is possible with NIO:

a ByteBuffer object can be wrapped around any memory address the native code can obtain, even memory outside the JVM's own address space. One example is creating a direct ByteBuffer object that encapsulates the memory on a video card. Such an buffer enables pure Java code to read and write directly to video memory with no system calls or buffer copies. Pure Java video drivers!

OnJava.com: Top Ten Things You Can Do With NIO
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

perhaps saikrishna uses a 1.1 jvm?


http://home.arcor.de/hirnstrom/bewerbung
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Java is slow? Probably a poorly written program (although GUI libraries such as Swing are questionable, but excellent alternatives such as SWT are available). Its very fast on the server side (J2EE) and I use a few programs on clients too, which use extensive GUI libraries. Admittedly, I have used some Java programs which have been slow in execution, but I know its down to poor coding.

Bare in mind that Java is interpreted and C/VB are native.
[ May 21, 2005: Message edited by: Kashif Riaz ]
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

I have a friend who works for Sun's VM group. He told me a secret. Sun doesn't want fast Java. They have a group created VM which runs any Java program 100 times faster than VB. That VM was frozen and entire group fired. Fast Java means that nobody will buy new hardware, Java program will run as a rocket on 10 years old hardware. I hope you understand the reason. Right, Sun makes money on hardware, Java is free. From other side VB isn't so Microsoft is interested in sold VB as a product.


Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hey blog i dont agree with it.
java is slower that microsoft produts and u r saying eactly wrong reg this issue.
If javasoft has fastest virtual machine it would have been already released for the reputation. and morever sunsoft is a non profit organization and it doesn't seel any software or hardware.. ok
and if you say it is faster then why dont they atleast provide the speed as the microsoft products.

For an instanc.. take an application(standalone) like swing application with hundered buttons and an application developed in VB with hundred buttons.
then start both the programs at the same time. then u can see it that java program is always starts very slow than when compared to VB program

cinux
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

Originally posted by saikrishna cinux:

For an instanc.. take an application(standalone) like swing application with hundered buttons and an application developed in VB with hundred buttons.
then start both the programs at the same time.


I understand a hammer is a great tool for driving in nails. Why would we ever need a screwdriver?
If you are programming GUI's with 100 buttons, VB sounds like the tool of choice. Those of us who are seeking reasonable processing speed, a robust API for doing client and server-side work not to mention large open-source projects to draw on find Java a good match.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
If you are programming GUI's with 100 buttons, VB sounds like the tool of choice
then platform independency goes astray....


java amateur
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by saikrishna cinux:
For an instanc.. take an application(standalone) like swing application with hundered buttons and an application developed in VB with hundred buttons.
then start both the programs at the same time. then u can see it that java program is always starts very slow than when compared to VB program


That the Java program *starts* slower doesn't mean that it necessarily also will *run* slower once it is started and the HotSpot engine warmed up.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by D Rog:
They have a group created VM which runs any Java program 100 times faster than VB.


Wouldn't that mean that they run faster than Assembler? Quite an accomplishment... :roll:
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I don't believe the story of the fast jvm, 'D Rog', but I don't believe a VB-Application is normally running faster than java.

The startup-time of the jvm IS mearuably not the fastest thing, but after startup, my applications and applications I've seen, are fast.
If I measure the time, an emulator needs to start on my machine, to run VB code, java is much faster.

Of course, the time to run an application shouldn't depend on the number of buttons.
I wouldn't even expect this from VB.

And AFAIK java supports a clear design better than VB, which makes it faster in development and maintainance.
Arjun K
Ranch Hand

Joined: Mar 09, 2005
Posts: 39
Java interpreter creates byte code which need to be run independently on any platform; for that it requires a JVM. So JVM is another layer of abstraction from the aplication to the underlying hardware; which interprets to the machine readable form.

People say its not advisable to use Java in device drivers; but the bad design makes the applications to perform low rather than the Java language itself. With latest facts which says that Java is embedded in 450 million PDA devices; lang used in Mars Rover(communicaton from Mars to Earth), increasing gaming s/w's with Java. And the list will never end.

Arjun.
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
hi to all

i agree that the java application achieve's the speed similarto a VB application after some time may be after 1 or 2 minutes after starting the application.
But why it is very slow at starting of the application and morever some large applications doesn't show the user interface (GUI components) for 5-10 sec's.
yes i have tested it by running LIME WIRE application developed in java


MY assumption:
:roll:
i think that
as soon as the application is started the java runtime environment(JRE)starts creating the objects in the heap. so for this it takes some time (i think)

if this this is not correct can any one please explain me that actaully what happens at the stating of a java application has run.

thanks in advance

cinux
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071

When I run this I see a the JFrame pop up in less than a second, probably less than half a second. That tells me that the act of starting the VM and allocating screen resources is not the issue.

Lets try something a little larger.


This takes about a second to display. It's not a very fancy layout, but most of your GUI's are not going to have as many as 100 components in them.

This tells me that component creation is probably not a big bottleneck. Now we haven't ruled out Layout and we've only limited ourselves to a couple of components here, also we haven't referenced, and therefore loaded, a couple hundred classes such as you might see in a real app.

Often times the bottleneck involves reading properties from files, opening network or DB connections, and doing other setup before displaying anything to the user. Usually simply poping up a splash screen to let the user know that the program started makes the wait seem much less between the double click and the actual program getting up and running.
[ May 24, 2005: Message edited by: Steven Bell ]
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
ok Mr. accept with it but.
as when compared to other applications like VB or C programs
it doesn't take less memory space while running.
why?

yes i have test 2 applications one in Vb and the other in java
and i have gone to taskmanager and i have seen that java application takes much memory space than any other applications.
so ultimately it requires a lot of main memory i.e RAM .
so i think javasoft is making a big mistake reg. this issue.


cinux
Mark Wuest
Ranch Hand

Joined: Jun 07, 2003
Posts: 88
Originally posted by saikrishna cinux:
ok Mr. accept with it but.
as when compared to other applications like VB or C programs
it doesn't take less memory space while running.
why?

yes i have test 2 applications one in Vb and the other in java
and i have gone to taskmanager and i have seen that java application takes much memory space than any other applications.
so ultimately it requires a lot of main memory i.e RAM .
so i think javasoft is making a big mistake reg. this issue.

cinux


I'm not really wanting to jump into the fray here, but am just curious - when you ran your 2 applications on platforms other than Microsoft Windows (e.g.: Mac OS-X, HP-UX, Solaris, VxWorks, Linux), how did they compare?

Java has many more goals than being the fastest. I'm pretty sure that that never has been a goal. Safe, cross-platform code has been and the fact that it really does perform quite well is lagniappe, IMHO. I would guess that memory differences between your Java and VB app are due to the way you implemented the code and to different memory management goals and to tuning.

Mark
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Originally posted by saikrishna cinux:

yes i have test 2 applications one in Vb and the other in java
and i have gone to taskmanager and i have seen that java application takes much memory space than any other applications.


And going to taskmanager is where you went wrong. The memory usage you see in taskmanager is not the memory usage of your Java application. The JVM allocates memory from the OS and holds it so that it is available to your application when it needs it. You can't get any kind of understand of the memory usage of your application by looking at the taskmanager other than an upper bound.

Also how can you say 'Java applications use more memory than any other application'? That is a pretty ridiculous statment. What applications are we comparing the memory footprint of? Are we compairing NetBeans to notepad?

It wouldn't surprise me if, for example, a Java program uses a little more memory than the same program written in C++, but is it really a significant amount, and does it actually cause any problems? I doubt it. If there is any real memory impact I would suspect the chance of memory leaks in the Java progam to be significantly lower (yes you can have a memory leak in a Java progam).
Edwin Keeton
Ranch Hand

Joined: Jul 10, 2002
Posts: 214

I'm not really wanting to jump into the fray here, but am just curious - when you ran your 2 applications on platforms other than Microsoft Windows (e.g.: Mac OS-X, HP-UX, Solaris, VxWorks, Linux), how did they compare?


How much does it cost to get a Windows app in VB to run on Solaris? Is there a Windows emulator for Solaris?


SCJP, SCWCD
Edwin Keeton
Ranch Hand

Joined: Jul 10, 2002
Posts: 214

yes i have test 2 applications one in Vb and the other in java
and i have gone to taskmanager and i have seen that java application takes much memory space than any other applications.
so ultimately it requires a lot of main memory i.e RAM .


You also need to understand that the VB program is using a significant piece of memory that is built into the Windows operating system. (Most or all of the GUI widgets for one example.) But taskmanager does not report that chunk of memory as being used by your app.
Mark Wuest
Ranch Hand

Joined: Jun 07, 2003
Posts: 88
Originally posted by Edwin Keeton:
How much does it cost to get a Windows app in VB to run on Solaris? Is there a Windows emulator for Solaris?


Since insignia doesn't seem to be in that business any more, I'm not sure what (if any) the choices are (I used to use an IPX with SoftPC on it). I'm hoping the original poster knows, since running a test on a platform intentionally tweaked to make VB perform well isn't really a valid test, IMHO. I suspect that he can't get the VB program to run on at least a few of the many platforms that support Java, further invalidating any test.

Mark
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Originally posted by Edwin Keeton:


You also need to understand that the VB program is using a significant piece of memory that is built into the Windows operating system. (Most or all of the GUI widgets for one example.) But taskmanager does not report that chunk of memory as being used by your app.



hi Mr edwin

so what u wanna say about this.so VB programs takes the same amount of memory as java program?
but u say that Vb takes the memory but it internaly takes is'nt it?



cinux
saikrishna cinux
Ranch Hand

Joined: Apr 16, 2005
Posts: 689
Originally posted by Edwin Keeton:


You also need to understand that the VB program is using a significant piece of memory that is built into the Windows operating system. (Most or all of the GUI widgets for one example.) But taskmanager does not report that chunk of memory as being used by your app.



hi Mr edwin

so what u wanna say about this.so VB programs takes the same amount of memory as java program?
but u say that Vb takes the memory but it internaly takes is'nt it?



cinux
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
The short answer of it is the windows taskmanager is NOT a profiling tool.

Personally I've never seen any measurements comparing memory usage between Java and VB. Maybe VB uses more, maybe Java uses more I don't know. Although the amount of effort required to come up with some sort of valid measurement would be, in my opinion, quite high and the results are likely to be of little use.
Edwin Keeton
Ranch Hand

Joined: Jul 10, 2002
Posts: 214

No I didn't want to say that a VB program takes the same amount of memory as a Java program. My point was that any VB program utilizes a fairly substantial chunk of code (memory) that is supplied by the operating system. Therefore it is impractical to try to compare the memory footprint of VB and Java applications.

Further, as was noted more than once, taskmanager is not a profiling tool.
Mark Wuest
Ranch Hand

Joined: Jun 07, 2003
Posts: 88
Originally posted by Edwin Keeton:
My point was that any VB program utilizes a fairly substantial chunk of code (memory) that is supplied by the operating system.


Entering the fray

To be really clear, it is my opinion that Microsoft Visual Basic programs, Microsoft Visual C++ programs, etc. running on a Microsoft Windows platform are probably faster and probably take up less non-o/s memory than even, say, Borland's equivalent. Microsoft notoriously ties these things all together (remember trying to unbundle Internet Explorer?) and puts out a highly monolithic, uh "thing". This, along with some other practices, draw and even tie developers to stick with Purely Microsoft solutions. Some poor schmuck like the original poster does a couple of rudimentary tests and observes that Microsoft Products run better (in many cases - it's evidence of their folly that it isn't always true) on Microsoft Windows than the competition. It's compelling enough to convince a lot of developers to hitch their wagons to Microsoft.

I'd guess that most of us like Java because Sun appears to be Doing The Right Thing and than Java doesn't tie our fortunes to any particular company or personality. That, plus it's easier to write Good Code than C++ or any variant of Basic (Visual or Invisual) and performs pretty darned well.

Mark
[ May 27, 2005: Message edited by: Mark Wuest ]
 
jQuery in Action, 2nd edition
 
subject: java programs run slower than VB