C# vs Java Part 2: Web Platforms

Written By John Sonmez

Web platforms are a critical thing to consider any any modern software development environment.

Back in the C++ days it wasn't about the platform at all.  It was all about knowing the intricacies of the language and pointer manipulation.

Modern programming languages are more about platforms and libraries than about the language themselves.  In both Java and C#, knowing what libraries are available and how to use them is a much more important factor than knowing all the features of the language.  A developer who understands the platforms and base class libraries will be able to accomplish more than a language expert, which is a stark contrast to how programming used to be.

One more note before I dive into the web platforms.  When I use the term platform here, what I am really referring to is the technology platform, base class libraries, and frameworks in general.

The Web

Java

For a long time Java has been dominating web platforms.  If you are doing basic Java web development you will most likely be using Java EE 5 or Java EE 6 which used to be called J2EE.  Aside from that commonality, the rest is a very big question mark.  Here is a list of 10 popular frameworks for developing a Java EE application.

Java web frameworks are huge, cross-cut many different concerns and the choices are daunting, but they are also very good.  For a long time while the .NET community was dragging and dropping controls onto a .aspx page, the Java community was building highly scalable model view controller (MVC) frameworks with distinct separation of concerns.

Most Java web application frameworks are built on top of the basic framework available in Java SE, specifically around applets and beans.  The current generation of the base Java SE specification has been greatly simplified to make writing enterprise web applications much easier than it was in the past.  This is the point where the platform and tooling overlap a little bit.  After selecting a web framework for developing in Java (which pretty much all of them are MVC of some sort), if you have a tool which supports developing on that framework (IDE plugin), development on that framework can be very easy.

Here is the difficulty… information overload.  If you took a look at that list of Java web frameworks, you can see there are many of them to chose from, and each one requires pretty extensive research to understand.  Some of them even combine, like Struts + Spring.  In fairness though,  part of the proliferation of frameworks is due to the age of the platform.  If you can wade through the choices, and settle on a framework, most of the good ones are really good and proven.

C#

ASP.NET for a long time was analogous with Web Forms.  Up until the release of ASP.NET MVC the only way to do C# web development was with ASP.NET Web Forms.  This technology was not bad.  It just did not have enough guidance.  It truly is amazing how easily you can drag and drop a control onto a page and have it automatically populated with data from your database and allow edits to that data all without writing a line of code.  Amazing, but in a ‘violate all separation of concerns, mix all my layers together,  look! I'm accessing the database directly from the UI' type of way.

Now don't get me wrong here.  I'm trying to be fair and honest, and Java took a beating in my previous post about languages; ASP.NET Web Forms is going to take one here.  With that said, yes, it is possible to write a good separation of concerns MVC style application using ASP.NET Web Forms.  And yes, it is possible to write an ASP.NET web forms application that properly uses business objects that use the data access layer and still bind the business objects or data transfer objects to the UI.  Before MVC was around, I built several ASP.NET applications which did exactly that.  The problem is that you really had to figure out creative ways to do it, and there wasn't any kind of real guidance.  I always felt like the platform was trying to push me into dragging and dropping, like a little devil sitting on my shoulder saying “but it is so much easier to just bind that control directly to the database.  Look, the wizard will do it for you.”

Fortunately that problem has been solved with the ASP.NET MVC platform.  It is very new and still needs some maturing, but it encourages good design practices that separate the concerns.  Under the covers it is still using the Web Forms view engine as a default, but that can be swapped out with any number of view engines which are starting to pop up.  There still is a bit of a complexity issue with ASP.NET MVC in my opinion, especially in regards to AJAX.  I know that some of this has been solved, but some people will find it very difficult to come from a platform where you could drag and drop a server control, have a wizard to set it's properties, and have the HTML automatically generated for you, to one where you have to hand code much of the HTML.  ASP.NET MVC uses HTML helper classes to help render the HTML for you, which is a good step, but I think it still has some room for improvement.

Microsoft has also done an excellent job of getting information out there about how to develop in ASP.NET MVC.  This is one of the areas where MVC shines.  When I go to search for how to develop on Swing or Struts there are some tutorials, but nothing like the volume of information that is out there and easily accessible about ASP.NET MVC.

Rich Internet Applications (RIAs)

Quick blurb on this topic.  .NET and Java both have competitors to Adobe Flex and Air in this space: Silverlight and JavaFX respectively.  There really isn't even a competition here between Silverlight and JavaFX.  JavaFX does not have a visual design and has some strange new language to learn which mixes layers of abstraction.  Silverlight gives you the full power of the .NET framework and uses a common design with Windows Presentation Foundation (WPF) through XAML.  I am not sure what Sun was thinking here.

Conclusion

It is very hard to compare the web platforms, without giving so many details about them.  I really haven't even gone into very much depth at all.  Java EE has a much larger web platform, but it is also more fractured.  ASP.NET is only split between two technologies, but the MVC platform is not very mature at this point (although it is growing and improving extremely fast.)  One consideration as a developer is specialization.  It is not possible to be an expert in every single web platform or framework.  If you going the Java route, you'd better pick carefully, because the nature of open source development leads to many dead projects.  A considerable investment in learning could be lost.  ASP.NET MVC is still a gamble at this point, but I think it is a good one, because Microsoft is devoting a large amount of resources to it and the adoption seems to be widespread.

To be continued…

I thought I was going to be able to cover more than the web in this post, but I didn't realize how much there is about the web platform.  Tomorrow we will look at C# vs Java when it comes to desktop development, and future sections will cover IO operations, databases and concurrency, and mobile.