Thursday, February 4, 2010

Platforms

Java (the programming language) is designed to execute on the Java platform, the Java Runtime Environment (JRE). The runtime environment includes the Java Virtual Machine (JVM) as well as a common set of libraries. C# is designed to execute on the Common Language Runtime.

Language

Object handling

Both C# and Java are designed from the ground up as object oriented languages using dynamic dispatch, with syntax similar to C++ (C++ in turn is derived from C). Neither language is a superset of C or C++, however. Both use garbage collection as a means of reclaiming memory resources, rather than explicit deallocation of memory. Both include thread synchronization mechanisms as part of their language syntax.
In both languages objects are created with a new.

References

In both languages references is a central concept. All instances of classes are by reference.
While not directly evident in the language syntax per se, both languages support the concept of weak references. An instance which is only referenced by weak references is eligible for garbage collection just as if there was no references at all. In both languages this feature is exposed through the associated libraries, even though it is really a core runtime feature.
In addition to weak references, Java has soft references. Soft references are much like weak references, but the JVM will not deallocate softly-referenced objects until the memory is actually needed.

feature
Java
C#
Garbage collection
yes
yes
Deterministic disposal
no
yes
Weak references
yes
yes
Soft references
yes
no
Object pinning (fixed to address throughout lifetime)
no
yes

0 Comments: