tags:

views:

380

answers:

12

So, I don't want this to get into a flame war between C# and VB.NET developers. This is purely from a standpoint of a development department going forward. We've been a VB.NET company for years, but that was mainly due to who we've hired. That requirement has fallen off the wayside as of late, as we've pulled in 2 guys who specialize in C#. I used to be a C++/C# guy before converting to VB.NET for this company.

So, to everyone who has to deal with this whether on a hiring basis or a maintainability basis: how do you handle standardizing languages of choice going forward? I'm inclined to make a push for C#, as that'll make 3 solid C# developers here. But just curious what everyone's thoughts on this are.

+2  A: 

On a purely capabilities basis, they are about as close as two languages can get. VB.NET tends to get more COM interactivity and has literal XML -- but C# is getting some of that soon.

It's really just personal preference and what language you think the team can be most productive in.

Lou Franco
+4  A: 

Some years ago we standardized on c# because c# seems to have more of a following among serious developers.

Let me be clear I am not saying anything bad about VB.NET or those who use it.

Jon B
+8  A: 

At a previous client, who had written their mission critical apps in VB, they started to find it more difficult to find VB programmers as opposed to C#.

So they decided to start switching their apps to C#.

As with most IT/Dev questions, the answer is it depends. If you have more people in your department who are great with VB, then go with VB. I don't think one of is that much better than the other.

Jack Marchetti
Exactly. It all compiles down to the CLR using the same exact libraries. The language itself in .NET is just syntactic sugar.
Byron Whitlock
+8  A: 

If you have a lot of code that is already written in a particular language, prefer that language.

Otherwise, if you have more developers well-versed in one language over the other, prefer that language.

Otherwise, prefer C# (it is generally more popular, and feature-wise they aren't different enough to make a meaningful choice over features alone).

Pavel Minaev
+1, good concise answer!
Meta-Knight
It looks like the best course of action for us was to switch over to a C# shop. I'm originally a C++ dev by trade, so that coupled with a bunch of developers being hired on are C# guys and the market for C# guys made it an easy choice. Now, this actually works out also because we have a code library that we're revamping to fit with API standards, so switching it over to C# should be good practice.
LookitsPuck
+3  A: 

That is entirely dependent on the developer pool you have.

schar
+4  A: 

The question you are asking is actually very important, and too many people will tell you that language choice is just personal preference. But you already know that, from the standpoint of an organization, this is not true. Choosing a standard set of frameworks, languages, tools, etc. is an important business decision.

Your programmers should be able to use either language with a little time, encouragement and maybe a little training. C# and VB are close, and there are no significant technical reasons to choose one over the other...

So my advise is to pick your organization's language based on businesses reasons. If hiring C# guys is easier, or if you find they tend to have better skillsets for the kind of work you do then score one for C#. If you write code for customers, and those customers prefer C# deliverables then score another for C#. If you have existing code in VB, score one for VB.

It should be a pretty simple breakdown... just ignore technical reasons and concentrate on how the choice of language will affect your business in terms of hiring, training, ability to deliver to the customer, etc.

Stephen M. Redd
A: 

It sounds like you already have a standard - VB.NET. And maybe you are tempted or interested in getting into C# instead.

It makes very little sense to have half your systems written in VB and half written in C# - although depending on the nature of your organisation this may not apply. But generally, the organisation shouldn't take these changes lightly.

If I was you (and you are interested moving to C# for yourself) then I'd push for C#, but if I was the business then I would need a very good reason to introduce this new complexity, cost & management issue.

Kirk Broadhurst
+4  A: 

If there is a single reason to adopt C# for your company it is the lambda operator. Without the full support of the lambda operator in VB.NET some of the best tools become either crippled or DOA. For example: Fluent NHibernate, StructureMap etc.

Chris Marisic
+13  A: 

As someone who works in a mixed shop, it's not that hard to get by using both. But it helps to have a standard that makes it easier to move code back and forth. Here are few ideas for your standard:

For the VB Developers:

  • Disallow old vb6-style functions in new code. I'm talking about string and other functions (Len, InStr, Replace, UBound, etc). The convert operators (CInt, Cstr, etc) are still okay because they are language operators, but prefer a Convert.To___() function where possible for easy conversion to and from C#.
  • Require Option Strict and Option Explicit. You'll give up some dynamic typing coolness by making it a requirement vs a strong suggestion, but it's worth it to keep the code parity with C#.
  • Standardize on '+' vs '&' for string concatenation (if you're not already using a StringBuilder)
  • Prefer AndAlso and OrElse over And and Or

For the C# Developers:

  • Disallow names that differ only by case. This especially includes names that are basically the same as the type name (SomeType sometype = ...). Tell them to use an _ prefix instead (and not "m_"). You should do that anyway but it's especially important in a mixed shop because that code will be harder to work with in VB.

For both:

  • Disallow ArrayLists and other non-generic collections (because not only are they evil anyway, but VB and C# handle the all required casting very differently, even with option strict thanks to CType)

If you do this, there will be few real differences between the code for the two groups, and you've taken the first step toward teaching the VB developers to think like C# developers.

Joel Coehoorn
Very good points. I work in a VB-only shop but we still follow all of your standards, following these principles result in more robust and type-safe code that is in-line with the framework standards.
Meta-Knight
Joel Coehoorn
Joel, can I get your reasoning on the _ vs. m_? We've had internal discussions about that and determined that it's a matter of taste. Plus there were some vague references to _ being reserved somehow, so we ended up going with m_.
Scott Whitlock
It is _mostly_ taste: the m_ looks really weird in the VB code. Also, this use pattern isn't always a member; sometimes it's a local.
Joel Coehoorn
Meta-Knight
And I do prefer it that way, actually, but if you use both C# and VB it's certainly less confusing to use +!
Meta-Knight
@Joel: I see - that's just for variable names that are the same as type names and differ by case. We solved that because almost all of our class names are entities or entity collections, so we (shock and horror) use hungarian notation with e and c respectively, and only in this case. As a rule we don't use HN, but in this case it does work well.
Scott Whitlock
Please don't use prefix `_` for locals, it would be terribly confusing (it's widely used _specifically_ to highlight fields!). I'm not sure what the standard VB practice for locals is, but personally I've always liked the way Smalltalk does it, by prefixing with `a` or `an` or `the`, whichever makes most sense; i.e.: aCustomer As Customer, anOrder As Order`.
Pavel Minaev
+3  A: 
  1. Talk to some local recruiters, find out what the available skillsets are in your area, if you were to hire more developers. What is available should affect your choice.
  2. Make sure your developers can work with your current codebase, no matter what the language
  3. Ask your developers for their preference, since they may base their decision to stay with the company down the road on the technology.
  4. Have a look at support for those languages in your specific industry. For example, a law firm might need a lot of MS Office and VBA integration. Using VB.NET might have cross-training benefits. Or you might be in an industry that uses a lot of C++, C, or Java based tools. Using C# might be more natural to those programmers.
  5. Look into what sort of training resources you have available in those languages. If you can get more or cheaper training for one specific language, you might want to favor it.
  6. Start thinking about your plan to transition to another language down the road. Even if you standardize today, what about 5 years from now? Or 10? Languages change, needs change.
Andrew Lewis
A: 

Having good reasons to go with one standard over another should be the guiding factor. Use these:

  1. VB.NET seems much more verbose than C#. (ex: "Dim var as MyClass" vs "MyClass var")
  2. C# is similar to C++ and Java. VB.NET is similar to... well, nothing. (unless you count VB6...)
  3. Try making a ragged array in VB.NET. I dare you.
James Jones
1. The verbosity does not cause a productivity problem because the IDE does a good part of the job for you. For example, if you type "If something" then press Enter, Then and End If is added automatically.
Meta-Knight
2. VB.NET does have lambda expressions?? 3. VB.NET is similar to VB6. VB syntax is easy to pick up anyway... 4. Jagged arrays? You need that for what??
Meta-Knight
Oops. I didn't realize VB.NET could do Lambda expressions now. But I get annoyed at having to type "Dim" and "As" every time I want to initialize a variable. And as far as VB syntax being simple, how do you test for referential inequality? "Is Not" or "IsNot"? How about type casting? Would you rather do "(int)x" or "CType(x, int)"? And I think it's hilarious that someone would think VB6 and VB.NET are similar. Apart from there still being "Dim"s and "As"s, the languages are *radically* different to the point where there is virtually zero knowledge transfer from one language to the other.
James Jones
Also, the fact that I need an IDE to generate the verbose constructs of the language only ticks me off more. I don't want my code to appear any larger than it has to. I feel that it's implied that I want to "do something" after I write an if-statement such that I do not need to specify "Then". And FYI, Jagged arrays are an extremely prevalent data structure and I feel that this is a pretty known and accepted fact. Check out the wiki: http://en.wikipedia.org/wiki/Ragged_array#Applications_2
James Jones
If you were coding your application in Notepad, then yes, the verbosity of VB.Net gets annoying quickly. With Visual Studio, Intellisense and ReSharper (if you've got it), the language verbosity is a non issue as far as I'm concerned. FYI, I'm a c# developer.
Chris Conway
I just meant that VB6 and VB.NET have similar syntax, just like C# and C++ have similar syntax yet nothing else in common ;-) As for jagged arrays, my point was that in many scenarios (like mine) you don't need them at all. It might be harder to initialize one in VB, but if you choose a language based on this, something is wrong with your decision factors :P
Meta-Knight
+1  A: 

We've recently had the same issue. We actually just code in both, depending on what the original project was started in. It's surprisingly easy to switch back and forth, especially with Visual Studio (it always "reminds" me when I start typing "bool myvar..." that I'm doing something wrong if I'm in a .vb file).

Our priority goes like this:

  • Use an existing language if we already have code for this project/customer
  • Use the language that the customer prefers, if they care
  • Use C# otherwise (this is only because there are way more examples out there in C# when you're trying to find a code snippet to get you through some problem quickly)
Scott Whitlock