What I love about VB.NET.
Posted
Sat, Feb 26 2005 14:00
by
bill
Via, Yag, Paul, and Jay, Scott touched on some of the nice things VB.NET has to offer. So I thought I’d add to that list the things I love. Some of these are what I see as improvements over VB6, some as advancements compared to C#....
- Block property declarations. This feature is one I use the most often (how can one avoid it after all <g>), but it is also one I really love. It just feels more anatomically correct ;)
- Structured Error Handling. (SEH) . Once again, this just feels more natural to be able to explicitly wrap a block of code inside a specialized error handling block. OF course you can achieve the same pretty much with VB6 style On Error GoTo, but the clear explicit structure is not there, rather you have to interpret it from the spaghetti
- Pretty listing. Yeh it’s just an IDE thing, but one I love. No more worrying about indenting code manually.
- Option Strict. Detect errors at design time, rather than runtime.
- Background compiler. Detect errors at design time rather than compile time.
- Formal Interfaces declarations. Sure you could do these in VB6, but it felt more like an abstract base class rather than an interface. So it’s more a style than a functionality thing, but one I like :)
- Explicit Interface mapping. This is incredibly cool. Unfortunately a lot of people just don’t get how important this concept is to true OO. I’ll blog about this separately me thinks, suffice it to say for now is that it formalizes the contract in a clear robust explicit and flexible manner.
- Delegates. Them just sweet. Not syntax sugar kind of sweet, no, these are the purest finest honey :)
- Parameterized constructors (as Scott mentioned). This really comes in handy when creating object purely to pass to another method. When all is said and done it really is just a matter of cutting down on lines of code.
- Multiple types per code file and Nested Types. Multiple types per code file is great when wanting to write quick tests etc, but I do tend to split code out to one type per code file for the most part. Nested types on the other hand are really cool as they allow encapsulation of types you don’t want exposed.
- Explicit Event handler mapping
- Explicit structure member layout. With win32 API this rocks !
- Explicit casting. CType or DirectCast, such as CType(myfoo, IBar).DoIt
- Implementation Inheritance. I think this one is highly over-rated, but it is also indispensable when you do really need it.
- Threading. Also often over rated IMO, but also indispensable when you need it.
- ASP.NET versus ASP. No comparison, asp is just scripting totally devoid of event driven structure or strong typing etc. ASP.NET kicks azz !!
There’s probably a lot more little things but I’ll leave the list at that for now. As to VB.NET over C#, VB.NET is actually a far more OO language when you look at the actual implementation details. It also is case insensitive which is closer to natural language. (u don’t have 2 spe4k 1337 to gr0k that 1) , and it is written more like we speak. The most obvious example of which is the End xxx constructs. Compare VB.NET code to the }}}} of closing a if block inside a method inside a class inside a namespace, and you should easily see what I mean .
As to VB6 compared to VB.NET, I think many of the enhancements I list above could easily be applied to VB6. Yes I do strongly believe that another version of VB6 is still warranted, one with many of these enhancements.