One comment from my recent post was big enough to handle separately…
I’ll second the break statement. Why is it really necessary? Haven’t you guys got enough feedback to acknowledge that wasn’t the brightest move? You say it is there to please the C++ developers, because they are your main target.
- The C++ developers thought they were smart. You just stated they aren’t, as you don’t believe they can adjust to the new rules.
- You insult all the other programmers, as they are not the target. At least not more than a minor target.
- Finally, you insult everyone not on the C# team, as you think you are smarter than us. You could just have made the break statement optional.
When we were designing the language, we decided we wanted to do something about the fall-through behavior of C++. In my years of writing C and C++ code, I had come across several cases where the behavior was troublesome. I believe that experience was widely shared among the language designers.
So, we decided that any fallthrough would have to be explicit through a “goto” statement, which has the nice byproduct that cases can be re-ordered without a problem. We then had to decided whether “break” would be required, or whether it would be optional.
We decided to make it explicit to make it easier for developers who write in more than one language – which our research data shows to be a significant percentage of developers. The question is not whether we think C# developers are smart enough to learn the new rules – the question is whether we wanted to force developers to remember two different kinds of switch statements so that they could save 7 characters of typing. Changing the syntax there would have been a gratuitious change. With this behavior, while there are different rules for *writing* switch statements, reading them is the same across languages.
Having written code both in C# and C++ recently, I’m happy with the choice that we made. There are enough differences between the two languages that I’m happy not to have another to deal with.
I admit that we haven’t done the best job at explaining our language rationale. But now that you know the rationale behind this decision, do you think it was the right one?