473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How fast is Java?

Many must have asked that question. I intend to write a few programs
which will be CPU intensive. I know a little of Java. Would a language
that yields native code, instead of bytecode perfrom much faster?

I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as
the C program. Unexpected result to me. When is Java slower?

What kind of program will I write? Programs for myself only. Only text,
no graphical user interface; batch processing; virtually no I/O. Mostly
comparing, and adding integers. Random access to memory.

Should I use my already installed Javac, or consider using another
language?

Feb 25 '06 #1
4 6974
In article <43**************@sympatico.ca>, =?iso-8859-1?Q?Jean=2DFran=E7ois?= Blais
<je****************@sympatico.ca> wrote:
Many must have asked that question. I intend to write a few programs
which will be CPU intensive. I know a little of Java. Would a language
that yields native code, instead of bytecode perfrom much faster?

I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as
the C program. Unexpected result to me. When is Java slower?

What kind of program will I write? Programs for myself only. Only text,
no graphical user interface; batch processing; virtually no I/O. Mostly
comparing, and adding integers. Random access to memory.

Should I use my already installed Javac, or consider using another
language?

This is a question that's difficult to answer. If you were using a lot of
floating point, I'd say Fortran. But who wants to program in Fortran? Not me.
But if you have a lot of number crunching, it's a good choice.

Since these are personal programs, use the language you know if it's fast
enough. If it's not, then look for another. Well written C programs tend to be
very fast. But string processing in C is a pain. Actually it's a pain in Java
(and I like Java). But if I had to do a lot of text processing, I'd probably
look at Perl. (And I don't like Perl. Nothing wrong with it - it's a personal
preference.)

Early versions of the the JDK were certainly slower than C, and Java got a
reputation for being slow. That is no longer than case. The optimizers are a
lot better. But the results will vary with the cpu you use, the program
version, memory, operations ...

If you decide to go with Java, use at least version 1.4x. We have no idea what
version is installed on your machine. (java -version)

Eric
Feb 25 '06 #2
"Jean-François Blais" <je****************@sympatico.ca> wrote in message
news:43**************@sympatico.ca...
Many must have asked that question. I intend to write a few programs which
will be CPU intensive. I know a little of Java. Would a language that
yields
native code, instead of bytecode perfrom much faster?
Not nescessarily. See
http://groups.google.ca/group/comp.l...a47d1ebb9c540a
I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as the
C
program. Unexpected result to me. When is Java slower?
Very rarely. See
http://groups.google.ca/group/comp.l...5cfa858f8e09c5
What kind of program will I write? Programs for myself only. Only text, no
graphical user interface; batch processing; virtually no I/O. Mostly
comparing, and adding integers. Random access to memory.

Should I use my already installed Javac, or consider using another
language?


Use the programming language with which you are most comfortable.
Developper time (i.e. how much time you spend working on the project) is
more valuable than CPU time (i.e. how much time your CPU spends running the
program).

- Oliver

Feb 27 '06 #3
Jean-François Blais wrote:
Many must have asked that question. I intend to write a few programs
which will be CPU intensive. I know a little of Java. Would a language
that yields native code, instead of bytecode perfrom much faster?

I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as
the C program. Unexpected result to me. When is Java slower?

What kind of program will I write? Programs for myself only. Only text,
no graphical user interface; batch processing; virtually no I/O. Mostly
comparing, and adding integers. Random access to memory.

Should I use my already installed Javac, or consider using another
language?
Try gcj-4.1.
I have been playing with gcj-4.1 and have been writing up my discoveries
at the following url:
http://www.storm.ca/~tabun/
Do text search for "gcj" and you will find info to support you in your
adventures with compiling java natively.
You will find tar.gz's for examples that compile tcp/ip, awt, swt,
glade/gtk, aes(that's math and memory work which is what you like),
cortado, and finally a clarification of -cp and -foutput-class-dir=. in
order to compile stuff without getting all sorts of "type not found" errors.

Keep in mind my goal was to isolate everything and keep everything
simple to understand without resorting to an IDE or ant.
Mastery of -cp and -foutput-class-dir=. will permit developers to put
java sources into makefiles with all the rest of the sources if you so
choose.

You can squeeze more performance with extra optimization switches which
you can read up in the gcj/gcc documentation.

I wish you lots of fun in your discoveries.
Jul 26 '06 #4

<ta***@storm.cawrote in message
news:WM******************************@storm.ca...
Jean-François Blais wrote:
>Many must have asked that question. I intend to write a few programs
which will be CPU intensive. I know a little of Java. Would a language
that yields native code, instead of bytecode perfrom much faster?

I recently wrote a minuscule C program containing one loop using a few
variables, and an equivalent java program, which was nearly as fast as
the C program. Unexpected result to me. When is Java slower?
See
http://groups.google.com/group/comp....fdc4eda32ca731
>>
What kind of program will I write? Programs for myself only. Only text,
no graphical user interface; batch processing; virtually no I/O. Mostly
comparing, and adding integers. Random access to memory.

Should I use my already installed Javac, or consider using another
language?
I'd recommend you write in whatever language you are most comfortable in
(unless your goal is to learn Java, in which case, write them in Java).
Don't worry about optimization until you actually notice a problem in
performance. And then, look at optimizations at the algorithm and data
structure levels before worrying about switching to a "faster" language.

- Oliver

Jul 27 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bdinmstig | last post by:
Hi. I need an implementation of java.util.Comparator with the following features: 1. Given a (mutable) java.util.List instance of unspecified size at construction time. 2. That List instance...
13
by: Charles Handy | last post by:
How does FastCGI compare against java Apps running in java app servers like TomCat, Sun One, WebLogic and WebSphere? Is there a business case for switching from CGI to Java? Performance?...
18
by: Michele Simionato | last post by:
I posted this few weeks ago (remember the C Sharp thread?) but it went unnoticed on the large mass of posts, so let me retry. Here I get Python+ Psyco twice as fast as optimized C, so I would like...
0
by: Andre | last post by:
Hello, I am working on refactoring my companies search engine, and a critical component of the search is that the results be displayed very quickly. We have done enourmous work on making the...
4
by: Alexis Gallagher | last post by:
(I tried to post this yesterday but I think my ISP ate it. Apologies if this is a double-post.) Is it possible to do very fast string processing in python? My bioinformatics application needs to...
11
by: Olie | last post by:
This post is realy to get some opinions on the best way of getting fast comunication between multiple applications. I have scowered the web for imformation on this subject and have just found...
8
by: . | last post by:
What is the fast way for a fast implementation of Python? -- JavaScript implementation of Python http://groups.google.it/group/JSython/
8
by: Sanny | last post by:
I have a old Pentium 2.5 Ghz Machine I use for surfing Net. I am just curious to know how much faster are the Server Machines are. Say they are 8 Core/ 16 Core??? What is the Max cores Modern...
7
by: Sanny | last post by:
I have an app in Java. It works fine. Some people say Java works as fast as C. Is that true? C can use assembly language programs. How much faster are they inplace of calling general routines. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.