Why C# is better than Java, response 2

by Charles Miller on January 26, 2003

Responding to Andy Oliver's Why C# is better than Java, part two. 6-10

  1. Structs In C#, a struct is a not-quite-object that lives on the stack and can't do inheritance. I assume structs get passed by value too? Hello, serious bug pattern. This adds a great deal of “When is an object not an object? When it's value type that can't be extended!” complexity, which isn't worth the pretty trivial gain.

  2. Substitution Parameters java.text.MessageFormat has existed since the 1.0 days.
  3. #define For the example given, look up Java's compilation. For other uses of #define, the preprocessor is a hack. There's generally a more elegant solution staring you in the face.
  4. Verbatim Strings These are nice syntactic sugar. Notice how the only things that pass the test of really being advantages of C# over Java are “nice syntactic sugar”? If you really cared, you could hack verbatim strings into the Jikes compiler in an hour or two.
  5. Foreach Evil syntactic sugar. Foreach is a lame, feeble excuse for not having blocks/closures. It embarrasses me that Java is planning on copying this mistake.

Previously: Why C# is better than Java, response 1

Next: Mailing-list Stupidity of the Year