14.07.2013 Views

Contents - Cultural View

Contents - Cultural View

Contents - Cultural View

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Comparison of Java and C Sharp 62<br />

Bags/multisets Yes Yes<br />

Metadata Java C#<br />

Metadata annotations/attributes Interface based Class based<br />

Positional arguments No; unless a single argument Yes<br />

Named arguments Yes Yes<br />

Default values At definition Through initialization<br />

Nested types Yes Yes<br />

Specialization No Yes<br />

Conditional metadata No Yes<br />

Preprocessing, compilation and<br />

packaging<br />

Java C#<br />

Namespaces Packages Namespaces<br />

Packaging Package Assembly<br />

File contents Restricted Free<br />

Conditional compilation No Yes<br />

Custom errors/warnings No Yes<br />

Explicit regions No Yes<br />

Threading and synchronization Java C#<br />

Native interoperability Java C#<br />

External/native methods Yes Yes<br />

Marshalling External glue code required Yes; metadata controlled<br />

Pointers and arithmetics No Yes<br />

Native types No Yes<br />

Fixed size buffers No Yes<br />

Explicit stack allocation No Yes<br />

Address pinning (fixing) No Yes<br />

Address-of No Yes<br />

Object pinning (fix variable to address) No Yes<br />

Data types<br />

Unified type system<br />

In Java the primitive types are special in that they are not object-oriented and they could not have been defined using<br />

the language itself. The Java reference types all derive from a common root type, however. C# has a unified type<br />

system in which all types ultimately derive from a common root type. Consequently, all types implement the<br />

methods of this root type, and extension methods defined for the object type apply to all types, even primitive int<br />

literals and delegates. Note, that unlike Java, C# this way supports objects with encapsulation which are not<br />

reference types.<br />

In Java compound types are synonymous with reference types; you can not define methods for a type unless it is also<br />

a class reference type. In C# the concepts of encapsulation and methods have been decoupled from the reference<br />

requirement so that a type can support methods and encapsulation without being a reference type. Only reference<br />

types support virtual methods and specialization, however.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!