Mark Needham

Thoughts on Software Development

Java vs .NET: An Overview

with 5 comments

A couple of months ago my colleague Mark Thomas posted about working on a C# project after 10 years working in Java, and being someone who has worked on projects in both languages fairly consistently (3 Java projects, 2 .NET projects) over the last two years I thought it would be interesting to do a comparison between the two.

The standard ThoughtWorks joke is that you just need to remember to capitalise the first letter of method names in C# and then you’re good to go but I think there’s more to it than that.

The Language & Framework

There is really not much difference between the syntax of Java and C# and I’m not that interested in going into it it massive detail here. There are other websites which cover it in more detail.

Language features wise C# seems to be marginally ahead – the introduction of lambda expressions, implicitly typed local variables and extension methods in C# 3.0 is something not yet matched in Java.

From my experience C#/.NET has much better support for front end rich GUI applications (WinForms, WPF) while Java is probably better for back end work. When it comes to web applications Java probably holds a marginal edge although the soon to be production released ASP.NET MVC framework is a very nice piece of kit.

I have no data to justify saying that, merely thoughts based on experience, but from conversations with friends who work in investment banking I have learned that this is the way the two languages are used there as well.

Other language support

If you are looking for language support on the respective platforms beyond Java/C#, Java probably has a slight edge.

Groovy is a dynamic lanuage with a Java style syntax and should therefore be easier for Java developers to pick up. I’m not aware of a dynamic language with C# style syntax for .NET although Boo is an alternative which compiles to run on the Common Language Infrastructure.

If you need Ruby support Java has JRuby while .NET has IronRuby. JRuby is the more mature of the two options here. If Python is what you need then both contenders compete here too with Java’s offering of Jython and .NET’s IronPython.

Functional language wise .NET has a CTP release of F#, while Java has support for Scala.

Use of 3rd party APIs/Open Source Software

I’ve found that in the Java projects that I’ve worked on use significantly more open source software than the .NET ones. I’m yet to be convinced that this is necessarily a good thing although my Java colleagues are confident that it is.

To give an example, there are multiple different Java libraries for Xml parsing whereas in C# everyone just uses the default one that’s provided.

This provides the opportunity to learn new and better ways of doing things on the one hand, but the potential to spend serious amounts of time evaluating which tool to use instead of just getting on with it on the other.

From a Java perspective it certainly provides extra challenges in trying to get your applications integrated with the range of different application and web servers on the market. In .NET it would simply be a case of getting it to work on IIS – of course easier said than done!

IDEs

I think Java clearly leads in this area with IntelliJ out ahead of anything else I’ve ever worked with. Eclipse is a popular open source alternative but for me it is far less intuitive to use than IntelliJ.

Visual Studio only becomes usable once Resharper is installed but when that’s done it becomes better than eclipse if not quite as usable as IntelliJ. My colleague Pat Kua also listed some ideas to make it run even better. SharpDevelop is a free IDE for .NET development although I haven’t used it so I’m not sure how good it is.

Build and Deployment

Partly due to its better support of Ruby, Java has a much wider range of tools for working with the build.

In .NET NAnt is the only serious contender, and although msbuild is often used to handle the compiling of the code its verbosity of non intuitive approach means I can’t imagine recommending it for a whole build file.

Java wise we have Ant, Maven, a Groovy based wrapper around Ant called Gant, the Ruby based buildr and the dependency management tool Ivy.

Communities

From my experience the community around .NET is more accessible to your average developer than what I’ve noticed in the Java world.

The Alt.NET group is an initiative started last year by several of the leading lights in the .NET world and aims to make the world of .NET development a better and more productive place.

Java has the Java Community Process driving it forward from a community perspective and perhaps due to the lower reliance on the drag and drop tools which are encouraged by Microsoft tools, the standard of your average Java developer may in fact be higher.

When it comes to finding the answers to questions both are mainstream enough that this is fairly easy.

Overall

I’ve tried to cover some of the areas which I considered important when using these two approaches. I’m sure there are some comparisons I have missed out so it would be interesting to hear from others who have worked on both platforms.

This is all written from my knowledge (and a bit of research) so if I’ve missed anything please mention it in the comments.

*Updated*
The paragraph about ‘Other Language Support’ was updated to reflect Robin Clowers’ comments.

Written by Mark Needham

October 15th, 2008 at 12:09 am

Posted in .NET,Java

Tagged with , ,

  • http://robinclowers.blogspot.com Robin Clowers

    Hi Mark, I feel it is worth mentioning that LINQ (Language INtegrated Query) is a very powerful feature of C#. A single set of query methods can be used against in memory collections, xml and any other data source a provider has been written for. Most of the C# 3.0 features were added in support of LINQ.

    For open source .net, take a look at the Castle Project and Spring.net.

    You also mentioned that you are not aware of any dynamic languages for .NET, but of course IronPython and IronRuby are both dynamic…

    Cheers

  • Pingback: IT Blog

  • http://www.markhneedham.com Mark Needham

    You raise a good point! What I was trying to get across (admittedly not so clearly having re-read it!) is that I don’t know of a dynamic language with C# style syntax similar to the Java style syntax that Groovy provides.

    What you say about LINQ is also of course true => it’s a really good addition in my opinion. Hopefully we’ll start to see new features like this in Java soon.

    Cheers, Mark

  • http://www.flickr.com/photos/adsphoto Adam Scott

    Two things:

    1) While this isn’t a particularly useful question to ask, I’d be curious to know which kind of project you’d prefer to work on, given what you’ve stated?

    2) I’m surprised that you find IntelliJ more intuitive than Eclipse. Having come from using solely Eclipse for a very long time, and now only starting to use IntelliJ, I will agree that IntelliJ has a host of features that make it very attractive. Having said that I would also say that I actually find it very counter intuitive to use. For example, many of the shortcuts do not follow OS conventions, like CMD + W on a mac does not close a tab, it selects text. And CMD + Y deletes a line, rather than redoing an action.

  • http://wuetender-junger-mann.de felix

    @Mark
    One thing that is troublesome about C# is .NET and all the vendor lock-in stuff.
    Do you really want to have your servers run on windows. So deployment is a big issue..

    @Adam
    The CMD-Y is quite intuitive, as it was CTRL-Y on the PC, which was delete line in Turbo Pascal, which in turn stole a lot of shortcuts from the late WordStar…