How Random Babbling Becomes Corporate Policy (t3knomanser) wrote,
How Random Babbling Becomes Corporate Policy
t3knomanser

VB vs. C#

Wow. Okay, so I come from the C/C++/Java school of languages. Visual Basic has always felt amateurish to me, especially old-school VB. The more modern version, VB.NET, has lots lots of that feeling- it's a truly Object Oriented language now, but it still uses big clunky keywords.

For example, VB.NET code might look something like this:
Public Class Circle
  Inherits Shape

  Private _Radius as Double;

  Public Property Radius() as Double
    Get
      Return _Radius;
    End Get
    Set (value as Double)
      _Radius = value;
    End Set
  End Property
End Class


Big, spelled out keywords. The original language was designed to be easy for non-programmers, so lots of spelled out words. The same thing, in C#, is generally more preferable to a programmer:
public class Circle : Shape
{
  private double _radius;

  public double Radius {
    get { return _radius; }
    set { _radius = value; }
  }
}


Way more concise, very trim. Thats the sort of thing programmers generally prefer. It's not hard to learn a syntax, regardless of how cryptic it is (inconsistency makes it very hard, however). Since I do most of my work in VB.NET, since that's what people want their classes in, that's what I know the best. C# has always been something I've been meaning to pick up more about, but never have. Until today.

Today, I discovered that VB.NET has things C# lacks. In fact, despite the chunkiness of the keywords (which are usually auto-completed for you anyway), there are several very prominent things VB.NET has that C# lacks.

The first is the ability to have multiple indexed properties. Maybe there is a trick to doing this in C#, but I can't find it. If I want to have a property that represents a list, I've gotta implement a property against "this". For the non-programmers, suffice to say, it's kinda annoying. To be fair, I'm spoiled- most languages don't have the same simple property syntax that C# and VB.NET share, but it's annoying to have to do things the "old fashioned way" in order to make them work.

Secondly, in VB.NET, interfaces are not tied to method names. For the non-programmers- an "interface" is a contract. I promise to expose methods to meet the contract. In VB.NET, the stuff my class has doesn't need to have the same method names as the contract requires- it can map between them. This is great, because I can add interfaces to a class without having to worry about naming conflicts. C# does it the Java way, where names matter.

Thirdly, setting up event handlers, while somewhat more concise in C# is cryptic. Why the hell do I use the "+=" operator for adding those?
Tags: c#, programming, vb.net
Subscribe

  • Strange Things People Say About Me (to my face)

    Recently, I've been at the center of a trend. That trend is complete strangers asking me "Are you ____?" A quick summary. For example: Are you…

  • Writer's Block: If I could find my way

    -10,000 years, at minimum. Tomorrow is always better than today, especially when you can't fact-check.

  • Bob Morlang

    When I was working at Tri-Mount, we had these camp trucks. They were army surplus, and while they could take a beating, they only sort of worked. And…

  • Post a new comment

    Error

    Comments allowed for friends only

    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded 

  • 6 comments