It’s Amazing What Passes for a Language – C#

Csharp.jpg

OK, I'm old school, and as such, I'm not a big IDE user, but I recognize that they have a place in this world, and it saves a lot of people a lot of time. Just not me. Not most of the time. But when I'm coming into a new project, and it's already established in this IDE and a certain language, it's just plain silly to buck these established "standards".

But I have to say... C# is one of the oddest languages that I've ever seen. I believe it's written for people who have never seen a programming language before, and it's meant to be "easy" for them to understand what it's doing. Let's look at the setters and getters in C#, shall we?

  private string _farm;
 
  ...
 
  public string Farm {
      get {
          return _farm;
      }
      set {
          _farm = value;
      }
  }

where the first line is the definition of the instance variable, and the thing that looks like a method definition in Java or C++ or C is really a combination definition and meta-data for the getter and setter. The use of this code is simple:

  obj.Farm = "three";
 
  ...
 
  string l = obj.Farm;

Here the first call will end up calling the set 'method' in the Farm definition, and the second will call the get method. C# looks at the usage and then decides what method to call based on the naming conventions. I can see this, in theory, but it's so totally contrary to what you'd expect if you knew Java or C++.

In fact, in either of these two languages it's clear what:

  obj.cnt++;

means, but in C# is it calling the getter, doing the increment and calling the setter? It would appear it would have to. However, it's not clear from the language structure. Call me silly, but I like the language to infer as little as possible about the workings of the code for me. If I wanted that, I'd have written macros for preprocessing.

I have to use C#, so I will, but I can't imagine that I'm going to look at this anytime soon and see this as a good, descriptive, understandable, language. No time soon.