Friday, August 22, 2008

C# Whining Again

C# Whining Again

One of the virtues of Java is that it was a clean sheet of paper. While there are some obvious similarities in keywords and syntax to C, they weren't slaves to it. C++, because it had as its goal to be upward compatible with existing C code, suffers a bit by comparison.

C# doesn't have that need for upward compatibility from C or C++, and that's generally a good thing. But I don't think that one should break upward compatibility without a good reason. In C, and C++:

int *x, y;

means a pointer to an integer x, and an integer y. One of them is a pointer, one is an integer. C# decided that:

int* x, y;

means that both x and y are pointers to an integer. This is a significant difference, one that will almost certainly cause a lot of developers who have moved from C and C++ to make mistakes. Now, C# discourages the use of pointers--they are mostly present for getting access to pre-.NET interfaces--but therefore all the more reason why they should have stuck with the C/C++ declaration syntax.

No comments:

Post a Comment