[Mono-list] Mono Evangelism
Miguel de Icaza
miguel@ximian.com
Wed, 10 Mar 2004 10:12:13 -0500
Hello,
> >From the article:
>
> "Performance . This is one aspect where .NET shines and Java wimps."
>
> Is this true? I have understood the opposite, but things might have changed.
More work has gone into fine-tuning Java, but it seems that this work
was required due to some features in the language.
The ones that come to mind are:
* Optimization of virtual calls: the Java JITs try to decide if
a class is terminal or not to replace a virtual call to a
method with a regular call.
Although this is in general a good idea, it is very complex to
implement, since it means that you must re-JIT the code if a
new class is loaded that breaks the assumption that a class is
not inherited. This means stopping all running threads in a
safe point, storing their state (possible register values, map
the stack state), recompile any affected code, and resume the
execution into the new JITed classes.
Very hard code, a bit of a performance problem, and means that
you must keep more data structures alive during the program
execution.
Although this optimization would be nice in .NET as well, it
is not as important to do, because by default in C# methods
are not virtual. In Java, by default all methods are
virtual.
For an explanation of why C# did not go virtual, see:
http://www.artima.com/intv/nonvirtual.html
* Value types (structs): again, learning from one of Java's
limitations the .NET VM supports value types that can assist
enormously in performance tuning, since it can be used to
avoid a lot of memory allocations when they are not required
(see Ben's recent blog entry for a few examples).
* Generics: not yet in production, but the generics
implementation of .NET is a first class citizen, something
that the VM is aware of, and something that it can generate
special code for.
In the Java world, Generics are just compiler syntactic sugar
that is translated into slower boxing classes.
Miguel.