6

For me, developing for the Java ecosystem payed the bills for many years. However, for several years now, I have been working primarily in the .Net space. Initially, my transition into the .Net world consisted of writing and maintaining VB.Net code. VS provided almost all of the nice intellisense support I came to expect after years of working with the Eclipse/Java combo. Eventually my employer decided to do new development in C#. My initial impression of the intellisense support for C# was less than stellar. At times it seems as if VS has no background compiler for C#, but occasionally it does something smart, indicating there is some background processing there, but not quite enough to really boost productivity in meaningful ways. Is there any sane technical reason for this discrepancy regarding intellisense support between the two languages?

4
  • 2
    The only hiccups I've found are that C# is a case-sensitive language, so sometimes I don't trigger it properly. Can you post an example of what you mean?
    – Eric
    Jul 4, 2009 at 4:22
  • 2
    It's all about VB.NET has the background compilation from the beginning.
    – dr. evil
    Jul 4, 2009 at 20:50
  • 1
    C#'s Intellisense updates after a source code edit, even before a build/recompile; that's why I wondered whether the OP's machine is simply slow for some reason.
    – ChrisW
    Jul 5, 2009 at 1:25
  • I find the new title much clearer. Jul 6, 2009 at 13:48

1 Answer 1

14

There has been a gap between C# and VB for awhile now. VB generates a lot of code for you. For example, hitting enter after finishing an "If" statement will automatically add the "Then" at the end of that line if you left it off, and close it off with the "End If" portion. In C# it's up to you to add those starting and closing {} curly braces.

VB has had background compilation long before C#. In fact, that was one of the major appealing factors of using ReSharper, which provided such functionality. However, as of VS 2008 / .NET 3.5 SP1 that all changed. You can read Scott Gu's post about that here, but I'll paste the relevant part:

"The C# code editor now identifies and displays red squiggle errors for many semantic code issues that previously required an explicit compilation to identify. For example, if you try to declare and use an unknown type in the C# code-editor today you won't see a compile error until you do a build. Now with SP1 you'll see live red squiggle errors immediately (no explicit compile required)."

Using CodeRush or ReSharper definitely enhances the experience with the autocompletion of common statements which would make a VB developer feel like there has been a seamless transition.

That doesn't quite address technical concerns, but the development teams are different and didn't necessarily do the same thing. In other words, there's not likely to be a shared approach. This blog post excerpt, by a Technical Lead on the VB team, supports this:

“Background compilation” is the feature in VB that gives you a complete set of errors as you type. People who move back and forth between VB and C# notice this, but VB-only developers may not realize that other languages such as C# don’t always give you 100% accurate Intellisense and don’t always give you all of the errors that exist in your code. This is because their Intellisense engines are separate, scaled-down compilers that don’t do full compilation in the background. VB, on the other hand, compiles your entire project from start to finish as Visual Studio sits idle, allowing us to immediately populate the task list with completely accurate errors and allowing us to give you completely accurate Intellisense.

One final note is the recent Channel9 interview with the Group PM of the C#/VB/F# team, Luca Bolognese, where he emphasized how the languages are no longer going to stray off in different directions and will begin to share their similarities. So it looks like the future holds great things!

6
  • 1
    There is a small voice in some small, banal area of my brain thinking this is a bad idea. Why? These languages are not similar for pragmatic reasons. They should be allowed to evolve independently.
    – Todd Stout
    Jul 6, 2009 at 3:29
  • I must admit that I haven't read all of this answer yet, but the first paragraph doesn't seem entirely accurate. You mention what essentially sounds like a code snippet for an If statement in VB - C# also has snippets like this: Type "if" and hit tab to generate the entire block. There are plenty of other similar snippets as well. Jul 8, 2009 at 2:30
  • 1
    Sadly, I suspect this is the death knell for VB.Net. MS is relegating it to second/third-class status. I'm an old-school c/c++/java/c# (and unix guy) but I realized after working with VB.Net, that it is a damn fine language and has an undeserved crap rep among many in the programming community. I will miss it.
    – Todd Stout
    Jul 8, 2009 at 2:31
  • @Ryan: I'm familiar with code snippets, and they are useful, but as you stated you have to hit tab to generate them. My If Then example is not a snippet in that sense, but something the IDE does once you hit the right combination (no tab), just as the IDE reformats C# code after a closing brace/semicolon. VB handles that w/o me thinking, meanwhile in C# I'm more of a CTRL+K+D junkie. I imagine a VB dev going to C# quickly realizes how much VB did for them. Ex: the trivial code encapsulation between If Then/End If protects from unintended 1 line statements; absent C# {}s can spell debug trouble Jul 8, 2009 at 4:01
  • 1
    @Todd: I've worked with both but prefer C# overall. The negativity you mention, from my understanding, was from the VB6 days. I worked w/VB.NET on a few projects & I've gained some healthy respect for it coming into it with a clean slate (C/C++/C# background, no VB6). I really doubt it's going anywhere anytime soon, or that C# will inherit its features then MS will close the curtains on it. Recently VB got XML literals and C# 2.0 got yield. Useful features. I'd welcome some convergence with VB implementing yield rather than having to write my own state machine for an iterator block. Jul 8, 2009 at 5:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.