As I've continued coding in VB.Net at my new(ish) job, the "WTF!!!" factor has reduced substantially, although I still do a lot of backtracking to insert Dim statements. For the most part, I've realized I can do all the same stuff in VB that I did in C#, along with a couple of nice things like the great pile of VB snippets that ship with Visual Studio compared to the meager offerings for C#. Don't get me wrong, I'd still rather be coding C#, but I've come to terms with the fact that they really are the same thing when it comes down to the CLR, and except for a few small differences, it's really just a matter of personal preference.
Or is it?
It's certainly not my personal preference, in this case. So I guess it's enterprise preference. But wait, who decides enterprise preference? Someone obviously does, someone who probably makes a helluvalot more money than I do, and probably doesn't code any more if they ever wrote code in the first place. What I've been wondering lately is this: if both VB and C# compile and run on the same .Net runtime, why do enterprises care which language its developers use to write .Net applications? Just because I've been coding VB for the last three months doesn't mean that my C# skills have atrophied off like an unused extremity. I can still read and write C#, and when I coded C# for a living ("enterprise standard" at my old job) I could still read and write VB. Once folks understand the simple syntactic differences between the two, square brackets for arrays, angle brackets for generic type identifiers, "Dim thing as type," Function and Sub, etc., it's really not hard at all to read and understand both.
The common answer I hear to this question is that the enterprise wants everyone coding in the same language to...
- Promote code reuse.
- Make it so that if department A happens to be on a team building exercise at the archery range and they all get impaled on crazy boomerang arrows, department B can "seamlessly" pick up where the dead folks left off.
Superficially, these reasons make a lot of sense. Code is easier to share and recycle if it's all in the same language. Joe Developer coding VB in the Wonky Department on the 12th floor can read Jane Developer's code, even though she works on entirely different stuff in the Hinky Department on the 3rd floor. And that's good, because Jane wrote a really cool snippet for connecting to the company mainframe and screen-scraping something or other. But wait...why does Joe even need to read Jane's code? It seems to me that if Jane wrote that functionality in C#, she can simply bundle it up into an assembly, compile it, and offer it to Joe as a referenceable DLL.
All Joe sees are the members of Jane's object after he references, and Visual Studio translates that to VB for him anyway.
Joe doesn't even see "public string CSharpMethod(string inVal)." Pretty nifty runtime conversion there, if you ask me. Another example of the inherent quality built into the Visual Studio IDE.
Can somebody please tell me why I can't write my applications in C# even though my boss wrote applications in VB?