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

Share and Enjoy:
  • Twitter
  • Facebook
  • Reddit
  • LinkedIn
  • Digg
  • DotNetKicks
  • StumbleUpon
  • Slashdot
  • Technorati
  • Google Bookmarks
  • Print
  • email

Article published on July 31, 2009




20 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 😀

  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

  15. Slava Persion Says:

    It makes me very sad that Java doesn’t have unsigned primitives 🙁

  16. shweta Says:

    1st of all c# is derived from java….copied literallly all possible features n added new one…
    im a swftware engg studied both of them…
    even with respect 2 web technology .net coding is far more shorter than
    java but still .net is very much component based..
    n v r forgetting dat still for embedded house hold machines or cell phones
    java is widely used..n c# cant replace it.
    java was ny way not designed for web it was for d programming of machines with small ram and memories…

  17. kiranb Says:

    Hi,

    C is best as any low level codes or programs closely related to hardware are still written in C and also most Operating systems are preferred to be written in C itself….if you want to be a systems programmer then C is the best choice and if you aspire to be a web development or middle ware still not sure…probably Java or .Net.

    One more thing to your notice, JVM is itself written in c/c++. 🙂

  18. kiranb Says:

    As you know .. java they say it is machine independent. can you please answer me this question..if i suppose develop an OS will the java code compiled on another system executes in my OS. :).
    so this is the reason they designed JVM. They have hard coded the OS type in JVM and once my OS specification is named and defined in JVM then only the java code becomes portable to my OS.Sorry if i might have hurt or bothered some other developers.

  19. Murat Says:

    Kiranb you dont seem to know this topic well. First of all It does not matter what language the OS or the JVM is written. What matters is what it is compiled to. To run as OS you need to be compiled in pure machine code and you can also do that with Java if you want.
    Saying JVM is written in c/c++ is also not completely correct. Have you heard open jdk, did you check the code base or have you heard of embeded java devices, boards running Java code out of the box?

    Saying C is the best language is like saying tomatoes are the best food! It just depends, depends on what you are doing and what for. Because C is used to write OS does not mean it is the best. Java has been widely adapted than any other language but this also does not mean it is the best. To be a good software engineer you can never be a fanatic or you will lose your judging ability.
    Remeber you can only use tomatoes if it tastes good for that meal!

  20. JohnD Says:

    So tell me in this regards, which food do you think is best for you and do you still keep on consuming the same food today aswell. Well there is no best language that you can live with. It all depends upon the situation. This discussion is only like wasting time. I still believe that a good programmer never believes in a language.

Leave a Reply