I’ve been practicing the Bowling Game Kata in Eclipse the past few days, and this evening I did the kata in Visual Studio 2010 Beta 2. I’ve done a bit of C#/.NET 2.0 development in the past, 2006-2008, but I haven’t worked with it daily in over a year. In that time I’ve been working on projects that involve Java. (I think most people go the other direction, from Java to C#. But anyway.) I had got to the point with Eclipse where I could quickly create and refactor Java code, so switching to C#/Visual Studio was a challenge. For one thing, the syntax of the languages are similar but not exact. I can’t go into all of the differences, and others have already done that better than I could, but I’ll try to highlight some differences that I find interesting or that trip me up, mainly for my own benefit.
One difference that I found interesting (in a “why the hell is this different?” sort of way) is array declarations.
In Java, I was declaring an array like this:
private int rolls[] = new int[21];
The same array in C# has to be declared like this:
private int[] rolls = new int[21];
Huge difference, huh? I have no idea why the C# language designers made this different from Java; maybe if I did some more research I’d find the history behind that design decision. I found that Java allows arrays to be declared with either format, so maybe I should simply use the latter format all the time.
I know this is far from the biggest difference between the two languages, but this seems like a subtle difference that didn’t need to be a difference. And again, I haven’t done a lot of research into the issue.
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.