Mad, Beautiful Ideas
Foolish Language Decisions

I’ve been blogging quite a bit lately about C#, .NET, and Mono. And by large, I love the technology. ASP.NET was never that interesting, it feels pretty restrictive to guys like me who know HTML fairly well, but the rest of .NET is a solid technology that performs far better than alternative VMs at this time. With the DLR, it even does dynamic languages, cleanly providing the features of parrot but combining it with non-dynamic code in an interesting symbiosis.

I even really like C#. It’s a language with features resembling the advanced features of C++, with the few nice features that came out of Java. The new features added in C# 2.0 and 3.0 make the language even better, though they do show that Paul Graham was right when he said that as languages advance, they become more like Lisp. Lambda expressions, Delegates…it won’t be too much longer before we get an eval command in C#. Won’t that be an interesting day?

Still, despite the improvements, there are a few things about C# that just don’t make sense.

First, the switch-case statement. Unlike C/C++, case statements do not explicitly fall through to the next case. They must either break or goto another case label. However, they are required to one or the other. The break, which could easily be implicit under the rules of the grammar was specifically made explicit. The argument seems to be that they didn’t want to give C/C++ programmers the wrong idea when they were reading C# code. I think that the average programmer is clever enough to remember such a trivial (and logical) change between two languages with minimal confusion. Break certainly shouldn’t be disallowed, but there doesn’t seem to be any good syntactic reason to require it.

For the second, C# 3.0 now supports the ‘static’ keyword on classes, which is used to imply that all the methods for the given class is static. Why then, do I still need to declare each method as static? Clearly, by declaring the class static, I’ve already declared my clear intent that every member of that class be static as well. It’s a waste of time to require that I consequently declare every last member of the class as static as well. Just stupid.

Overall, C# is a really good language. It’s not the most powerful language out there (Perl has that by miles, and of course Lisp, but I don’t use it regularly), but it’s good. These few nagging things really are little more than that, nags. Still, there is no good reason why these syntactic artifacts have persisted into this language, and specifically it’s third revision.