VB.NET, option strict on
After much pissing around with it, a buddy at work here wandered behind me to check out what I was working on, he has been using VB.NET for quite some time now so I explain the issue too him. He laughed at me (mocking my pathetic VB.NET skills) and told me to turn "option strict on". With much disgust I tossed it at the top of the sample file and viola the compile time error finally decided to rear its ugly face. ~Of course I realize that this has nothing to do with Generics, but either way..
People wonder why I'm really starting to dislike VB.NET. Shouldnt this stuff be defaulted to on? There are many many people out there that will probably flame me for this post, but come on why bring VB to .NET and still allow VB programmers to be so damn lazy with everything (which causes so many stupid little errors) ?
Also, my final rant on VB.NET, why didnt it use the same keywords and syntax as C# for many of the new features? A simple example is C#'s "static" keyword, why do we need to remember that, in VB.NET, we must use "shared" instead. IMHO the MS VB.NET team should have copped a squat with the C# team and hashed out a common set of keywords that share functionality. VB.NET seems like VB with hacked in OOP features, no cohesion.
13 Comments
Comments have been disabled for this content.
Darren Neimke said
Rob, change it at the Project level. That way you don't have to type it in each file. Also, that way you can change the defaults at "policy" level by changing the VS Project files for VB Projects... but, yeh, I agree, the product should be shipped with that as the default!
Darren Neimke said
Rob, change it at the Project level. That way you don't have to type it in each file. Also, that way you can change the defaults at "policy" level by changing the VS Project files for VB Projects... but, yeh, I agree, the product should be shipped with that as the default!
Rob Chartier said
I was actually only using Notepad for this, and in that case (the vbc.exe compiler itself) should default to having it on.
Duncan Mackenzie said
The person to ask would be Paul Vick, but I suspect the reason for defaulting to off was to allow you to open VB6 projects (or paste in VB6 code) and have the most chance of it working.
There is a lot of VB6 code out there, so I can understand that being a priority when choosing the defaults.
As far as Shared vs. Static. VB6 already has the keyword Static, and it doesn't mean quite the same thing, so perhaps that was a reason for going with a new keyword.
One could also ask why the C# team didn't just choose to use the same syntax as VB.NET, to just reverse your question... but both languages have different goals and somewhat different audiences so I believe they hoped to design the best language for their audience rather than focus on people who will be programming in both (a smaller group than those that will work in mostly one or the other).
Doug Reilly said
On many issues I agree with allowing default behavior to work so that code moved forward works. In this specific case, I think it was a mistake. They could have turned Option Strict On and Option Explicit On by default, and then if folks have old code they are moving forward, make sure the error message is specific about how to resolve it.
Darren Neimke said
Just one quick note - when I said:
"the product should be shipped with that as the default! "
I was specifically referring to Visual Studio (as opposed to the VB compiler)
Paul Laudeman said
Or they simply could have made it to default as on for any *new* project created, and default it to *off* for any upgraded project. This is really causing a lot more problems out in the real world than I guess MS would have anticipated. Hopefully they might take this suggest to heart with Whidbey.
Wallym said
There has been a lot of screaming about Option Strict not being on, but MS doesn't want to change it. I understand both sides of the issue, but I just wish it was on by default.................
Wally
AndrewSeven said
Perhaps those who believe it should be on by default should be writing c# instead?
Paul Laudeman said
Ha, Andrew. You'd think that, wouldn't you? C# is my first choice, no question, when it comes to .NET development. Unfortunately, being a consultant I hardly ever have the luxury to make the choice for the client about which language to use (although you can be sure I make my preference known).
The whole problem is that there are many companies who are now migrating to .NET from VB6 and VBA and see VB.NET as the natural upgrade path. The unfortunate thing is that they want to invest as little time and training as possible (naturally) in learing good OO and design skills so they basically carry all their baggage with them to .NET, so what you end up with is a bunch of displaced VB'ers who don't know a class from a module or strong typing from variants (and who don't typically care to learn so long as they can just hit F5 and run)...
DeBruyne said
What types of variables are created by the following declaration if Strict Option is off ??
Dim a, b As Integer, c
DeBruyne_458@HOTMAIL.COM
Joshua said
Shared has been a keyword in basic for a long time. The original meaning was a variable declared Shared at top level was visible in functions in the project.
Flavio said
Dim a, b As Integer, c just do a Console.WriteLine(a.GetType().ToString()) or something like that... I WOULD say that a,b are integers and c an object... but not sure...