by smacktoward · 6y ago · 0 comments
Given how big C# ended up becoming, I'm wondering why anyone committed to staying in the .NET ecosystem would have stuck with VB.NET all this time. What's the attraction? I could see it as a transitional stage to get classic VB developers started on the road to C#, but as a long-term solution it seemed doomed to chronic suffering from birth.
I've seen several moderately large and active projects (5+ developer maintenance team) still surviving to this day, running on VB.Net. In most cases though, these were started in the mid-2000s, simply due to manpower questions, not language advantages. I recall being moderately surprised even circa 2008 that the author of CSLA.Net (an interesting object-oriented framework) was mostly using VB.Net. I guess from their point of view, they were more proficient in that languages, and the cost of switching was too high. I definitely don't see any rationale for benefits, akin to say F# vs C#.
I think the MS world of the time was very much a monoculture (and would be until circa 2010 or so), which lead to a lot of developers who had only ever really worked in one main language (plus maybe SQL / T-SQL). I tend to think this is quite similar to children growing up in a single-language vs multi-language environment. The patterns tend to get ingrained in your brain in the former, and there are few signals for our brain to understand that "this concept can actually vary from language to language, don't get too used to it", making later shifts much more difficult. It's kind of a case of over-fitting the data, which is the first language they learned, in this case. I think a lot of the VB and then VB.Net developers had this kind of strong mono-culture of language, which compounded the need to keep VB.Net alive for longer. This may have been further compounded by VB's image as a beginner-friendly language, which a lot of people took up to get into the industry as outsiders, without any formal or informal experience. I really do think this might be the main factor. VB.Net may have had a few tiny advantages in terms of semantics (slightly looser casting and conversion rules), syntax clarity ("static" vs "Shared" - an example of a keyword which is objectively clearer in VB, IMHO), or some convenience libraries (I recall occasionally having to reference core .VisualBasic assemblies to get hold of some helper method which was missing on the C# side, for no apparent reason). But it also had just as many detractors, and I would not think any of these were nearly enough to lead to people choosing it over C#.
I don't really feel any pain switching between them, apart from VB.net is a bit annoyingly verbose and I always forget how to do linq lambda functions in it.
One tip I would add is that you can change the colour of the matching {} when you're in a block scope. VS actually highlights the opening and closing of the block. Usually not much of a problem due to auto-indenting, it can help a lot with complex code.
For some idiotic reason the default is a very light grey, but if you make it darker or a different colour, picking out ending } or starting { becomes trivial.
Ada is a lot like this too. I can read, compile and run it in my head during a gerrit review with almost no glitch by now. Written once, read 20 times at least.
There was some talk on HN yesterday about making your code easily changeable. First step is to make it easily readable, understandable. Little things help. End loop helps. Exit loop_name helps. Non-fallthrough case statement help. in / out / in out help so much. Pre and post conditions help also. Clear static types help. Internal functions help. Explicit generic instantiation, while a pita to write, helps a lot at code read time... Lots of lead bullets.
As a simple example you can write an if block with `if...end`, and this will be automatically rewritten as `if...end if`.
I wish every language had built-formatting and also made the reading/writing distinction!
In C-style syntax there's often disagreement on how to format blocks, but there's rarely a disagreement in VB: there's naturally only one choice.
Maybe take the best of VB and Pascal, clean up the key-words by tossing legacy inconsistencies, and produce a next generation "word-oriented" style. #MVBGA!
Personally, I think every balanced marker (parenthesis, block beginning/termination, brackets) adds a maintainabiliy cost and is better replaced by some unbalanced alternative (on the case of blocks, semantic whitespace is the current winner). The largest the thing inside the markers, the higher the cost.
In C# the end to an if and a try both look the same. In VB they don't.
As for the complaints of something being verbose, I see people constantly adding comments to close braces to indicate what it was they closed.
...lots more code up here...
return result;
}
}
}
return -1;
}
What's that next-to-last "}" for? To find out, I need to scroll way up, and hope the code is properly indented, or use an IDE feature to collapse the block.But with a Pascal-family language, it would be more like this:
...lots more code up here...
return result
End If
End Loop
End While
return -1
End Function
It is more verbose - but its verbosity with a purpose, and it helps me avoid the distracting question "What is ending here?".