Comparing Web Development with Java and .Net

I was recently asked to comment on what the pros and cons were of Java compared to ColdFusion and ASP.Net when it comes to Web development. I guess the first thing to get straight with this question is what exactly constitutes 'Java' in a Web development sense.

The basics of the two technologies

The diagram below outlines the elements that comprise of Java and .Net Web development.

Both technologies are very similar as in essence Microsoft based .Net on many of Sun's original Java concepts and borrowed a lot of Java syntax when designing C#. Both utilise managed containers in which code is compiled and executed within. These containers are referred to as the JavaVM or CLR runtime in Java and .Net respectively. Both managed containers have the ability to execute code written in a number of languages, for example it is not uncommon to have a .Net application written in both VB.Net and C#. Whilst not as common the Java runtime is also beginning to support multiple languages such as Python and Ruby. Increased emphasis has come on this ability after the meteoric rise to fame of the Ruby on Rails Web development framework.

Looking at the diagram above you will notice that ColdFusion falls within the domain of Java. Whilst the language itself does not look very similar to Java this is just aesthetic, under the hood ColdFusion code is compiled into Java by the ColdFusion interpreter and then executed in the same manner as standard Java code. So any debate between whether to use ColdFusion or Java Server Pages (JSP) really boils down to what the developer is familiar with.

Industry Support

Java and .Net share extensive industry support and broad user bases. As shown by the O'Reilly analysis of reference book sales no single programming language has a clear lead when it comes to popularity.

.Net's greatest advantage is that being a Microsoft technology it is integrated within the Windows Server family of products and installed on the majority of corporate desktops. Microsoft also has a strong history of excellent developer tools which enables the relatively rapid development of .Net applications via the Visual Studio suite. Whilst Microsoft's .Net framework is proprietary code that only runs on Windows, the Mono project (sponsored by Novell) is successfully implementing the API's and CLR runtime standards in open source code capable of being deployed on a range of platforms such as Linux and OSX. However it must be noted at this stage Mono does not cover 100% of the .Net API's or support the .Net 2.0 standard, limiting its applicability as a production level .Net platform.

Java development whilst lead by Sun is also extensively supported by industry heavyweights such as IBM and Google and a range of smaller but no less important entities, the most famous of which being the Apache Software Foundation. Recently Sun announced they would be open sourcing core Java technologies under the GPL. A significant benefit of this move is that it will allow Java to be tightly integrated into Linux distributions, easing deployment burdens for IT administrators. Unlike the one size fits all approach favored by .Net, Java is broken into a range of different frameworks which can be combined together to generate a unique set of functionality. This design also enables third parties to develop languages like ColdFusion that allow developers to utilise the power of many J2EE technologies without the added complexity.

And the winner is...

There is no clear winner when it comes to comparing Java and .Net simply because they are both so powerful and similar in design. Here is a short list of positives they both share:

  • An excellent suite of development tools
  • Relatively fast once compiled
  • Large developer bases
  • Comprehensive reference materials
  • Widespread industry backing

Compared to .Net, Java has the following benefits:

  • Open source platform
  • A distributed development community
  • More deployment and architecture flexibility as it is platform neutral

On the other hand .Net has the following going for it:

  • Microsoft backed and integrated into Windows
  • Concise platform controlled by Microsoft
  • Easier for existing Windows developers to adopt (i.e. C++ and Visual Basic coders)

When it comes to the speed at which one can create applications it really comes down to the skill individual developer (after all, bad craftsmen blame their tools). But even with this in mind compared to more agile Web centric programming frameworks like Ruby on Rails and PHP, both Java and .Net are painfully slow to develop for.

So if you are after a concrete recommendation then here is my situation dependent advice that I have gained from programming experience:

  • If you want a platform neutral, highly scalable and robust framework choose Java.
  • If you will only ever run Microsoft products and have a set of Windows centric programmers on hand then .Net is the easiest route.
  • If it is coding speed and flexibility you are after then checkout Ruby on Rails.
  • If you want something that is simple to deploy, relatively agile and easy to learn then PHP is the way to go.