While writing this C# compiler, I've had a chance to get familiar with not just the general C# language, but also the hundreds of little decisions that went into it (little things like overload resolution, attribute subtleties, or subtle improvements in the switch statement). I'm continually amazed at how these all interlock, enhancing each other, to make such an airtight container. I've also had to work with a lot of Java code once again, while doing this and another project. It was a bit of a surprise, not totally bad for sure, just umm... Maybe like the way old girlfriends can scrunch up their faces while smiling when meeting me again, 15 years later. Anyway, it got me thinking about the whole C# vs Java language debate.
When people compare two technologies, they all two often don't compare the technologies. C# and Java are just one example, OS's are another, SWF and SVG are yet another. Not to digress here, I'll stick with the two languages - but the key word here is 'languages', not lifestyle choices.
C# is a better language. I don't think there is any argument here, in spite of all the arguments about this. While Java may certainly be a better choice, that doesn't make it a better language. Lets go through some of the common arguments one by one.
1) Java is cross platform and C# isn't. I'm not going to dispute it, that is a pretty valid point. Now while certainly there is nothing stopping C# from running elsewhere (after all I'm making it run in swf's), and Mono BSD etc etc, in reality C# is pretty closely tied to Microsoft, and Java isn't tied to any OS. BUT. This has zero to do with a language. This has a LOT to do with what language you will choose for your project, no question. However, this is comparing the Java platform with the .Net platform, C# doesn't enter the picture.
2) Java is more widely deployed than .Net. No doubt. Not sure how that makes debugging easier.
3) Microsoft ripped off Java and now claim it as their own. Hmm, I've always had trouble with that kind of logic. Everything is built on what came before, including Java, including C#, its called progress. Sour grapes do not a valid point maketh. As Java improves, they will be looking closely at C# (unless they are idiots). I know Microsoft PR tilts the other way, saying C# is more like managed C++ than Java (which Java is too) - while there is truth to this, I bet they knew what Java was ; ). Yet, it is not exactly like Java in a lot of ways. And in these ways it is better.
Oh, and everyone knows that stealing Anders Hejlsberg was way more important than anything they stole from Java ; ).
4) Unsafe code ha ha. Well, here we get into the purpose of the whole environment - Java is meant to be safe always and platform agnostic, C# is meant to be able to (optionally) interact with its environment. While C# can be 'geared down' to be safe, and while Java isn't always 100% platform independent, both are tuned about right to facilitate or prevent interaction with the underlying machine.
5) Java is open, C# isn't. Well, you hear this a lot, but in fact for this one, it just isn't the case. You hear this a lot about swf from the svg crowd too -- which isn't correct either. You even hear this sometimes from Mac people about the PCs or .Net, which is very bizarre. Linux or BSD absolutely, but Macs? Weren't those 1984 commercials filmed inside the company?
I think number five can be boiled down to this: "Microsoft is popular. Popular is common. I'm special. I'm not common. Must boycott the man." The nutshell version is, "I don't like Microsoft". Ok, this is totally a valid way for a person to think, honestly no problem. I feel the very same way (emotionally not logically) about many other things, and it causes me to avoid them. However, it is important to separate these emotions from the pro's and con's of named constants or type indexers if we hope to move forward, or even just appear intelligent.
6) What about all the existing code for Java. What about the .Net framework. What about multiple language interaction, what about Eclipse or Tomcat, or Jakarta, or Jini, or Swing, or BulletFart etc etc. These are all valid points about the environment languages are used in, just not about the languages. Unrelated, but I'm not sure why computer people, and especially Java/Unix people, can't just name things for what they are. I guess everyone needs a little cuteness in their life, but why not name it 'XML Parser' and carry around a little pink kitty purse?
7) You can do anything in Java that you can do in C#. While that isn't very specific, in general that is right. There is the counter argument that even in an assembly language anything is possible, so language improvement is really important. While this is also true, it is pretty disingenuous to bring up in a Java vs C# debate. Programming is often a bit easier or 'safer' in C#, but not so dramatically that switching would be a 'slam dunk' proposition - even from J# to C#. The usual coder preferences, learning curves, project goals etc must be factored in, as always. When talking language though, it does come down to how you do things, so just 'being able' to do something doesn't mean much - you have to look at whether things like enums or properties make life better or worse.
8) Java 3.763 will kick C# 2.015's lilly white ass. This could be, I hope so even, as a programmer (from either side) that would only be a good thing. I'm sure they aren't sitting on their hands at Sun or IBM. There is lots of room for improvement in both (generics for one). Regardless of which will be 'best' in ten more years, but I'm certain both will be better. Of course this is also a different debate, but a good one.
Don't agree? No problem, but then you have to explain why it is better not to have enums, structs, indexers, properties, params, attributes, operator overloads, explicit virtual methods, ref, out, aliases, multiple classes per file, foreach, IDisposable/using, is, as, jagged arrays,verbatim @"strings", and preprocessor directives. Yeah, I'm sure I missed some, and I'm sure there a few the other way, but that is the jist.
End of major combat. Mission Accomplished!
posted on Saturday, May 01, 2004 7:17 AM