VC++ VS Java Performance test

Can anyone show me the link or article on the performance test conducted by any organization? Generally, is C++ better than Java?
[143 byte] By [ckyap-rookie] at [2007-9-30 23:17:48]
# 1

> Can anyone show me the link or article on the

> performance test conducted by any organization?

http://www.google.com/search?q=Java+C%2B%2B+comparison&ie=UTF-8&oe=UTF-8

> Generally, is C++ better than Java?

Generally, would you care to define "better"?

tsith at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 2
faster, better exception handling, using less memory, and so on!thanks
ckyap-rookie at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 3
> Can anyone show me the link or article on the> performance test conducted by any organization? The web is flooded with them.> Generally, is C++ better than Java?Generally, is a hammer better than a screwdriver?
CeciNEstPasUnProgrammeur at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 4
> > Generally, is C++ better than Java?> > Generally, is a hammer better than a screwdriver?yes, as it serves more purposes. You can for example use it to administer anesthetic to people claiming C++ is better than Java :)
jwenting at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 5

> > > Generally, is C++ better than Java?

> >

> > Generally, is a hammer better than a screwdriver?

>

> yes, as it serves more purposes.

> You can for example use it to administer anesthetic

> to people claiming C++ is better than Java :)

Or people claiming Java is better then C++.

sigh, i hate these discussions that come around every single day, bloody twerps not knowing what they're talking about.

salpeter at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 6

If you believe your application might not perform well enough when implemented in Java, there is little reason to believe implementing it in C++ would improve things.

> Generally, is C++ better than Java?

> faster, better exception handling, using less memory, and so on!

No.

"faster": C is faster than C++.

"better exception handling" means what?

"using less memory" would normally imply a performance penalty.

and so on.

tschodt at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 7
> sigh, i hate these discussions that come around every> single day, bloody twerps not knowing what they're> talking about.What do you mean? Everybody knows that Java is slow.
CeciNEstPasUnProgrammeur at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 8
No, java developers are slow. ;-)Here we go again;every language serves it purpose, period.(And no, don't try rewriting the latest and greatest 3d engine (HL2, Doom3) in Java, Java doesn't serve that purpose)
salpeter at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 9
> No, java developers are slow. ;-)Exactly, C# developers are much faster than Java developers, with all those fancy wizards.
CeciNEstPasUnProgrammeur at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 10
> (And no, don't try rewriting the latest and greatest> 3d engine (HL2, Doom3) in Java, Java doesn't serve> that purpose)Have you tried?
Herko_ter_Horst at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 11

Java is slower, but it is often more than fast enough.

In terms of the total cost of developing and deploying an applications I would claim that Java is cheaper. This is because you really need to know what you are doing to develop a stable C++ application, whereas you can achieve a stable Java appplication

Development under Java is often faster because there are less issues to worry about and an extensive set of standard and public libraries.

This is not true in every case, but in the area I am in Java would be faster to deploy and easier to maintain. In fact, having seen some developers Java code, I shudder to think what would happen if they were let loose on C++.

Peter-Lawrey at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 12
> In fact, having seen some developers Java> code, I shudder to think what would happen if they> were let loose on C++.Maybe they were C coders in the first place?
CeciNEstPasUnProgrammeur at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 13

> Here we go again;

> every language serves it purpose, period.

Not quite. There are application areas where modern languages such as Java, C# and C++ overlap.

> (And no, don't try rewriting the latest and greatest

> 3d engine (HL2, Doom3) in Java, Java doesn't serve

> that purpose)

Why not. You have both high-level renderers (Java3D, Xith3D .....) and also OpenGL bindings (JOGL ......). All written in Java

uj_ at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 14

> Can anyone show me the link or article on the

> performance test conducted by any organization?

I've been looking too. Unfortunately there aren't many up to date. They basically stopped around 2002 when it became clear that Java is within say 30% of C++.

> Generally, is C++ better than Java?

Not generally. It's all about how you define "better".

uj_ at 2007-7-7 13:50:45 > top of Java-index,Security,Event Handling...
# 15

> What do you mean? Everybody knows that Java is slow.

I took the liberty to write a little program in C to exercise a variation of Erathostenes' sieve to find primes. The number of the primes through the sieve was given as an input argument. Then I rewrote the program in Java. I compiled and run both in the "vanilla" (no option, no optimization) way and measured the exceution speed.

To my astonishment Java was only slightly slower if slower at all!

In the output below "c" or "j" tells if it is good old C or Java, the arguments tested (=number of primes to sieve) happened to be the powers of 10 and the last but one column is the execution time of the loop in seconds. Admitted only the computational part was measured, the invocation of the program including parsing the input argument and allocating the result array not, also not the outputting of the result.

1. measurement

Windows 2k box (Compaq desktop) with JDK 1.4.2. and Borland C++ 5.5.1 for Win32

10000000_c1.out:c time 10000000 629 0

10000000_c2.out:c time 10000000 628 0

10000000_j1.out:j time 10000000 633 0

10000000_j2.out:j time 10000000 637 0

1000000_c1.out:c time 1000000 23 0

1000000_c2.out:c time 1000000 23 0

1000000_j1.out:j time 1000000 23 0

1000000_j2.out:j time 1000000 23 0

100000_c1.out:c time 100000 1 0

100000_c2.out:c time 100000 1 0

100000_j1.out:j time 100000 1 0

10000_c1.out:c time 10000 0 0

10000_c2.out:c time 10000 0 0

10000_j1.out:j time 10000 0 0

10000_j2.out:j time 10000 0 0

1000_c1.out:c time 1000 0 0

1000_c2.out:c time 1000 0 0

1000_j1.out:j time 1000 0 0

1000_j2.out:j time 1000 0 0

2. measurement Linux with JDK 1.4.2 and gcc 3.3.3 (Compaq Proliant server)

Linux linux 2.6.4-52-default#1 Wed Apr 7 02:08:30 UTC 2004 i686

model name: Intel(R) Pentium(R) III CPU family1400MHz

cpu MHz: 1397.468

cache size: 512 KB

c time 10000000 788 0

c time 10000000 786 0

j time 10000000 772 0

j time 10000000 766 0

c time 1000000 29 0

c time 1000000 29 0

c time 1000000 29 0

c time 1000000 29 0

j time 1000000 29 0

j time 1000000 28 0

j time 1000000 28 0

j time 1000000 28 0

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int doit(int n,int *buffer) {

int ct=1;//found so far

int i;

int candidate;

buffer[0]=2;

//for(i=1;i<n;i++) buffer[i]=0;

candidate=buffer[ct-1]+1;

while(ct >< n) {

int j;

int ip=1;

for(j=0;j<ct;j++) {

int pr=buffer[j];

#ifdefDEBUG

printf("candidate=%d pr=%d\n",candidate,pr);

#endif

if ((candidate / pr) >< pr) {

break;

}

if (candidate%pr==0) {

#ifdefDEBUG

printf("rejecting candidate=%d pr=%d (ct=%d)\n",candidate,pr,ct);

#endif

ip=0;

break;

}

}

if (ip) {

buffer[ct++]=candidate;

#ifdefDEBUG

printf("gevonden %d (%d)\n",candidate,ct);

#endif

}

candidate++;

}

return 0;

}

int main(int argc,char *argv[]) {

time_t t0,t1,t2;

int i,n,ret=1;

int*buffer;

if (1==argc) return ret;

sscanf (argv[1],"%d",&n);

if (1>= n) return 2;

time(&t0);

buffer=malloc(n * sizeof(int));

if (!buffer) return 3;

time(&t1);

ret = doit(n,buffer);

time(&t2);

for(i=0;i<n;i++) {

printf("%d %d\n",i,buffer[i]);

}

printf("c time %d %ld %ld\n",n,(long)t2-(long)t1,(long)t1-(long)t0);

return ret;

}

public class a {

static int doit(int n,int buffer[]) {

int ct=1;//found so far

int i;

int candidate;

buffer[0]=2;

//for(i=1;i<n;i++) buffer[i]=0;

candidate=buffer[ct-1]+1;

while(ct >< n) {

int j;

int ip=1;

for(j=0;j<ct;j++) {

int pr=buffer[j];

if ((candidate / pr) >< pr) {

break;

}

if (candidate%pr==0) {

ip=0;

break;

}

}

if (ip!=0) {

buffer[ct++]=candidate;

}

candidate++;

}

return 0;

}

public static void main(String argv[]) {

System.exit(main0(argv));

}

static int main0(String argv[]) {

long t0,t1,t2;

int i,n,ret=1;

if (0==argv.length) return ret;

n=Integer.parseInt(argv[0]);

if (1>= n) return 2;

t0=System.currentTimeMillis()/1000;

int buffer[]=new int[n];

t1=System.currentTimeMillis()/1000;

ret = doit(n,buffer);

t2=System.currentTimeMillis()/1000;

for(i=0;i<n;i++) {

System.out.println(i+ " " + buffer[i]);

}

System.out.println("j time " + n + " " + (t2-t1) + " " + (t1-t0));

return ret;

}

}

>

BIJ001a at 2007-7-20 1:20:09 > top of Java-index,Security,Event Handling...
# 16

You all missed the point!!!!

He asked: is VC++ better than java?

Of course it is, it is M$ centric!!! You can write it in a pseudo mannaged code and use a lot of wizard, so you do not need even know what you are doing and you still can think yourself a real programmer for you use the good ol' C++.

Well this people "XlanguageIsbetterthanjava" should implement the interface BuggerOffable and buggerOff();

Please, someone can lend me a hammer?

/**

* @wish

*May the Code be with you.

*/

notivagoa at 2007-7-20 1:20:09 > top of Java-index,Security,Event Handling...
# 17
>Please, someone can lend me a hammer?Take a screwdriver, it's better.
CeciNEstPasUnProgrammeura at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 18
> Exactly, C# developers are much faster than Java> developers, with all those fancy wizards.Wizards? I thought MS was putting Lizards in thier boxes, but haven't found one yet, but then I've not found the cup of coffee in my Java downloads either.
morgalra at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 19
> >Please, someone can lend me a hammer?> > Take a screwdriver, it's better. Yeah! Maybe I should use a tea spoon to stab their heart, slowly, very slowly and painfully. /** * @whish *May the Code be with you. */
notivagoa at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 20

> To my astonishment Java was only slightly slower if

> slower at all!

I also have the feeling Java is very close now.

Just a comment. The % operator is often very slow in Java but it seems equally slow in C.

Also the C algoritm isn't tweaked to the limit, You could replace array accesses with pointer arithmetics and if the / and % operations aren't totally dominating the loop the C version could gain, well, say 10%

uj_a at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 21
> Generally, is C++ better than Java?That question generally indicates that the poster does not understand the the entire software process which includes requirements, design, coding, project planning, scheduling, budgeting, estimating, performance, etc.
jschella at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 22

> You all missed the point!!!!

>

>He asked: is VC++ better than java?

>

> Of course it is, it is M$ centric!!! You can write

> ite it in a pseudo mannaged code and use a lot of

> wizard, so you do not need even know what you

> are doing and you still can think yourself a real

> programmer for you use the good ol' C++.

>

Sigh....unfortunately that is so true.

I know of one "senior" developer who used the "helpful" stuff in VC to write an adapter for sockets which was supposed to support a spec'd message interface. He reported that he was quite well along before I became suspicious and wrote a java app that did nothing but receive the messages that his code was sending. It took him several days to understand that the "helpful" stuff was producing a serialized form of the data (which of course did not match the spec.)

jschella at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 23

> > You all missed the point!!!!

> >

> >He asked: is VC++ better than java?

> >

> > Of course it is, it is M$ centric!!! You can write

> > ite it in a pseudo mannaged code and use a lot of

> > wizard, so you do not need even know what

> you

> > are doing and you still can think yourself a real

> > programmer for you use the good ol' C++.

> >

>

> Sigh....unfortunately that is so true.

>

> I know of one "senior" developer who used the

> "helpful" stuff in VC to write an adapter for sockets

> which was supposed to support a spec'd message

> interface. He reported that he was quite well along

> before I became suspicious and wrote a java app that

> did nothing but receive the messages that his code

> was sending. It took him several days to understand

> that the "helpful" stuff was producing a serialized

> form of the data (which of course did not match the

> spec.)

And his code was probably full of unecessary code, put there by the wizard, that only cluters the application and sometimes makes it even slower and he does not even dream about for what is that.

/**

* @wish

*May the Code be with you.

*/

notivagoa at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 24
> That question generally indicates that the poster> does not understand the the entire software processWhich is quite usual... *wry smile*
CeciNEstPasUnProgrammeura at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 25

> > Generally, is C++ better than Java?

>

> That question generally indicates that the poster

> does not understand the the entire software process

> which includes requirements, design, coding, project

> planning, scheduling, budgeting, estimating,

> performance, etc.

and me thinking the software process existed of posting your homework assigments to a forum and drinking sodas while waiting for someone to do them for you :)

jwentinga at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 26

> and me thinking the software process existed of

> posting your homework assigments to a forum and

> drinking sodas while waiting for someone to do them

> for you :)

To your credit, that does seem to be the pattern in introductory Java development... ;o)

yawmarka at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...
# 27

> > and me thinking the software process existed of

> > posting your homework assigments to a forum and

> > drinking sodas while waiting for someone to do

> them

> > for you :)

>

> To your credit, that does seem to be the

> pattern in introductory Java development... ;o)

Excellent. In that case it's just that my managers have never gotten more advanced and introduced the other steps into our workflow.

I did have this nagging feeling there was something missing ;)

jwentinga at 2007-7-20 1:20:10 > top of Java-index,Security,Event Handling...