|
The correct title of this article is Comparison of C# and Visual Basic .NET. The substitution or omission of a # sign is because of technical restrictions.
The original .NET Framework distributions from Microsoft included several language-to-IL compilers, including the two primary languages: C# and Visual Basic. There is heated debate among the greater .NET community about which language is better in general, or for specific purposes. Below is a comparison of the two languages.
CompatibilityIt should be noted that all .NET programming languages share the same runtime engine, and when compiled produce binaries that are seamlessly compatible with other .NET programming languages, including cross language inheritance, exception handling, and debugging. No second class languagesOne of the main goals of .NET has been its multi language support, and the concept of "no second class languages". That is, all of the various Microsoft languages should have the same level of access to all OS features, and all expose the same level of power and usability. It should be noted that Visual Basic and Visual Basic .NET are completely different languages and are not backwards-compatible. Visual Basic .NET shares only syntax similarities with Visual Basic. The Abstract syntax tree for Visual Basic .NET and C# are closely matched and the intermediate language produced by the compiler is virtually identical. It is possible to compile C# code into IL and use a decompiler to convert the compiled IL back into Visual Basic .NET source code - such is the similarity between the languages. C# shares syntax similarities with Java. Both C# and Visual Basic .NET share structural similarities with other modern high level languages such as Java and C++. However the differences between Java and .NET are numerable, as can be seen in Comparison of Java and C Sharp. Development EnvironmentVisual Studio provides minor differences in the development environment for C# and VB.Net. With the release of subsequent versions of Visual Studio the differences between the languages have reduced. For instance early versions of Visual Studio had poor support for Intellisense in C# compared to Visual Basic .NET. Exclusive C# Development Environment FeaturesExclusive VB.Net Development Environment Features
Language featuresThe bulk of the differences between C# and VB.NET from a technical perspective are syntactic sugar. That is, most of the features are in both languages, but some things are easier to do in one language than another. Many of the differences between the two languages are actually centered around the IDE. Features common to all .Net languagesThese features are common to both C# and VB.Net as well as all languages running the .Net platform.
Features of Visual Basic .NET not found in C#
Features of C# not found in Visual Basic .NET
Criticisms of Visual Basic .NET not applicable to C#
Criticisms of C# not applicable to Visual Basic .NET
Syntax comparisonsVisual Basic .NET terminates a block of code with In C#, when a block is not defined for a statement, the next statement will be treated as the block. Sometimes C# developers will add comments at the end of scope to more easily mark where the scope started. For instance some C# developers use KeywordsKeywords are very different between the two languages. A comparison: (VB.NET vs C#)
Notice above how some C# keywords such as Comments
Note that for Visual Basic .NET, multiple lines of code can be commented or uncommented using the Visual Studio IDE. As such having no support for Multi-line comments in the language is a disadvantage only when the IDE is not used. if-then-else
For loop
Equality and other comparison operators
PerformanceAdoption and community supportBoth C# and VB.Net have high adoption rates, and very active developer communities and Microsoft fully supports both communities. However, C# does have an advantage in terms of the level of community activity on the Internet. Also, there are more books available for C# than VB.Net, and publishers report that C# books significantly outsell the VB.Net counterparts. Examples of the increased community and industry adoption include:
As counter examples
Other languagesC++/CLI (formerly Managed C++)C++/CLI (a replacement for Managed Extensions for C++) does not have the adoption rate of C# or VB.NET, but does have a significant following. C++/CLI syntactically, stylistically, and culturally is closest to C#. However, C++/CLI stays closer to its C++ roots than C# does. C++/CLI directly supports pointers, deconstructors, and other unsafe program concepts which are not supported or limited in the other languages. It allows the direct use of both .NET code and standard C++ code. C++/CLI is used for porting native/legacy C++ applications into the .NET framework, or cases where the programmer wants to take more control of the code; but this control comes at a significant cost of ease of use and readability. Many of the automated tools that come with Visual Studio have reduced functionality when interacting with C++ code. This is because reflection cannot provide as much information about the code as it can for C# and VB.net J#J# runs a distant fourth in terms of adoption. J# is a language primarily designed to ease the transition of Java applications to the .NET framework; it allows developers to leave much of their Java or J++ code unchanged while still running it in the .NET framework, thus allowing them to migrate small pieces of it into another .NET language, such as C#, individually. J# does not receive the same level of updates as the other languages, and does not have the same level of community support. For example, Visual Studio 2005 supports automatic generation of Unit Tests in C#, VB.Net, and C++, but excludes J#. J# is not included with Visual Studio 2008 and thus discontinued. Minor languagesThere are many additional languages available for the .NET Platform. CILAll .NET languages compile down to Common Intermediate Language (CIL) , but it is also possible to code directly in CIL. This can be done for performance or security reasons, or just for fun. It is a common practice to make source changes in the original C# or VB.NET, and then compare the resulting CIL, to see what benefits or consequences might result[verification needed]. Coding directly in CIL often makes code that is difficult or impossible to de-compile to a higher level language like C#. Either the decompile fails, or the resulting code is not very readable. This is analogous to writing directly in assembly language, and then decompiling to C++. This technique is used by many obfuscators to help prevent reverse-engineering. It is possible to code an entire application directly in CIL, but this would be very cumbersome. ReferencesExternal links
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net