|
Comparison of C Sharp to Java - Definition and Overview |
| Related Words: Affinity, Agent, Agreement, Alliance, Alternative, Analogy, Approximation, Assimilation, Backup, Balance, Balancing, Change, Changeling, Community, Conformity, Contrast, Copy, Copying, Correspondence |
|
|
- The title given to this article is incorrect due to technical limitations. The correct title is Comparison of C# to Java.
This is a comparison of the C# programming language to the Java programming language.
Similarities
- Both languages were derived from C/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, in the case of C# the .NET framework.
- Both languages have syntax rules which catch a large number of common programming errors (related to initialization, etc.).
- 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 the Java VM and the .NET platform optimize code at runtime through just-in-time compilation (JIT).
Advantages of C#
- Tied more closely to the Windows operating system, making for better performance in OS-specific tasks such as user interface.
- The .NET framework already supports a much larger number of languages, making 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 considered to be a "first class citizen" in that it is part of the language itself.
- C# is defined by ECMA and ISO standards, whereas Java is proprietary.
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, one must note that C# is submitted to ECMA for standardization while Java is still entirely controlled by Sun Microsystems.
- It is still unclear whether C# design and implementation include software patents potentially enforcable by Microsoft. However, some argue that Microsoft's strong backing of C#'s standardization indicates 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.
- Language is simpler, making code easier to optimize at compile-time.
- 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# does not include checked exceptions. Some would argue that checked exceptions are very helpful for good programming practice. Others, including Anders Hejlsberg, chief C# language architect, argue that they were to some extent an experiment in Java and that they haven't been shown to be worthwhile [1] (http://www.artima.com/intv/handcuffs.html).
- 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, which generally leads to poor quality code, but is occasionally useful.
See also
External links
|
|
Example Usage of Comparison |
 |
discoelectro: ah sweet online peep show! Isn't is suspicious how smoothly the 4od adverts stream in Comparison to the show itself... |
 |
noneil277: Found this great Comparison spreadsheet explaining all of the Windows 7 editions. http://bit.ly/4UYpwb |
 |
mooks19: @inetespionage Aside from the asinine Comparison is the disclaimer that she worked hard to get him elected, that she had high hopes for his |
|
|