Wednesday, 11 May 2011

Java versus .NET for web applications

Over the past few years I've come to believe that when building web applications in fairly small teams, .NET has the edge over Java. I have come to this conclusion having started my career using Java, then subsequently moved on to .NET, all the while working on web applications in small teams. Please understand that while I'm going to favour .NET here, I don't dislike either technology. I believe, as with all things in software development there are pros and cons and the choice should be justified by the people involved. 

To explain what frustrates me about building web applications with Java I'm going to run through some of the steps that would be required when starting a project from scratch with both Java and .NET. These steps are by no means complete, they are purely used to make a point.


Java

  1. Download and install an IDE (I am assuming that the IDE comes with the required Java run times). Which IDE to download? Eclipse is free and very good, but which version do you download? The full one with all the whizzy bits, or the simple one and try and only download the plugins you think you'll need separately? I always found the second option an nightmare. Or do you go with a paid version such as MyEclipse? Or do you avoid the Eclipse route and go for NetBeans, or maybe IntelliJ IDEA?
  2. Install a web server. When I last used Eclipse, a few years ago now, it didn't come with a built in web server, so you need to install one. Again, it's another decision. Apache? GlassFish? JBoss? 
  3. Configure the web server to work inside IDE. You want to be able to start the server and your web application at the click of a button, I always found configuring something like JBoss to work with Eclipse was a headache
  4. Configure IDE/web server to allow debugging. Another annoying task
  5. Choose a web framework. Major headache! There are a huge number of frameworks. Off the top of my head some of the options are Struts, Struts 2, Tapestry, Wicket, Spring, Stripes and Seam. Which one do you choose? Do you have experience of each framework? If not how do you make an informed decision?
  6. Install and configure web framework
  7. Identify, download, install and configure and additional components. For example I always used Sitemesh for implementing consistent site layouts in Java which is extremely important if your chosen framework does not support a layout mechanism

.NET

  1. Download and install an IDE. So, that'll be Visual Studio then. If you using .NET in a professional environment you'll have to pay, in which case you've got a fairly simple choice of package based on the functionality you want and the amount of money you're willing to spend. If you want to use the free version simply download the version that is relevant to the work you want do to. All versions come with a built in, pre configured web server which has debugging enabled. Plugins are available and useful, but my no means required
  2. Choose a web framework. I imagine most developers will choose either Forms or MVC. If you want testability and modularity then MVC is the way to go. If you're not bothered and want to knock up an application very quickly and easily Forms is fine
  3. Identify, download, install and configure and additional components. Out of the box .NET frameworks have a huge amount of functionality but there's always things that can be added

Boiling this down to a statement; Java gives you less functionality out of the box but provides you with more choice whereas .NET gives you more functionality out of the box but with less choice. It's the choice that I have a problem with. I used to think choice was great, but, after hours of research into Java frameworks and Java IDEs I've decided that too much choice is bad. I spent hours trying to figure out which IDE and framework was best before realising that the only way to find out is to use one for an extended period of time. Too much choice also dilutes the amount of support you get for each option. Take web frameworks for example; I've no idea how many people use .NET and how many people use Java, but say for example that 100 people use each technology. For .NET say that 50 people use Forms and 50 people use MVC. For Java, based on the number of frameworks I could think of off the top of my head (seven), say that about 14 people use each. I know these numbers are nonsense; my point is that because there is so much choice it's likely that far fewer people will be using any one Java web framework so the support for it will be significantly less. This is true in my experience. I often struggled to find help with problems using Struts and Struts 2. With ASP.NET I find there's rarely a problem that someone else hasn't already had and posted a solution for. 

To summarise my experience, I'd say that you can get up and running much more quickly with a .NET web project then you can with a Java web project. There's far more functionality out of the box when using .NET, far less configuration and considerably more support. So if you're happy to cough up the money and you're willing to using Microsoft products .NET is the way to go. 

No comments:

Post a comment