top | item 734487

C# is now a better language than Java

152 points| fogus | 16 years ago |brizzled.clapper.org | reply

133 comments

order
[+] smakz|16 years ago|reply
I guess I'll be the lone dissenting opinion and actually favor Java over C#.

Java has an extensive library of open source software, which makes it, as they say, more of a platform then a language. From hadoop, to tomcat, to jetty, to hibernate, to spring, to c3p0 (and many, many, many more), you have all the tools you'll ever need to do 95% of the coding work.

I definitely get the love around here for dynamically typed languages, but I've never been sufficiently motivated to switch to ruby. The whole philosophy of ruby, "convention over configuration" is applicable to ANY language, including Java. Java's EJB spec was monstrous and XML config file infested, but I've gone through many projects in Java without a single XML config file and following the philosophy of convention over configuration, and it's been great.

As to .NET, I would never use it. Never want to get in the business of paying for licenses, not just .NET, but it ties you to Windows server boxes and Windows development boxes.

[+] joechung|16 years ago|reply
The article made a point of distinguishing the comparison between Java and C# as languages, not between Java and .NET as platforms.
[+] rfreytag|16 years ago|reply
As regards your last sentence, MS licensing does definitely limit your ability to scale out (over multiple servers, see http://www.codinghorror.com/blog/archives/001279.html). Mono might just save MS from losing the server mindshare entirely if it can talk itself into letting go of the license more than even the community "promise."

I have been pleasantly surprised to find C#/.NET is quite good. Please do force MS' hand by supporting the alternatives. The more good alternatives there are to .NET including improvements to Java, Scala or what have you, the more likely MS will do the smart long-term thing and loosen its licensing restrictions.

(please do say why you might disagree - I'm genuinely curious)

[+] nollidge|16 years ago|reply
Not sure why you brought it up, but convention-over-configuration is characteristic of Rails, not Ruby.
[+] fogus|16 years ago|reply
It's fashionable to say that Java is painful to use, and there is truth to the statement. However, when I started with it I had come off of a few years of C++ and loved that it reduced my pain exponentially. Like the new lover's quirky laugh, the 'nuances' of Java became annoying. It almost seemed as if with Java there is a threshold of productivity that the language itself imposes. I have since moved on to Scala/Clojure and again feel renewed. Maybe that is the natural progression of programming languages?
[+] icey|16 years ago|reply
I see C# as a linear improvement on Java. In my eyes, it looks like this:

C++ --> Java --> C#

[+] mahmud|16 years ago|reply
The SLW in me thinks: "Don't choose a language for its features, choose a language for its feature building capabilities".

It reminds me of people who buy stackable shelves and drawers to store their crap and make some room. Sometime later, they buy vacuum-sealable bags to store things that they bought after they made some space. As time passes, they start digging for a new basement and add another floor as an attic to store more things.

Java vs C# programming sounds a lot like two hoarders of the kind described above, except one has enough room behind his La-Z Boy to recline to 120 degrees, while the other only gets to 100.

[+] jrockway|16 years ago|reply
Indeed. Java and C# are some of the least flexible programming languages around. The problem, though, is that people like being told what to do. They don't want to wonder if they are implementing something correctly, they want to know that they are "following best practice". They don't want to invent their own features, they want to read a cool blog post about something "the experts" came up with and then try using that in their application.

This produces horrible code, of course, but since it sort of works and nobody knows any better, it's the norm. (Most programmers don't know programming. Why they want to be a programmer is beyond me, but it happens.)

The people that have a deep understanding of programming and know what they want to do and how to do it are not using Java or C#.

[+] messel|16 years ago|reply
where's the purist that lives outside on a hammock?
[+] DanielStraight|16 years ago|reply
Java is painful after experiencing .NET. I'm not sure this is really news though.
[+] habs|16 years ago|reply
I wouldn't describe it as painful myself. But, I would agree with sentiment. Having spent 3+yrs working with Java and then moving to C# (2yrs+ dev) has been a pleasant experience. C# is great language with features like delegates, Indexers, Pointers and Unsafe Code (executed in an unsafe context) and constraints on type parameters.

In contrast, I hate the msdn documentation for C# and still have a soft spot for java documentation.And yes, C# v Java is not the same as JVM v CLR

[+] bradgessler|16 years ago|reply
I should point out the obvious that C# was designed after Java was in the wild for some time; thus, Microsoft got to learn from the mistakes Java made when designing the language.
[+] sbt|16 years ago|reply
Exactly. This is not news. C# has always been a step ahead of Java. They're both enterprise languages, good for large teams. But C# has always offered comparable features to Java as well as more higher level features. Add to this, albeit a subjective opinion, that VS is a superior IDE to Eclipse.
[+] chaostheory|16 years ago|reply
Nothing new here. I've been working with both for years and I agree.

There is one thing that Java still has though, that I somehow doubt C# will have due to culture. Java has way more free or open source libraries. Yes, C# open source has gotten a little better over the years, but it's still not even close (it doesn't help that historically MS has been antagonistic towards open source even within its own products). What does this mean? With C# I have to keep re-inventing a ton of wheels, as opposed to Java where there are already thousands of existing well made ones for me to just grab and use.

[+] Caligula|16 years ago|reply
I was a c# dev a year ago and whenever I looked for open source packages to address some requirement, I would always end up at codeproject. It always tended to be poor quality, never updated, etc.. Java has so much more but maybe things have changed over the last year.
[+] voidpointer|16 years ago|reply
So if the JVM beats CLR but C# beats Java, why isn't there a C# compiler for the JVM?

I suspect that all language features of C# should be expressible in Java bytecode, but I have not thought about the details yet. If you know of anything in C# that would be unimplementable in terms of Java bytecode it would be interesting to hear about that.

[+] rcoder|16 years ago|reply
Java bytecode is Turing-complete, so there's nothing explicitly preventing you from implementing many of the advanced features of C# atop the JVM. As the OP stated, alternate languages running on the JVM (such as Scala) already do this.

The problem is simply that most Java shops use only the officially-blessed Java language. Because Sun has always forced "certified" implementations of the language and platform to conform to their standard, there has been little room for innovation in the source syntax and bytecode format since the release of the first JDK in 1996. In the meantime, programming languages (and the programmers who use them) have moved forward, and Java has failed to keep up.

[+] leadnose|16 years ago|reply
My guess is that C# supports stuff that has no direct and fast implementation on the JVM. IIRC C# has unsigned primitive types, stack allocated objects etc. which JVM doesn't have.
[+] jwhitlark|16 years ago|reply
These days I tend to think of Java as the new assembler; I need to read/understand it, occasionally write it, but I do most of my work in clojure and python, (or scala, whatever your preference)
[+] solutionyogi|16 years ago|reply
That's the problem with the article. Author concluded that JVM is better than CLR without giving any details. As I wrote in my other comment, .NET platform implements various features in CLR and in the language (in this case C#), to make C# a superior language. I challenge anyone to come up with examples which shows that JVM is better than CLR.
[+] icey|16 years ago|reply
I know it's doable in the other direction (http://www.ikvm.net/).

My assumption is that there's no real incentive to create such a beast though. Most people who like C# don't care enough about the JVM to want to deal with that kind of effort.

[+] kashif|16 years ago|reply
Yes C# is an improvement over Java. But, that isnt saying much with the plethora of cutting edge languages available today.

I still prefer Java, because C# is limited to the Windows environment,Mono isn't much help yet, and that is a huge limitation for me. Especially because Windows is not conducive to any serious systems programming - its ugly.

Another reason in favour of Java is the better open-source eco-system, more libraries and much more mature stuff.

C# has had the benefit that all new products/techs have - it leapfrogged.

[+] francoisdevlin|16 years ago|reply
Excellent writeup, and he nails the fact that C# vs. Java is not the same as CLR vs. JVM.
[+] solutionyogi|16 years ago|reply
Interesting. I don't think it's right to discount the CLR and focus on the language whereas the fact is that C# can not do certain things without support from CLR. [In fact, for each C# feature, I like to know whether it's a compiler trick or CLR feature.]

The biggest example I can think of is 'generics'. Java 'generics' are implemented using the compiler and JVM has no clue about them whereas CLR actually understands them and you get full reflection support for generic classes. Read this detailed article on Generics in Java vs C#:

http://www.jprl.com/Blog/archive/development/2007/Aug-31.htm...

I also like the utility of AppDomains supported by CLR.

Overall, I love .NET platform precisely because how all the modules (CLR, languages) are integrated with each other to give you a powerful tool set.

Other than JVM being portable, I don't know of a single case where JVM is superior to CLR. [Performance wise there is not a measurable difference between the two.]

[+] jwilliams|16 years ago|reply
Indeed - but there is the language, the VM and the class library. He separates the VM - but lumps the class library and language together (or at least, doesn't explicitly distinguish this).
[+] rbanffy|16 years ago|reply
You know... C# may be less painful than Java, but, still, it took me 8 years to go through learning C++ after I had learned OOP with Smalltalk and done some programming with Actor (kind of Smalltalk with an ALGOL-ish flavor). I closed my first book on C++ seconds after I saw the overloaded binary shift operator being used to output text.

I see my early contact with Smalltalk made me picky and spoiled. Today, it makes not much difference if it's C#, Java or C++, they are all painful well beyond my pain tolerance.

It's like smashing one's toes with hammers of different sizes - I am pretty sure even a small hammer is painful enough.

[+] StrawberryFrog|16 years ago|reply
What do you mean, now ?

annotations (though C# calls them "attributes")

he means "Java added attributes, which C# had from day 1, but called them "annotations""

C# has many of the same features as Java ... generics

Again, C# had this first, and still does it better since the bytecode is aware of them.

[+] adharmad|16 years ago|reply
Java being more widely deployed has to worry about source and binary compatibilities between all the supported versions and thus for them, changing the bytecode would have been a painful decision.

As opposed to that C# did not have to worry about these things due to their limited deploy base and could freely change the language and/or the VM without worrying about backward compatibility.

That does not mean java is a better language than C# - its just that when Sun woke up and started adding features to the language, it was not easy.

[+] subwindow|16 years ago|reply
He's just now realizing that Java is painful to use? Even PHP had me dreading the tiny bits of Java work I had to do when I last touched it in 2005.
[+] ilitirit|16 years ago|reply
Language wise C# was than Java from day 1, but the C# toolset and build model are why I prefer C# over Java.

I have never had to spend ages trying track down a "class not found" error in C#. Nor have I had to deal with version clashes between libraries. And I might be biased because I develop mainly on Windows, but I think Visual Studio is a better IDE than Netbeans, Eclipse, IntelliJ or JDeveloper.

[+] kashif|16 years ago|reply
Really Visual studio is better than Intellij/Eclipse?!?

I can tell that you havent done enough programming in the Java world. Have you ever tried any serious refactoring or bothered analyzing your code. I didnt think so, you would have realized why visual studio sucks..

BTW, I program in both C# and Java all the time. Actually, I do about 70% C# and 30% Java. So your claims are crap.

[+] messel|16 years ago|reply
My preference is definitely visual studio over netbeans/eclipse simply due to response time and the ease of installation.
[+] geebee|16 years ago|reply
A good article, but I think the last line is the most revealing...

"compared to C# and Scala, it (Java) is almost painful to use..."

I think most of the Java community realizes incremental improvements to Java are at the point of severely diminishing returns, and Scala seems to be the next phase (I've heard people jokingly refer to Scala as Java 1.9... of course, this really isn't accurate, but it does capture what's going on in the Java world right now).

So in the future, I'm going to be a lot more interested in hearing how Ruby and especally Scala stack up vs C#...

[+] zmimon|16 years ago|reply
It's sad, but this isn't really an interesting argument any more these days. Even as a staunch java supporter, I wouldn't try to argue Java is in and of itself as good as C#. I'm more interested in how the 2nd generation JVM languages (Scala, Groovy, etc) compare with C# or the other options on .NET, and on the pros and cons of the whole platform and ecosystem.

For my money, no matter how good C# is, I'm not willing to be tied to an environment where the only full, modern implementation is tied to a single platform.

[+] adharmad|16 years ago|reply
A thing that I have wondered about: Although Java and C# are similar languages with very similar libraries and features, Java has migrated towards being used for server side and middleware programming. C# however has not gone in this direction even on Windows platforms. What is the reason? Wouldn't it be easy to write the equivalent of Tomcat, JBoss, EJB's etc. in pure C#?

It is surprising that some of the apache projects have .NET equivalents (lucene, log4j, ant) but some others dont........

[+] vetinari|16 years ago|reply
Windows shops are vary of writing functionality, that might one day compete with Microsoft. Writing net Tomcat/JBoss could clash with IIS and future frameworks. Something like this happened with nant/msbuild and nunit/mstest. Commercial companies find it difficult to justify development of tools with high risk of being obsolete soon (something competing with MS product does not stand a chance in most Windows shops). Apache projects do not care about this risk.
[+] tumult|16 years ago|reply
C# is awesome because in a situation where you are using C#, there's a good chance you could use F# instead.
[+] ramoq|16 years ago|reply
I've always preferred Java to several languages (could be JVM influenced). I would still rather hack up an idea using Java vs C# or many other languages.
[+] umjames|16 years ago|reply
What are the other languages that you prefer Java over?
[+] angstrom|16 years ago|reply
I could tell the tipping point when I did a recent search for jobs. Even NYC which is still heavily Java is shifting to C#/WPF for client front ends.
[+] icefox|16 years ago|reply
And on the backend?
[+] tybris|16 years ago|reply
The problem with language features is that people will actually use them. Much better for maintenance to have consistent code. Except for inner-classes, you always know what to expect when opening a Java file. Java's not as elegant as Eiffel or some of the functional languages, but its simplicity has value.

(No, I program mostly in C#)

[+] mgrouchy|16 years ago|reply
I am not sure if I feel it is better, but I do like them both quite a bit.

Sometimes I just feel like C# is just a little bit more pliable in a lot of ways compared to Java, just a little easier to make it do what you want it to do.

[+] kashif|16 years ago|reply
Windows usually undoes that benefit really fast...