Blog Indiana 2008

It’s official… I like C# better than VB.NET

Yes, it is true, I’ve switched to the dark side. The last bastions of VB.NET have fallen.

After a conversation with a pair of developers I work with, I have finally been convinced that C# is a better syntax than VB.NET. That’s saying something, considering I used to believe I liked my languages verbose. You know, like COBOL. There were three things in the C-based syntax of the language that bothered me:

  • Case sensitivity
  • Curly braces
  • Semicolons

Like me, one developer was a former VB programmer now a fan of C#. The other was more of an open source proponent, but extremely knowledgeable about programming theory and history. A discussion with these two and some time actually developing in C# helped me understand the power of the language and the benefits over VB.NET syntax. I would still like to point out that the IDE in Visual Studio could use a few more features to truly make C# programming outstanding. I guess Resharper will have to fill the gap.

Case sensitivity

For the longest time, I could not come up with a decent reason for a case sensitive language. In VB.NET’s case-insensitive world, the IDE can auto correct your tYpInG mistakes very easily. It isn’t as easy to do in a case-sensitive language, because the IDE will not know “var” verses “Var” verses “VAR” when all three are in use. I have found case-sensitivity to make sense in naming variables, especially in the post Hungarian Notation world. I can declare a variable and name it the same as the class on which it is based. For example:

Customer customer = new Customer();

I don’t have to spend any time coming up with a different variable name. It actually requires less thinking. Less thinking is good.

Curly Braces

My previous experience with C-based languages was in college, circa 1994. Back then, there were no fancy IDEs, we coded in a text editor and we liked it that way!

Ok, I didn’t.

Formatting a document was a giant pain, but I had to do it to my curly braces straight. With VB’s If.. End If structure, I could read where the end of a statement was without tracing back and forth. Admittedly, Visual Studio can be thanked for fixing a lot of this issue in C#. It will auto-format a document for you and highlights bracket pairs. A number of other IDEs have done this for c-based languages as well.

What I hadn’t realized was how symbology makes it easier to understand the code. By using curly braces and other short constructs that are not words, C-based languages become easier to understand. My mind spends less time translating the code when I read it because the braces fade into the background. I can focus on the important things instead - the actual code.

It actually requires less thinking, and less thinking is good.

Semicolons

This one is more of a religious debate than anything else. I used to prefer not having to end statements with a semi-colon, choosing instead to use a line delimiter for continuation. That worked out fine and dandy until I needed to reformat a line - it involved moving the delimiters. In C# I hit enter and I’m done.

You know… less thinking.

Posted on November 29, 2006 in .NET, Software Development.    

6 Comments

  1. Jeremy said:

    Great next thing you’ll tell me that you have come around to using StarTeam and Crystal Reports for all your C# development.

    I’ll admit though I cringe now when I have to work or read VB code, the only really beef I ever had with C# is that the Visual Studio IDE sucks, but as you pointed out Resharper fixes those problems.

  2. ^Lestat said:

    … 3 Words; php

    =P

  3. Dan said:

    Alas, your training is almost complete, apprentice Sith Lord(TM). But, you still have not truly come to the dark side for you are not yet a Java(TM) programmer. You have a taken a significant step, yes. In time, you will really come to love Python, which requires no braces at ALL and is based on indention which makes it REALLY easy to read.

    (Sorry, that response was obligatory, eh?)

    Another nice thing about braces, btw, is that, if you put them underneath the first line, it will line up with the last brace (most people don’t because K&R didn’t and if the bearded ones did not do it then it is bad and I am stupid and should bow to all things root [Administrator for you M$ guys]).

    See the difference:

    for (i = 0 ; i

  4. Dan said:

    Ooooh, I was rudely cut! Plus, I indented with spaces, which wouldn’t have worked with HTML. Well, you get the idea.

  5. Dan said:

    Hey SQL Server man,
    use text instead of varchar,
    daylight come and me want to go code!

    DAY-O!

  6. y0mbo said:

    Jeremy - no, Team foundation is the closest I’ll have to get. I miss subversion.

    Dan - this blog runs on Wordpress == mySQL. Can’t help it if its crappy, that’s what you get for open source PHP stuff.

(Comments are moderated.)