Re: Exception Misconceptions: Exceptions are for unrecoverable
errors.
On 2009-12-23, Branimir Maksimovic <bmaxa@hotmail.com> wrote:
tanix wrote:
In article <hgskgk$kc2$1@news.albasani.net>, Vladimir Jovic <vladaspams@gmail.com> wrote:
C++ would probably be benefited tremendously if it adopted some
of the central Java concept, such as GC, threads and GUI.
GC is heavy performance killer especially on multiprocessor systems
Is not.
in combination with threads....it is slow, complex and inefficient...
Religious belief.
It has sense in functional languages because of recursion, but
in java?!
Java has recursion. Moreover, there are functional languages built on the Java
platform.
Recursion is not directly connected to the need for garbage collection; this is
some kind of strange misconception.
GC without threads, but processes and shared memory instead, is ok on
multiprocessor systems...
GC is very efficient from an SMP point of view, because it allows
for immutable objects to be truly immutable, over most of their
lifetime. No book-keeping operations have to be performed on objects
that are just passed around throughout the program (such as bumping
refcounts up and down).
No storage reclamation strategy is free of overhead. Even if your program
correctly manages memory by itself with explicit new and delete, there is a
cost.
Moreover, a poorly implemented heap allocator (like virtually
every default malloc implementation out there in the real world)
is an SMP performance killer.
Like malloc and new, GC can be badly implemented in a way that kills SMP
performance. So can any aspect a programming language implementation, including
the compiler.
If you find a sufficiently bad compiler and library for some language, you can
``prove'' any statement about how bad that language is.
Except that would require an equivalent of a virtual machine
underneath.
virtual machine is also heavy performance killer...
That may be so, but GC does not require a virtual machine. GC has been used for
five decades, with natively compiled code, starting in the late 1950's on IBM
704 mainframes, as part of the Lisp run-time support.
And that is one of central issues with Java.
Yes.
I think java is designed in such way that it will still be slow in
comparison to other compiled languages...if it is compiled
language.
Unfortunately, that is wishful thinking. Natively compiled Java has very little
disadvantage compared to C and C++. (Mainly in areas of doing low-level things
with memory, or directly interfacing with the ``bare iron''; the sorts
of things that are poorly supported in Java).
Java has the same low-level numeric types, and the way it deals with objects is
not much different from pointers to classes in C++.
There is no reason to expect something like a matrix multiplication with
Java arrays to be slow, when Java is compiled to native code by an optimizing
compiler.