2013年8月5日 星期一

compare c sharp with java

inf: http://www.pickatutorial.com/tutorial/csharpprogramming/csharp_java_similarities.htm


C# is a very powerful programming langauge by Microsoft. Its first version a.k.a. C# 1.0 released by
Microsoft in June 2000 as part of its .NET framework. C# inherits many of the featurs of C, C++, Java and Visual Basic. In short C# is a general-purpose, type-safe, platform-neutral and robust object oriented programming language. The most current version of C#, as of this writting, is 4.0 and is shipped with .NET framework 4.0.

C# has been derived from the C programming language and it has many features similar to C programming language. C# also has some of the features available in Java programming language e.g. garbage collection. Also similar to Java, it is object-oriented and comes with an extensive class library, supports exception handling, multiple types of polymorphism, and separation of interfaces from implementations.

The above mentioned features, combined with C#’s powerful development tools, multi-platform support, and generics, make C# a good choice for many types of present day software development projects, large or small. C#’s strong typing helps us prevent many programming errors that are common in weak typed languages.

C# is Similar to Java and C++ in many respects, as you will see in the coming lessons. The .NET platform is centered around a Common Language Runtime (CLR - which is similar to a JVM) and a set of libraries which can be exploited by a wide variety of .NET enabled programming languages like C#, Visual Basic and F# etc.

This tutorial assumes that you are a C++ or Java developer and you want to learn the fundamentals of C# programming language.

Important:
This tutorial assumes that you have installed Microsoft Visual Studio 2010. Infact Visual Studio 2010, like its predecessor versions of Visual Studio, is a tool-rich development environment, prviding you every tool that you may need to develop small or large scale C# projects.

C#, C++ and Java are very similar in nature. For example the basic syntax of all of the three languages is almost identical.

The focus of this lesson will be on the major similarities of Java and C#.
C# and Java both compile into a machine independent code, which then runs in a managed execution environment. In other words both C# and Java compile initially to an intermediate language. In the case of C# it is called as Microsoft Intermediate Language (MSIL), and in the case of Java it is known as Java bytecode. In each case the intermediate language is run by interpretation or just-in-time compilation - on an appropriate 'virtual machine'. Java bytecode is run by JVM and the MSIL is run by the CLR.
Both languages have powerful reflection capabilities.
Both of these support only OOP and all classes descend from the Object class.
Both of these have garbage Collection coupled with the elimination of pointers. In C#, however, restricted use of pointers is permitted within code marked as unsafe.
Unlike C or C++, in Java and C# there are no header files. All code is scoped to packages(Java) or assemblies(C#).
Unlike C++ there is no problem in declaring one class before another with circular dependencies.
Objects must be allocated on the heap with the use of the new keyword.
Both support concurrency through thread support by putting a lock on objects when entering code marked as locked / synchronized.
Both have single inheritance and support for interfaces.
There are no global functions or constants, everything belongs to a class.
There is built-in bounds checking of Arrays and strings.
The "." operator is always used and there are no more -> and :: operators.
All values must be initialized before use.
Integers cannot be used as boolean.
In both languages try blocks can have a finally clause.





沒有留言:

張貼留言