On Visual Basic .NET

From what I hear, Visual Basic .NET is one of the most hated languages in existence. And so I am baffled as to why I'm enjoying it. Is it just the shininess of new paradigms and techniques? Is PHP really the absolutely bottom of the barrel of languages? Until I spend more time with VB .NET and other languages (especially C# .NET), I can't say for sure.

What I can say is that there are things about VB .NET that I love and a things that I hate. Coming from the perspective of a LAMP developer, a Windows Forms application written in VB .NET is a huge change. Here are my thoughts on Visual Basic .NET after about 6 weeks of working exclusively in it:

  • I really like stronger typing. I mentioned this in my Post-PHP thoughts, but I'll mention it again here. I like neatly structured data and type hinting. I like structures and interfaces quite a bit. However, I have found polymorphism to be trickier. I had to experiment before settling on a dictionary to store config data in a series of classes that implemented the same interface, and I'm still not satisfied with it.
  • VB .NET scoping is atrocious. I'm not sure if I prefer global-by-default or local-by-default, but some of the work I am doing is hell because I don't know who is modifying a variable or where. Naming conventions are good, but if they aren't followed, it is easy to get lost. Granted, this issue is partially caused by the decisions of the developers, but VB .NET certainly didn't help.
  • I don't miss AJAX. When working in the LAMP stack, I needed to bounce between PHP and JavaScript to create live interaction of elements. I used jQueryUI for dialogs and widgets, and jQuery for asynchronous requests. The PHP needed to generate the HTML, the JavaScript would enhance it and hit up the server for interaction, then update the HTML. It's all kind of a pain in retrospect. Windows Forms is much more streamlined. It's all in the same language, and form elements are just objects to manipulate like any other.
  • I like persistent state. In PHP, state is faked through cookies, but each request is still a single, isolated event. I can use JavaScript or the database to pretend I have state, but I really don't. With software, true state exists and I like it. It just feels much more efficient to store a small amount of state data than to do a DB lookup on every request just to find out the user's name.
  • Dealing with threads and locking is tedious. Some of the code that I've written could easily have been a 10 hour loop that locks the display the whole time. Instead, I wrote it as a timer coupled with a finite state machine and that seems to work just fine. Except I always have to be aware on each tick of the loop to make sure I'm not trying to manipulate data that originated in another thread.
  • VB .NET is extremely verbose. It feels like writing XML again. Each statement has very clunky strings wrapped around it. Visual Studio does a good job auto completing, so I don't notice just how much the 'End' keyword comes up.
  • I now understand the difference between dictionaries, lists, hashes and arrays. That was first brought to my attention with eevee's PHP is a Fractal of Bad Design article and I did not understand it at the time. But now that I've been forced to work with each type, I can see how they all have their own time and place.
  • Language level error messages are obnoxious. PHP relies solely on error messages, but then leaves the user code to maybe use exceptions, maybe use custom errors, maybe use built in errors and just let it die gracelessly. I really like how VB .NET uses exceptions for everything that isn't a compile error. It makes it much easier for me to rely on exceptions in my own code, since I don't have to do multiple checks when things get hairy.

With how derided VB .NET is, I'm sure I will eventually drift towards C# .NET, which seems to be much more loved. That isn't to say I only go where the crowd goes, but sometimes the crowd isn't wrong when they form a consensus. For the time being, I will still work mostly in VB .NET since that is what the existing code base is written in. I'm trying to write a little app on the side in C# .NET (with some C++ .NET thrown in), but with my time being very limited lately, I don't know how that will go.