Jul 31


Arguing “Which programming language is better?” is like debating “Which religion is better?”  You will never find an answer because people have different needs, they judge with different criteria, and in the end, the debaters just end up getting pissed off at each other.  That’s why you’ll frequently see developers label the programming language debate as a “religious war.”

For me in my current job, C# is my language of choice.  But I’ve also worked with Java, PHP, C++, C, RGB II and even assembler.  In general, I feel it’s better to select the right programming language for the job, rather than force the job to use my current favorite language.

That said, Java fan Brian M. Clapper has written an interesting article claiming that the Java language “depresses me lately.  It’s being left in the dust by other languages.  Worse, though, for Java enthusiasts: Java has fallen behind C#.”

According to Clapper, here are some features that C# now has that Java does not:




  • Lambdas, which are way better than anonymous inner classes.  (C# has anonymous inner classes, too.)
  • Delegates.  You can kind of do this in Java, but it’s not as clean.
  • Operator overloading.  This feature can be abused, but it is still occasionally useful, especially in libraries and DSLs.
  • Properties.  No need to write getters and setters.  Everything looks like a direct field access, even if it isn’t.
  • Yield co-routine capability.  This is a powerful and highly useful capability, especially for lazy iterators.
  • Extension methods.  They permit you to “extend” existing classes.
  • Null coalescing operator that provides a simple syntax for dereferencing a reference and supplying a default if the reference is null.
  • LINQ.

The responses to his article have been amusing:

“Dude thanks!  Your article was the tipping point of me having to choose from Java or .NET.  I am going with C# now.” Um, that’s all it took, one blog article?

“So what.  This is not an arms race to fatten up the language with as many features as possible.  Simplicity is a good thing.” So let me get this straight:  If my product has more features than yours, I have a better product.  But if my product has fewer features, then it’s more simple.  Talk about rationalization!

Debating “Which programming language is better?” is like banging your head against a brick wall.  I hope you brought some aspirin.

C# Is Now a Better Language Than Java

Popularity: 2% [?]

Related posts:

  1. Most Popular Programming Languages
  2. Microsoft Vault: Safe Version of C Programming Language
  3. Google Releases “Simple” Programming Language
  4. Groovy: Obscure Programming Language of the Month
  5. Small Basic: Programming Should be Fun


14 Responses to “Is C# Now Better Than Java?”

  1. dirk bunglethorpe Says:

    Who cares. I’m a C# man myself but I guess it all comes down to what skills your shop has and what’s appropriate for the task at hand. c#/.NET and Java/EE are both valid options

  2. Cyril Gupta Says:

    Well I’ve worked with C# for a long time and never with Java (though I learnt it in the olden days). So maybe I don’t have a good frame of reference, but I love C#.

    However it seems now that I will be working on Java next year to target the mobile smartphone market.

    I hope java catches up with C#.

  3. talishte Says:

    One word multiplataform…

  4. Developer Dude Says:

    I have not delved into C# much, but I have read about some of the advantages, including those features such as properties and delegates. From what I understand there is ongoing work to add these to Java.

    Maybe C#, as a language, is better than Java, but I am not going to switch to C# for a few nicer features. There are issues outside of the language features, such as the bigger picture of available standard APIs, third party libs and most of all, the ability to execute on a much, much, much wider range of platforms – not to mention the total lack of lock-in to Microsoft. Those attributes of the Java world are why I doubt I will ever do any serious sustained development in C# (and yes, Microsoft is within spitting distance of where I work).

  5. Erik Says:

    Although I’m also a C# guy, you can’t ignore the progress of Java descendants such as Scala.
    The comparison you are doing is on C#, which in itself is a third generation. It’s like comparing C against Java (just the opposite).

    Anyhow, again, personally I’m more comfortable in C#, I love the syntax, it’s both productive and fun for me.
    Nevertheless, I do think that Java offsprings such as Scala are very serious languages, which are more fitting for large enterprise solutions, thus if you are doing a comparison, you should include them in the argument.

    Cheers,
    Erik

  6. Mats Says:

    I program in both Java and C# depending on the project. Although C# now has a few features I would like Java to have I still understand this person:

    “So what. This is not an arms race to fatten up the language with as many features as possible. Simplicity is a good thing.”

    More features does not necessarily mean a better language. More features also mean you suddenly have more ways to get the same job done. By having a simple language it becomes easy to learn and it is easier to adopt the “right” way of using the language.

    That said, I agree that Java is missing a few nice features. Like lambdas or perhaps LINQ. I care, however, much more for robust and full-featured SDKs with few bugs. A good SDK would save me days compared to minutes by having an extra language feature.

  7. Timothy Perrett Says:

    I think there is usually some disparity between what people think when talk about “Java”. Some are talking purely about language whilst others see “Java” as the multi-platform runtime environment. Regarding the language, yes, your probably right – it is falling behind C#; however, Java is still used by more programmers in more countries than C#. Furthermore, the JVM is shifting – Java is no longer the first choice language for development on the JVM… languages like Scala and Clojure are way ahead of the Microsoft curve and yet they still have toll-free access to every single java lib ever written: this is hugely powerful.

    A recent study conducted by Dubochet et al concluded that the human eye spends the same amount of time understanding each language token irrespective of the programming language itself – seeing as C# has a similar level of verbosity as Java can we not conclude that they have similar levels of developer productivity? Ultimately this is what matters to business and enabling them to leverage their existing infrastructure investments (counting dynamic languages like Ruby and Python out)

  8. Murat Says:

    Linq???? haha may be you can go and check hibernate. So far linq is just clones the hibernate features. However if you want the full functionality an stability there is the .net port hibernate.net.
    You can’t be serious on things you mention java lacking. I don’t think the features java has and .net hasn’t would not fit in this page. want some??
    -jpa
    -ejbs
    -ide like eclipse
    -vendors, which cause many options of web, application, process and portal servers.
    -unix runtime (may be you know very few windows prod servers exist in big enterprises)
    - compability (c# webservices are not full compatible with nonnative clients, do you really think world is only consist of .net)
    -open source libraries (need something in java, well probably already written a perfect framework)
    -open source runtime
    -mobile support (if you consider wm as mobile, wonder how many people use wm devices)
    you know what i am bored with typing just nevermind yeah java sucks . net rulez

  9. Tim Says:

    LINQ isn’t just LINQ to SQL. It allows you to query any collection that implements IEnumerable. That includes object collections, XML, Active DIrectory, Twitter, Amazon DB etc. etc. There are loads of providers that allow you to query just about anything and if it doesn’t already exist you can create one yourself.
    JPA, EJBs, Eclipse, etc that you mention have absolutely *nothing* to do with the C#/Java language. They are all part of the framework/platform.

  10. Erik Says:

    Murat and Tim (not Timothy), you’ve just proven how charged this subject is..

    Although amusing, this reveals the issue at hand: c#’ers don’t know about Java capabilities and vice versa.
    There’s only cranky prejudice going around.

    Oh, and ridiculous personal remarks as well of course :D

  11. cindy Says:

    Both have its pros and cons.

    I’d like to introduce a tool here: CSharpJavaMerger. It’s an open source tool that allows you to write a set of code that can be used by both C# and Java.

    http://www.kevingao.net/csharp-java-conversion

    Thanks.

  12. vishal Says:

    Though C# has added new features, but it is almost derived from java.
    So, while developing c#, they had many languages to comapare with, like java, c++, etc. So they had chance to remove wrong things from previous languages(if any). But still java has number of unique features and still its in developement phase, so I guess java is not better……………
    IT’S THE BEST I EVER SEEN :)

  13. BK Says:

    Great blog post. I was considering writing a similar one, but this about sums up everything I was gonna say.

    Looking at the latest proposal for lambda functions (excuse me, Closures) in Java 7, it seems like the java folks are bending over backward to do the same thing as C#, but not look too much like C#. As a result, java syntax is getting clunkier.

  14. uberVU - social comments Says:

    Social comments and analytics for this post…

    This post was mentioned on Twitter by DevTopics: Is C# Now Better Than Java? http://bit.ly/eddEl...

Leave a Reply