Wednesday, February 08, 2006

Wierd stuff about VB.Net (from a C# perspective)

I knew that VB.Net was different, but it's funny how many extra things you find when you have to work on it day in day out:

  • Wierd syntax (of course :-)
  • No documentation comments, or support for tool-tip documentation at break time (hover over String: C# "System.String represents text etc..." VB: "String" :-(
  • Can have dates as constants
  • WithEvents
  • Exposes static methods on instance members, but only by casted type (so no real advantage from a polymorphic perspective)
  • Shadow by name, not by signature
  • With keyword (kinda handy at times)

Syntax hording / Legacy syntax

The VB.Net team seem to be dragging a lot of compatability cruft with them.
eg. 7 different ways of declaring arrays, depending on where you feel like placing the brackets and the array length (watch out for the UBound / out-by-one syntax):

Dim someArray1() As String ' -> Nothing
Dim someArray2(1) As String ' -> Array[2] of Nothing
Dim someArray3() As String = New String(1) {} ' -> Array[2] of Nothing
Dim someArray4() As String = New String() {"One"} ' -> Array[1] as specified

Dim someArray5 As String() ' -> Nothing
' Dim someArray6 As String(1) ' -> Actually not allowed
Dim someArray7 As String() = New String(1) {} ' -> Array[2] of Nothing
Dim someArray8 As String() = New String() {"One"} ' -> Array[1] as specified

  • Assigning return values to the property / method name rather than using Return, which as a consiquence requires...
  • Default return value of 'Nothing'
And they seem to be making more as they go along:
  • Me.New() vs MyClass.New()

  • Funny (slightly disfunctional) pulldowns
  • No pre/post build events
  • No 'close all windows but this' (how wierd is that?)
  • Simplistic flat namespace model (everything in a namespace named by the assembly, hard to change this model)
  • Debugger 'rolls up' class heirachy if not dealing with most derived type - can make it impossible to see some fields / properties on base class that are later shadowed
  • 'This' debugger window actually is a 'Me' window. However what's displayed in all the debugger windows does change from language to language (see above), so what's with not changing the window name...

  • Different order of field initialization (base first)
  • Strange non-transitive equality with empty strings

Good article from McConnel 'Stuck in a VB.Net ghetto'

No comments:

Popular Posts