I’m chilling out listening to some Innoway and eating a DQ butterscotch Dilly Bar when I get this email…
Hold up, that’s not entirely true.
I’m actually hiding out from all the kids in the house (each of mine has a friend spending the night), and I just received an email from a reader of one of my books asking me which .NET language is better: C# or VB.NET. This topic comes up quite a bit, so I thought I’d answer it here in hopes that it helps cut through some of the misconceptions.
Here’s the basics of how a .NET application runs under the hood:
1. When you write a .NET application, you write in a some supported .NET language such as Visual Basic or C#, or even Cobol for .NET.
2. When you build your project, your source code is compiled into Intermediate Language, otherwise known as IL.
3. When you distribute your application, you distribute assemblies containing IL.
4. When a user runs your application, the just-in-time compiler interprets your IL code and turns it into machine code. This machine code is than run in the common run-time.
So, in the end, all .NET languages are treated the same. This, in theory, would tell us that all .NET languages are alike. This is actually untrue. The compiler used to compile the code of the language with which you’re familiar (C#, Visual Basic, etc.) into IL can have an impact on the final IL code. There are some differences (C# allows for handling unmanaged code and Visual Basic supports late binding, for example), but for 99.99% of the people out there, none of these differences should be enough to sway a person to use one language over the other.
Vanilla, chocolate, Visual Basic, or C#?
Think of Visual Basic and C# as flavors. What flavor do you like? In fact, Microsoft’s official position is that when deciding on a language, you should choose based primarily on what you already know and what you’re comfortable with. If you happen to require a feature not found in your chosen language, you could always isolate that section of code in an assembly written in the language necessary to get the job done. For example, Visual Basic supports late binding, so if you needed to perform late binding for a feature in your application, you could write that code in Visual Basic and compile a DLL that could then be called from C#.
Me personally, I’ve worked with both Visual Basic and C# and written books on both languages. I HATE curly braces, and I think semi-colons are about as valuable as flung monkey poo. I think Visual Basic is easier to read and less cumbersome, but here are plenty of people out there that think the opposite. Oh, and its my opinion that case-sensitivity in any programming language just blows (this is 2007 after all). Oooh Oooh Oooh – I also like the way Visual Basic handles forms over C#, saving us lots of tedious hours working on a class to manage an active forms collection. Of course, I have a Visual Basic background so I’m used to having it easier. A lot of C# guys come from a C++ background. They like things to be harder for them – to keep them in their comfort zone. ;)
OK, I’m teasing the C# guys a bit, but I do get tired of hearing about how “serious” developers choose C#. Heck, what we did at Tigerpaw Software with Visual Basic 6 is astounding. We have a large-scale application run by over 10,000 (now 35,000) users, and you couldn’t tell from our interface that it is a Visual Basic 6 application. Our Visual Basic .NET product is going to be a new evolution in software for us, and we’re having a blast working on it. In the end, however, the average customer doesn’t care if an application is developed in GWBASIC, Visual Basic, C#, or Assembly for that matter, as long as it looks good, runs good, and works well.
If you have a Visual Basic background you might consider using Visual Basic .NET. If you’re comfortable in C++, C# might be your best bet. If you’re trying to get a job in a specific industry or with a specific company, learn the language used by your target employer. If you’re going to be hiring additional developers, what does the local talent pool look like? If you’re going to raid employees from a competitor, you might consider using the language that those new programmers are used to. lol
So, the choice is up to you. I wrote Teach Yourself Visual Basic 2005 and Teach Yourself Visual C# 2005 for Sams Publishing. Both of these books are very similar, since both languages use the same tools, the same type system, the same debugger, etc. Read the first chapter of each book (links below) and do the examples yourself; you should be able to determine which language you prefer by comparing apples to apples.
Powered by Facebook Comments