Herfried K. Wagner said:
In VB.NET you can write 'Dim x As SqlConnection = New SqlConnection()' too.
'Dim x As Y' is more self-describing than "Y x;" and thus less confusing,
especially for beginners.
How long do you really think it takes to get used to the syntax that
doesn't include redundant text? Have a look at the casting syntax in C#
compared with VB.NET - do you really think that the CType syntax is
more elegant than the casting syntax? (Admittedly I wish that the
unboxing and conversion syntax in C# were distinct from casting, but
that's another issue. There are various things I'd like to see done
differently in C#...)
I'll certainly accept that C# has a bit of a steeper learning curve
than VB.NET, but I don't think that's the be all and end all.
In terms of a language itself, of course, it's significantly smaller
than VB.NET - what there is may be slightly harder to learn, but there
are far fewer keywords - 78 in C# compared with 151 in VB.NET. That's
from the VS 2005 beta 2 docs, not including unreserved keywords in VB
or those beginning with #. That's also not including all the VB built
in functions, many of which have been carried over from previous
versions of VB despite perfectly reasonable versions of many (most? I
don't have enough experience in VB to know) being available in the
framework.
In short, being a new language, C# doesn't have nearly as much baggage
as VB.NET does. (There are one or two places where C syntax has
unnecessarily been carried over, and that's a shame, but it's far from
the same situation as in VB.NET.)
C# doesn't have advantages with 'Option Strict' and 'Option Explicit' turned
on. In fact VB.NET is even more strict than C# with these settings applied.
In a very few cases - but not in many others.
Consider the following piece of code:
\\\
bool a = ..., b = ...;
if (a = b)
...;
///
A beginner wants to compare the values of 'a' and 'b' and forgets to type
'==' as comparison operator. The code will compile and it's very hard to
find the logical bug. This gets even worse when dealing with more complex
expressions.
Only where you're comparing two boolean values directly, which I find
to be pretty rare. I'll certainly accept that there's potential for a
bug there though. How often have you actually seen that bug, out of
interest?
In VB.NET, potential problems like this do not occur as often.
Consider the following then, where "thread" is a variable of type
Thread:
thread.Sleep(5000);
If you were a beginner, what would you think that would do? In C# it's
not valid because Thread.Sleep is a static method. In VB.NET (2003) it
compiles without a warning, even in Option Strict mode. In 2005 it's an
optional warning/error, fortuantely.
Another example - C# doesn't let you use a local variable unless it's
been definitely initialised. VB.NET (2003) does - again, a new
warning/error in 2005.
Another example - VB.NET lets you pass properties by reference, even
though the semantics are significantly different in terms of timing and
what happens if an exception is thrown. I wonder what proportion of
VB.NET developers really know what happens when a property is passed by
reference?
The great thing is that you can turn the feature off and work with strict
semantics, without loosing the benefits of a BASIC-type programming
language.
Even "strict" isn't strict enough for me though - see above.
As for the benefits of a BASIC-type language - they remain to be shown
to my satisfaction.
I don't think that it's a big problem either, but in VB.NET you don't even
need to doubleclick anywhere or watch at tooltips, depending on the IDE you
are using.
And as I say, you don't need to in C# if you write readable code to
start with.
I don't see much need for C#. On the one hand, C++/CLI will strongly
improve developing managed/mixed solutions using C++, on the other hand the
VB.NET programming language is IMO more suitable for general .NET
development (libraries, database development, web development) than C#
because it encourages developers to write CLS-compliant code.
You can force C# to be CLS-compliant too very easily - just add the
CLSCompliantAttribute to the assembly.
You might want to consider this similar to the fact that VB.NET doesn't
even have Option Strict on by default - which is *far* more dangerous
than non-CLS-compliance, in my view.
C# is *much, much* easier to develop in than C++, even managed C++, and
I still find it a significantly better language than VB.NET for pure
..NET development.
Are you able to show that VB.NET developers are more productive than C#
developers, by the way?