Home   Cover Cover Cover Cover
 

.NET versus Java

Question: Which features of the .NET framework resemble those of the Java environment? Which features are not supported by Java?

Answer:

  • Both the .NET Framework and Java are based on a virtual machine that defines a set of services on top of a host operating systems. In both systems programs are translated into to the language of the virtual machine. Whereas Java bytecodes are interpreted (only the most frequently executed methods get JIT-compiled) .NET programs are always JIT-compiled to machine code before they are executed.


  • Both systems employ a garbage collector to automatically reclaim unreferenced objects.


  • Both systems have similar security mechanisms (i.e. a verifier, code-based access rights, etc.). The .NET security model, however, is more fine-grained in that it allows the definition of security policies on several levels (enterprise, machine, user, and application domain)


  • The languages C# (in fact all .NET languages) and Java are very similar. They support object-orientation with single inheritance, interfaces, threads, exceptions, etc. C# and Java are also syntactically very similar. However, C# has a few additional features such as properties, indexers, events, attributes, delegates, structs and reference parameters.


  • Versioning is a feature that is not available in Java. A Java class file is identified exclusivey by its name. There is no way to have several class files with the same names but different version numbers in the same directory or in memory at the same time.


  • Furthermore, the Java environment does not support interoperability between different programming languages. Although it is in principle possible to translate languages other than Java to bytecode, the bytecode is not designed for that. It does not contain features that are not used in Java (e.g. reference parameters). This makes it difficult (if not impossible) to translate all conceivable languages to Java bytecode.


  • On the other hand, platform independence is not a primary goal of .NET, although it can be achieved in principle.