logo       

Re: How do you choose your programming language ?: msg#00074

culture.hackers.israel

Subject: Re: How do you choose your programming language ?

On Tue, Nov 22, 2005, Tzahi Fadida wrote about "RE: [hackers-il] How do you
choose your programming language ?":
>...
> Anyway, all of these worth nothing if the software is distributed and there
> is a major
> recall because of bugs such as range checks rouge pointers, etc... the
> usual...
> Better use a high level language that restrict more than being flexible and
> even less
>...

In theory, you are right, and such reasons are always quoted for why Java
is better than C.

But while in theory, theory and practice are the same, in practice, practice
is often different from theory :)

What I mean is that often a program gets written in, say, Java, and while it
results in a program that has fewer bugs - it often results in a program that
is utterly unusable, because it takes up tons of memory ("don't worry, just
upgrade your memory to 1GB" is something I often hear in the context of Java
programs), or other performance issues. On more than one occasion (dare I
say, "every occasion"?) when a Java project or program is complete, the
people involved say, "This product has a great potential, but if it were
written in a different language, perhaps we could actually use it."

And I'm saying this is a person who currently programs in Java for a living (!).

So while when you say "C is better in performance" people always think
"I don't care because I don't mind if my program is 10% slower, or the
GUI takes 10 milliseconds instead of 1 milliseconds to update", you can't
neglect it altogether. A 5-fold memory usage increase, a 5-fold slowdown
in CPU-intensive applications, pauses (for garbage-collection or swapping)
during interactive applications - these things are NOT ACCEPTABLE. And in
some languages (especially Java) and some cases, they are nearly unavoidable.

Since my vents are already open ( :-) ), let me say what really bothers me
about Java, and its concept of garbage collection.
Java basically assumes that by the time of garbage collection, most of the
objects in memory are garbage, and its GC algorithms handle this case very
efficiently. It is almost always the case, because Java encourages you to
create many transient objects that live for very short durations.
So Java programs typically allocate a (very) large heap, and just go over
it giving out memory until the heap is all finished, at which time garbage
collection is done (very efficiently - forget the details for now).
The problem is that this process is very good when the Java virtual machine
is given the machine's entire memory (Linux kernel hackers: this is exactly
like the Linux kernel always tries to fill up the entire memory with buffers
and caches). So Java is ok for running a single huge application on some
machine. But as soon as we start running several separate JVMs (namely,
different Java-written utilities) on the same machine, things get hairy.
You can't let each Java program use 1 GB of heap, because even if it needs
just 50 MB, it will REALLY USE that 1 GB. So you need to either allow the
program to use tons of memory (ever used Eclipse? it's really notorious in
this regard) or artificially limit the heap size of the program, causing
horrible crashes when the heap really runs out because the program really
needs more memory. Sun's JVM (but not IBM's!) knows to shrink the heap
to a size more similar to the real size needed, but it still doesn't do
this effectively, and it always uses up much more memory than the program
really needs.

So in short, performance is *always* an issue: nobody cares about 10%
speedups, but people always care whether a utility takes 20 MB of memory
or 200 MB of memory (these are actual numbers from a comparison of one
C program and a similar Java program we did at work).

--
Nadav Har'El | Wednesday, Nov 23 2005, 21 Heshvan 5766
nyh-TS7m/3hpY0sOpacJJkBjfT4kX+cae0hd@xxxxxxxxxxxxxxxx
|-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |The trouble with being punctual is that
http://nadav.harel.org.il |nobody is there to appreciate it.


------------------------ Yahoo! Groups Sponsor --------------------~-->
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->


Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/hackers-il/

<*> To unsubscribe from this group, send an email to:
hackers-il-unsubscribe-hHKSG33TihhbjbujkaE4pw@xxxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise