Cognotive Distance

A discussion in this dot net rocks show explained why an experienced C++ devloper would chose to use VB.NET over C#. The two languages are of equivalent expressiveness but have slightly different biases. VB.NET is better for dealing with variants and default parameters while C# has unmanaged code support.

Kate’s argument was that C# was too close to C++ to make freely jumping between them difficult and error prone this made VB.NET a more natural choice. I have had similar experiences. Currently I am working in Delphi, SQL and C#.

I find that keeping the SQL in strict upper case allows me the seperation so that I don’t find myself adding “then” to the end of my if statements. This allows me to keep a Cognative Distance between the two languages. Since Delphi and C# have a suitable distance between them (begin end vs {} ) I generally don’t have a problem switching..

The major gotcha that I have between Delphi and C# is the calling of a method with an empty parameter list. In Delphi you can call foo; where C# requires foo();

C# reserves foo for referencing the method itself.

The other niggle that I have with C# is the casting syntax.

In Delphi if I wanted to cast a class to a specific descendant and then use a method exclusive to that type I would use:

TChild(aParent).ChildMethod;

C# would require:

((TChild)aParent).ChildMethod();

which has slighly too many brackets for my taste.
I know this was implemented for the C and Java developers but since one of the aims of C# was to correct the mistakes of the C and C++ world this could have been improved.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s