Key difference: Java is a programming language, which has been influenced by the C language. It derives much of its syntax from C and C++, however it has fewer low-level facilities than either. Java is a general-purpose programming language that is designed to have fewer implementation dependencies as compared to previous languages. C#, also known as C sharp, is an object oriented programming language. C# is a multi-paradigm programming language. C# is based on the C programming language. It was originally developed by Anders Hejlsberg for Microsoft for use in its .NET framework.
Java is a programming language, which has been influenced by the C language. It derives much of its syntax from C and C++, however it has fewer low-level facilities than either. Java is a general-purpose programming language that is designed to have fewer implementation dependencies as compared to previous languages. It is concurrent, class-based, and an object-oriented language.
Java was developed by James Gosling at Sun Microsystems and was released in 1995. It was originally released as a core component of Sun Microsystems' Java platform. Sun has since re-licensed most of its Java technologies under the GNU General Public License. This means that all the technology licensed under GNU General Public License is open source and generally available free of cost. Sun Microsystems eventually merged into Oracle Corporation.Sponsored Links
Java is designed to allow the same code to run on various platforms. i.e., developers are allowed to “write once, run anywhere” (WORA). Hence, Java applications are typically compiled to bytecode. A class file which contains a Java bytecode can then be run on any Java Virtual Machine (JVM). This would be regardless of computer architecture.
As of 2012, Java has become one of the most popular programming languages for use. This is especially true for client-server web applications. Many other systems have developed alternative implementations of Sun technologies, such as GNU Compiler for Java and GNU Classpath.
C#, also known as C sharp, is an object oriented programming language. C# is a multi-paradigm programming language. It includes strong typing, imperative, declarative, functional, procedural, generic, object-oriented (class-based), and component-oriented programming disciplines.
C# is based on the C programming language. It was originally developed by Anders Hejlsberg for Microsoft for use in its .NET framework. The C# language was later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of the programming languages designed for the Common Language Infrastructure. C# is intended to be a simple, modern, general-purpose, object-oriented programming language.
The design goals for C#, as listed by the ECMA standard:
- The C# language is intended to be a simple, modern, general-purpose, object-oriented programming language.
- The language, and implementations thereof, should provide support for software engineering principles such as strong type checking, array bounds checking, detection of attempts to use uninitialized variables, and automatic garbage collection. Software robustness, durability, and programmer productivity are important.
- The language is intended for use in developing software components suitable for deployment in distributed environments.
- Source code portability is very important, as is programmer portability, especially for those programmers already familiar with C and C++.
- Support for internationalization is very important.
- C# is intended to be suitable for writing applications for both hosted and embedded systems, ranging from the very large that use sophisticated operating systems, down to the very small having dedicated functions.
- Although C# applications are intended to be economical with regard to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language.
As it based on the C language, it is quite similar to it. It even shares some syntactic conventions with C. However, a disadvantage of C# is that, as it was developed by Microsoft for use in its .NET framework, it only works on Microsoft operating systems.
Some differences between Java and C#:
- C# provides more data types as compared to Java.
- C# contains more primitive data types than Java.
- C# supports operator overloading while Java does not.
- C# supports the strut type while Java does not.
- AII data types in C# are strut.
- C# provides better versioning than Java.
- C# allows parameters to be passed by reference by using the ref keyword, whereas Java allows parameters to be passed by value.
- C# allows variable number of parameters using the param keyword.
- C# provides static constructors for initialization.
- C# provides goto statement instead of the break statement.
- Declaration of arrays is different in C# as compared to Java.
- The convention for Java is to put one public class in each file and some compilers require this. C# allows any source file arrangement.
- Java does not support events and delegates.
- In Java, methods are virtual by default but can be made final. While, in C# they're sealed by default, but can be made virtual.
- C# doesn't have checked exceptions.
- Java doesn't allow the creation of user-defined value types.
- Java doesn't have operator and conversion overloading.
- Java doesn't have iterator blocks for simple implemetation of iterators.
- Java doesn't have anything like LINQ.
- Partly due to not having delegates, Java doesn't have anything quite like anonymous methods and lambda expressions.
- Java doesn't have expression trees.
- C# doesn't have anonymous inner classes.
- Java doesn't have any equivalent to the C# 3.0 anonymous types.
- Java doesn't have implicitly typed local variables.
- Java doesn't have extension methods.
- Java doesn't have object and collection initializer expressions.
- Java doesn't have properties as part of the language; they're a convention of get/set/is methods.
- Java doesn't have the equivalent of "unsafe" code.
- Java's enums are much more object-oriented.
- Java has no preprocessor directives (#define, #if etc in C#).
- Java has no equivalent of C#'s ref and out for passing parameters by reference.
- Java has no equivalent of partial types.
- C# interfaces cannot declare fields.
- Java has no unsigned integer types.
- Java has no language support for a decimal type.
- Java has no equivalent of nullable value types
Image Courtesy: sellmic.com, codesmesh.com