Tuesday, April 14, 2009

Cross-platform .NET GUI development

Although both Microsoft and Sun are in business to make money and increase market share to make more money, it would seem that there is a fundamental philosophical difference between the two companies regarding software development. For reasons which should be fairly obvious to most software developers, Microsoft does not care much for Sun’s “write once, run anywhere” mantra and has designed .NET to run only under Windows.


But what if one wanted to write .NET applications that can run anywhere? Is it even possible?


As it turns out, there are a couple of open source projects which aim to make it possible. One of them is Mono. From their web site: "The Mono Project is an open development initiative sponsored by Novell to develop an open source, UNIX version of the Microsoft .NET development platform."


Mono cannot run WPF applications, but it can run Windows Forms (WinForms). In addition, Mono has it's own Linux-oriented Windowing layer called gtk# which has been ported to Windows. Also, there is wx.NET, a CLI wrapper for wxWidgets.


Mono can also be used to run ASP.NET applications from Apache on a Linux box.


Of course, just because you can do a thing doesn't mean you should. Should one bother trying to write cross-platform .NET? I would say it depends on why you want to do so and how you go about it.


If you’re out to prove how great Linux is, that’s probably not a good reason to write .NET for Linux unless you happen to work for one of Microsoft’s competitors.


If you have an existing .NET application that you want to run under Linux for some other reason, that might be a good reason to use Mono.


It is not uncommon for Java programmers to develop under Windows and then deploy an application to a Linux server. So, why not go the other way? If you just prefer to use Linux but have some need to develop for Window, that might be a good reason to use Mono.


If you want to use Apache to run ASP.NET applications without IIS, possibly under Linux, that might also be a good reason to use Mono. As of April, 2009 Apache has 45.95% of the server market compared to 29.27% for Microsoft IIS according to netcraft.com.


Unfortunately, as with any copy-cat technology, Mono will always be one or two steps behind the latest Microsoft innovations. I already mentioned that Mono cannot do WPF.


Personally, I would not recommend using gtk# (gtkSharp), because it is specific to Mono, and I would not recommend wx.NET because it is an obscure technology.


If you read my previous blogs you know that I don’t like the idea of using obscure technologies and would prefer to spend my time learning skills that are marketable. That’s because I’m a professional software developer. If you’re a hobby programmer, you can pretty much do whatever you want.


That leaves Windows Forms (or ASP.NET if you are writing a web application). However, as a software developer I want to be learning and using the latest technologies. So, that is one negative. I shouldn’t have to limit myself in order to achieve cross-platform compatibility.


Unfortunately, I found that installation of Mono and Monodevelop IDE (the Linux port of SharpDevelop) can be a real pain depending on what distribution of Linux you are using. The Mono and MonoDevelop projects directly support OpenSUSE, but not Ubuntu or Redhat Linux. I am sure that is because both Mono and OpenSUSE are sponsored by Novell. However, this seems like a mistake to me. I found it very difficult to install MonoDevelop on Ubuntu and ended up changing to OpenSUSE instead. However, some people may not have this option. This issue could certainly have a negative impact on the adoption of Mono. This is a glaring example of how Linux applications also do not adhere to Sun’s “write once, run anywhere” philosophy.


And speaking of “write once, run anywhere”, if you look on the discussion forums on the Mono project web site, you will see many complaints of .NET applications working differently under Mono than under the true Microsoft .NET. Not that this is a big surprise. Fortunately, the Mono project supplies a Migration Analyzer tool, but even it is not perfect. However, I am thinking that if you are doing new development targeted for Mono, it would be better to use MonoDevelop under Linux for all your development so you won’t run into a lot of surprises later down the road with minor incompatibilities.

No comments:

Post a Comment