Newbies doubts on Java  
Author Message
kochiam





PostPosted: 2003-12-1 23:19:00 Top

java-programmer, Newbies doubts on Java Hi All:

I am mainly a C++ programmer. Recently, I need to do cross platform
development work and Java came across my mind. My worries are as
follows:

1. Is Java suitable as a language to develop software application in
an operational environment? My company needs to run application 24hrs
a day and 7 days a week (ie. non stop). I have heard that Java is
slower than C++ and Java has a larger memory footprint as compared to
C++. Are these true?

2. I have came across wonderfully written Java applications that works
smoothly. May I know is there any tips or tricks whereby one can
follow to streamline a Java program, such as conforming to certain
architecture or design principles etc.

Thank you for your time in answering these naive questions.
 
kochiam





PostPosted: 2003-12-1 23:20:00 Top

java-programmer >> Newbies doubts on Java Hi All:

I am mainly a C++ programmer. Recently, I need to do cross platform
development work and Java came across my mind. My worries are as
follows:

1. Is Java suitable as a language to develop software application in
an operational environment? My company needs to run application 24hrs
a day and 7 days a week (ie. non stop). I have heard that Java is
slower than C++ and Java has a larger memory footprint as compared to
C++. Are these true?

2. I have came across wonderfully written Java applications that works
smoothly. May I know is there any tips or tricks whereby one can
follow to streamline a Java program, such as conforming to certain
architecture or design principles etc.

Thank you for your time in answering these naive questions.
 
Tim Ward





PostPosted: 2003-12-1 23:35:00 Top

java-programmer >> Newbies doubts on Java "Tanuki" <email***@***.com> wrote in message
news:email***@***.com...
>
> I am mainly a C++ programmer. Recently, I need to do cross platform
> development work and Java came across my mind. My worries are as
> follows:
>
> 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?

You do have to understand the garbage collector, it appears. If you're
perfectly happy to go back to the days of tuning config.sys then you should
be happy with tweaking the garbage collection.


 
 
Harald Hein





PostPosted: 2003-12-2 0:38:00 Top

java-programmer >> Newbies doubts on Java "Tanuki" wrote:

> 1. Is Java suitable as a language to develop software application
> in an operational environment? My company needs to run application
> 24hrs a day and 7 days a week (ie. non stop).

Yes, in the same way a C++ application can do the job. There are
sometimes bug in C++ compilers and libraries, and there are sometimes
bugs in the Java compiler, VM (virtual machine) and API implementation.
In both languages you might not notice, or you might run into a
showstoper for your application.

> I have heard that
> Java is slower than C++

No. Benchmarks usually show that they are on pair by average, if a
recent Java implementation is used. Java applications typically have a
longer start up time, because the VM has to start, and the JIT (just-
in-time) compiler might also take some time. Once up and running,
things are usually the same.

> and Java has a larger memory footprint as
> compared to C++.

Well, the VM needs additional memory, and usually there are many object
instances involved in a Java application (some Java APIs tend to be
generous with objects). So yes, a Java application can need more memory
compared to a C++ application.

You also see a different memory allocation behavior, because the
garbage collector runs things behind the back of the application.

> 2. I have came across wonderfully written Java applications that
> works smoothly. May I know is there any tips or tricks whereby one
> can follow to streamline a Java program, such as conforming to
> certain architecture or design principles etc.

If you are a good programmer, you can do that, too. I sometimes have
the feeling that Java is a little bit less forgiving regarding a bad
application architecture than e.g. C++. This might be an illusion. On
the other hand, there are a lot of possible hacks one can do in C++ to
partly compensate for a bad architecture, while a lot of that stuff has
been taken away from Java (no void *, no unions, no preprocessor ...).

So if you mess it up in Java, you better fix the root-cause of the
problem instead of hoping that you can work around it.
 
 
Peter Ashford





PostPosted: 2003-12-2 4:38:00 Top

java-programmer >> Newbies doubts on Java Tanuki wrote:

> Hi All:
>
> I am mainly a C++ programmer. Recently, I need to do cross platform
> development work and Java came across my mind. My worries are as
> follows:
>
> 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?
>
> 2. I have came across wonderfully written Java applications that works
> smoothly. May I know is there any tips or tricks whereby one can
> follow to streamline a Java program, such as conforming to certain
> architecture or design principles etc.
>
> Thank you for your time in answering these naive questions.

I've done development commercially in C,C++ and Java. IMO Java is fine
for most applications. It does have a slower startup phase than a C++
app, performance might be down by say, 5-10% depending on the
application and memory usage will be higher - but by a constant one
one-off ammount (i.e. add 4MB or so to your application for JVM internals)

 
 
Scott Ellsworth





PostPosted: 2003-12-2 4:49:00 Top

java-programmer >> Newbies doubts on Java In article <email***@***.com>,
email***@***.com (Tanuki) wrote:

> I am mainly a C++ programmer. Recently, I need to do cross platform
> development work and Java came across my mind. My worries are as
> follows:

It is a good place to work.

> 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?

Yes and no. There is VM overhead, and the compliers are often a bit
weak, so that the out of the box code is slower. The just in time
compliers, on the other hand, often optimize surprisingly well.
Further, they work on the most critical sections of your code as it is
used, which makes it much faster in real world terms than indifferent
C++ code, and equally fast for good C++ code. (Note - the server VM has
a better JITC than the client, IME.)

Experts optimize for speed and space. C++ gives some great tools to do
that, which keeps the developer in control of their app. Java also has
good tools - I find the profilers better on the Java side, as well as
the testing tools. Good profilers and good tests improve code, often
better than design principles.

That said, an expert Java developer can often produce more functionality
in a given time, because the libraries and gc save so much effort. They
then can spend their time optimizing those things that need to work, and
thus they may end up with better code.

(This has been my experience, at least, and I have done both.
Windows/C++ for seven years, Java for six years.)

> 2. I have came across wonderfully written Java applications that works
> smoothly. May I know is there any tips or tricks whereby one can
> follow to streamline a Java program, such as conforming to certain
> architecture or design principles etc.

Profiling and designing for performance at the proper times are your
friends. For example, know your performance goals, and make sure you
test them from the first. Then, do not optimize until the code _works_.
(In other words, fast broken code is not worth the effort.)

Test everything that matters to your app. This allows you to dramatic
restructuring if your app needs it without risking terrible breakage and
an unfixable mess.

These last two principles are major parts of what I do professionally.
First test that it works, then test that it works quickly, then profile
to understand why it works the way it does.

Scott
email***@***.com
Java, Cocoa, WebObjects, and Database consulting
 
 
Jose Rubio





PostPosted: 2003-12-2 9:39:00 Top

java-programmer >> Newbies doubts on Java See my response in the comp.lang.java.help group. Please try not to post to
multiple groups as you may loose some responses to your question.

Jose

"Tanuki" <email***@***.com> wrote in message
news:email***@***.com...
> Hi All:
>
> I am mainly a C++ programmer. Recently, I need to do cross platform
> development work and Java came across my mind. My worries are as
> follows:
>
> 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?
>
> 2. I have came across wonderfully written Java applications that works
> smoothly. May I know is there any tips or tricks whereby one can
> follow to streamline a Java program, such as conforming to certain
> architecture or design principles etc.
>
> Thank you for your time in answering these naive questions.


 
 
Dale King





PostPosted: 2003-12-3 4:33:00 Top

java-programmer >> Newbies doubts on Java "Tanuki" <email***@***.com> wrote in message
news:email***@***.com...
>
> 2. I have came across wonderfully written Java applications that works
> smoothly. May I know is there any tips or tricks whereby one can
> follow to streamline a Java program, such as conforming to certain
> architecture or design principles etc.


The key thing to having a responsive GUI is to understand the threading
model of AWT/Swing and making sure you are doing things on your own thread
and not the AWT thread. This is not an issue with Windows programming for
instance because you are isolated from the GUI threads by a queue.

For instance see these articles:

http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html

 
 
josephfischer





PostPosted: 2003-12-4 0:27:00 Top

java-programmer >> Newbies doubts on Java email***@***.com (Tanuki) wrote in message news:<email***@***.com>...
> Hi All:
>
> I am mainly a C++ programmer. Recently, I need to do cross platform
> development work and Java came across my mind. My worries are as
> follows:
>
> 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?
>
> 2. I have came across wonderfully written Java applications that works
> smoothly. May I know is there any tips or tricks whereby one can
> follow to streamline a Java program, such as conforming to certain
> architecture or design principles etc.
>
> Thank you for your time in answering these naive questions.

Is this flame bait? How do you know that a particular Java
program is "wonderfully written"?
Pick your language; you can always find somebody who can write a
good program and somebody who can write a bad program in that
language. Depends on your definition of good and bad: fast, small
memory, low network burden, ???
Here are a few articles to consider if you think that Java
applications cannot compete with C++ applications:
http://www.research.ibm.com/journal/sj/391/baylor.pdf,
http://www.research.ibm.com/journal/sj/391/moreira.pdf,
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html
 
 
Andrew Marshall





PostPosted: 2003-12-5 2:13:00 Top

java-programmer >> Newbies doubts on Java On Mon, 01 Dec 2003 07:19:31 -0800, Tanuki wrote:

> Hi All:
>
> I am mainly a C++ programmer. Recently, I need to do cross platform
> development work and Java came across my mind. My worries are as
> follows:
>
> 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?
>
> 2. I have came across wonderfully written Java applications that works
> smoothly. May I know is there any tips or tricks whereby one can
> follow to streamline a Java program, such as conforming to certain
> architecture or design principles etc.
>
> Thank you for your time in answering these naive questions.

2 tips... avoid threads like the plague.. the will eat memory. They have
their place, like if you need to run alot of processes in parallel. and
try QT. It is great for cross platform applications, and it is really easy
to use.

Basically, Java is great, I use it all the time, but i find it can be like
a large truck... powerful, but cumbersom if you don't know how to use it.
And, it has it's place. I think Sun needs to perform some changes to how
the VM functions, and make it much more efficient.

Andrew
 
 
Alan Jones





PostPosted: 2003-12-5 6:39:00 Top

java-programmer >> Newbies doubts on Java
"Tanuki" <email***@***.com> wrote in message
news:email***@***.com...
> Hi All:
> > 1. Is Java suitable as a language to develop software application in
> an operational environment? My company needs to run application 24hrs
> a day and 7 days a week (ie. non stop). I have heard that Java is
> slower than C++ and Java has a larger memory footprint as compared to
> C++. Are these true?
>
I have written an application that runs non-stop for months at a time. It
is an Internet application. Yes, Java is slower and uses more memory but
are these the only criteria? The cross-platform capability is what drove
this application to Java. It does the job and does it well.

Alan