Comparison Of C Sharp To Java

This is a comparison of the C# programming language to the Java programming language.

Similarities

  • Both languages were derived from C++ (at least in their syntax), which was in turn derived from C.
  • Both languages were designed to be object oriented from the ground up; unlike C++, they were not designed to be compatible with C.
  • Both languages rely on a virtual machine.
  • Both languages include synchronization.
  • Both languages support generic programming.
  • Both include garbage collection.
  • Both include boxing and unboxing of value types, allowing numbers to be handled as objects.
  • Both include foreach, an enhanced for loop.
  • Both include a large class library, which provides APIs for performing many common programming tasks.
  • Both the Java VM and the .NET platform optimize code at runtime through just-in-time compilation (JIT).
  • Both languages allow the use of enumerations, via the enum keyword.

Advantages of C#

  • Tied more closely to the Windows operating system, making for better performance in OS-specific tasks such as user interfaces. C# also provides close integration with COM.
  • The .NET framework was designed to support the execution of many different languages using the same bytecode (MSIL) and virtual machine. While this is possible with Java, the design of .NET allows for better cross-language compatibility.
  • Better support for arithmetic by including more primitive types and functionality to catch arithmetic exceptions.
  • Includes a large number of notational conveniences over Java, many of which, such as operator overloading and user-defined casts, are already familiar to the large community of C++ programmers.
  • Event handling is a "first class citizen" — it is part of the language itself.
  • C# is defined by ECMA and ISO standards, whereas Java is proprietary.
  • Allows the definition of "structs", which are similar to classes but may be allocated on the stack (unlike instances of classes in C# and Java). This can improve performance in some situations.

Disadvantages of C#

  • Little support for platforms other than Microsoft Windows, like Mac OS, Linux and Unix. However, some initiatives, such as the Mono project are adding some functionality of the common language runtime needed for C# to other platforms.
  • Some would argue that C# is under too much control by Microsoft (just as Java is controlled by Sun Microsystems), making it a poor choice in the long run. However, C# has been submitted to ECMA for standardization while Java is still entirely controlled by Sun Microsystems.
  • It is still unclear whether the C# design include software patents potentially enforcable by Microsoft. However, some argue that Microsoft's strong backing of C#'s standardization indicates their intention to spread the language rather than to keep it under monopoly.

Advantages of Java

  • Already implemented on a larger number of platforms, making for better cross-platform compatibility.
  • More mature, meaning a lot of problems may have already been worked out, and more code is already widely available.
  • Method invocation model is simpler, making it easier to implement and at times easier to read.
  • Numourous JVM implementations exist, some under open source licensing.

Disadvantages of Java

  • Does not include operator overloading, making it ill-suited for scientific programming.
  • The lack of any pass-by-reference for primitive (or reference) types makes certain procedural programming tasks awkward.
  • Java is a proprietary Sun product.

Differences between the languages

  • There are no unsigned primitive numeric types in Java. While it is universally agreed that mixing signed and unsigned variables in code is bad, Java's lack of support for unsigned numeric types makes it somewhat unsuited for low-level programming.
  • C#'s namespaces are more similar to those in C++. Unlike Java, the namespace does not specify the location of the source file.
  • C# includes delegates, whereas Java does not. Some argue that delegates are extremely useful, but others point out that their inclusion complicates the method invocation model.
  • Java requires that a source file name must match the only public class inside it, while C# allows multiple public classes in the same file.
  • C# allows the use of pointers, which some language designers consider to be unsafe, but certain language features try to ensure this functionality is not misused accidentally.
  • C# supports the goto keyword. This can occaisonally be useful, but the use of a more structured method of control flow is usually recommended.

See also

External links

 

<< PreviousWord BrowserNext >>
blagoveshchensky district
marty klein
fyodorovsky district
miguel cabrera
stable (professional wrestling)
bernhard schlink
betty dodson
sell (professional wrestling)
weibel palade body
workrate (professional wrestling)
wgpr
ictal headache
soda constructor
flatiron building (atlanta)
explicitly parallel instruction computing
nissen fundoplication
list of movies set in miami
neyman pearson lemma
blaxton
economy class syndrome
schwinger's variational principle
hatfield, south yorkshire
wolfgang borchert
germany must perish!
seven mile island
roland emmerich
mishkinsky district
swiss prot
nathan clifford
progressive corporation
the wetlands institute
shaw prize
gavin maxwell
west end (disambiguation)
jkulsrln
alfa romeo 158
fjallsrln
frederick gustavus burnaby
breirln
list of u.s. insurance companies
list of new jersey related topics
pensato
stitch
marina vlady