visual basic.net is case insensitive so it allows the coder to write without caring or remembering the casing of variables. it also relieves from the 'undeclared variable' errors if you use the variable in another case than the one used in declaration. The fact that its line termination is a line feed makes it even more readable unlike C# or c++ that need good care in the casing and contineous war with following up with the {}, matching them and figuring out which is for which.
my question is what are the advantages of c# over vb knowing that both get compiled to MSIL so there is almost no performance difference between the two languages?
Casing doesn't excite me; especially with any decent IDE you'll have intellisense, auto-complete, auto-correct, etc. Worst case: the compiler finds it for you. And I really don't buy that being forced into a specific line-space pattern is a good thing (and yes, I used VB for years).
It is true that c# and VB.net have a lot of convergence, especially now with dynamic (which helps plug the only real gap in c# bs VB.net).
For a powerful c# feature: iterator blocks (aka yield return). Also; the lambda syntax is more complete/versatile.
But a less-specific argument: having used both extensively, I find c# more expressive, simpler to read/maintain, and cleaner. In short: I like it lots ;)
There is also the case that starting witha syntax familiar to java/c/c++/JavaScript makes transfer easier.
For one, the community for C# is much larger.
The vast majority of code samples on for example a site like http://www.codeproject.com/ is in C#.
My advise would certainly be to go for C#, if only for this reason.
I come from a Delphi background and felt like you about case-sensitivity a few years ago. But once I worked with C#(learning the casing convention) for a few days I noticed that's it's a much smaller error-source than anticipated.
Case sensitivity in statically typed languages doesn't matter much.
In case sensitive languages, you don't get it wrong that often even when programming without an IDE since you know the casing isn't arbitrary, but follows from the convention(Some languages such as Cobra even force you to follow the convention). And with an IDE it's even less important, since intellisense is fixing it for you.
IMO forcing you to follow the convention everywhere leads to better readable code. When I programmed in Delphi(case-insensitive) my casing was quite inconsistent. But modern IDEs for case insensitive languages should have a Format-Document feature which makes the casing on identifiert use the same as the identifier was declared with. So again that's obsolete with modern IDE technology.
For some dynamically typed languages case-sensitivity is essential
While this doesn't apply to VB vs C# some dynamically typed languages(lua, javascript) work only well with case sensitivity. This is because in them string
keys into a dictionary and member-names are almost the same. And case sensitive dictionaries are much more powerful that case insensitive ones.
Essentially none.
VB.NET was created to lure existing Visual Basic / Office programmers, C# to lure the ones preferring Java / C++.
精彩评论