Java speed vs. C++.

M

Mike Smith

Chris said:
Yes, Windows XP does have a command.com. However, it is not used for
anything, and the code probably hasn't been maintained for years.
Making use of it yourself is very ill-advised.

Since we're already way OT - the WinXP command shell (the so-called "DOS
prompt") is called CMD.EXE. It looks a lot like COMMAND.COM, but it's not.
 
R

red floyd

Mike said:
Since we're already way OT - the WinXP command shell (the so-called "DOS
prompt") is called CMD.EXE. It looks a lot like COMMAND.COM, but it's not.

Yeah, but the best WinXP command shell is called BASH.EXE, and you get
it from cygwin.
 
D

Dan Elliott

Mike Cox said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.
Mike,

This is a truly pathetic test. I am not sure you could learn ANYTHING of
value from it.

- dan elliott
 
J

Joona I Palaste

Dan Elliott <[email protected]> scribbled the following
Mike Cox said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.
Mike,

This is a truly pathetic test. I am not sure you could learn ANYTHING of
value from it.

I agree. The overhead of starting the Java process and creating a VM is
way too large in this test. Try to print "Hello world" one million times
in a loop for a fairer test.
 
J

jarrodhroberson

Mike said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.

first explain how your super contrived hello world example has any
RELEVANCE what so ever to Apache, Jakarta or anything thing else server
related?

If you are not a troll, then your least worry is the speed of running a
contrived hello world example, it is more like getting much more basic
fundemental understanding about practical programming.
if you are just trolling just stop.
 
J

jarrodhroberson

Mike said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.

first explain how your super contrived hello world example has any
RELEVANCE what so ever to Apache, Jakarta or anything thing else server
related?

If you are not a troll, then your least worry is the speed of running a
contrived hello world example, it is more like getting much more basic
fundemental understanding about practical programming.
if you are just trolling just stop.
 
J

jarrodhroberson

Mike said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.

first explain how your super contrived hello world example has any
RELEVANCE what so ever to Apache, Jakarta or anything thing else server
related?

If you are not a troll, then your least worry is the speed of running a
contrived hello world example, it is more like getting much more basic
fundemental understanding about practical programming.
if you are just trolling just stop.
 
J

jarrodhroberson

Mike said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.

first explain how your super contrived hello world example has any
RELEVANCE what so ever to Apache, Jakarta or anything thing else server
related?

If you are not a troll, then your least worry is the speed of running a
contrived hello world example, it is more like getting much more basic
fundemental understanding about practical programming.
if you are just trolling just stop.
 
J

jarrodhroberson

Mike said:
Hi. I recently ran a benchmark against two simple programs, one written in
Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete on
my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot that
Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.

first explain how your super contrived hello world example has any
RELEVANCE what so ever to Apache, Jakarta or anything thing else server
related?

If you are not a troll, then your least worry is the speed of running a
contrived hello world example, it is more like getting much more basic
fundemental understanding about practical programming.
if you are just trolling just stop.
 
J

James Kanze

first explain how your super contrived hello world example has any
RELEVANCE what so ever to Apache, Jakarta or anything thing else server
related?

Actually, if he is counting on using Java to implement CGI scripts, he's
found one of the few application areas where it is relevant. (Of
course, one could question the reasonableness of such a choice, given
the presence of JSP.)
If you are not a troll, then your least worry is the speed of running a
contrived hello world example, it is more like getting much more basic
fundemental understanding about practical programming.
if you are just trolling just stop.

There are applications where start-up time is important. I have a
couple of small programs that I invoke from the editor to filter part of
the text -- typically just a couple of lines; JDK's start up time pretty
much makes Java a no runner here. There are other applications where it
isn't, but other things in Java implementations make the language
inappropriate. And of course, there are other applications for which it
is really the only reasonable alternative -- I'm certainly not going to
write CGI code in *any* language if I can use JSP.

For most large scale applications, of course, the performance of the
language simply isn't an issue these days.
 
P

Piotr Plazienski

Joona said:
Dan Elliott <[email protected]> scribbled the following
Hi. I recently ran a benchmark against two simple programs, one written
in

Java and the other in C++. The both accomplish the same thing, outputting
"Hello World" on my screen. The C++ program took .5 seconds to complete
on

my 400 Mhz PC while the Java program took 6.5 seconds.

I am running the SUSE 8.2 Linux distribution.

Why is Java that much slower than the C++ program? I read on Slashdot
that

Java was almost as fast as C++. Here are my programs:

test.cpp

#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
}


test.java

public class test
{
public static void main(String[] args)
{
System.out.println("Hello world");
}
}

The reason I ask is because I'm thinking of using Apache and Jakarta to do
some development. If Java cannot be speeded up, I will be forced to find
another alternative.

Mike,


This is a truly pathetic test. I am not sure you could learn ANYTHING of
value from it.


I agree. The overhead of starting the Java process and creating a VM is
way too large in this test. Try to print "Hello world" one million times
in a loop for a fairer test.
Actually that wont't do either. Console has its limits, and outputting
anything at that rate makes everything slow down to console speed. My
brother 'proved' that perl is working at same speed as c that way.
Better (but also silly) is to do loop that outputs something, does
something without ouputting, disk usage and so on (like
incrementing/decrementing or modulo-ing variable) and does it many
times, then execute that loop many more times :D.
I mean sometning like that:

#include <iostream>
using namespace std;
int main()
{
for(i=0; i<many_times;i++)
{
cout<<"Hello World";
for(j=0;j<many_many_times;j++)
{
i++;
i--;
}
}
}

and you have to take many_many_times high enough to slow doen output to
maybe one "hello" a second, and many many_times to take program to
execute not less than i think 30 secs to reduce impact of preparing a
program.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top