Historically, the web development choice between the Microsoft platform and open source has been a fork in the road with many consequences. Choose Microsoft, and you generally use Visual Studio, Internet Information Server, ASP.NET, C# or Visual Basic, and SQL Server for the database manager. Choose open source, and you most likely target LAMP in one of its guises, the most common being Linux, Apache, MySQL and PHP, and work in Eclipse or almost anything other than Visual Studio.
Recently the boundaries have been blurring a little. Apache actually runs nicely on Windows, and I've used it happily to host a Subversion repository, while on the other side Microsoft has been making an effort to support PHP in IIS 7.0. But what about running ASP.NET on Linux, is that a silly idea?
I've been following the efforts of the Mono project in this area for some time, though it's been a while since I've tried it out. Mono was originally focused more on desktop than web applications, and I've used it mostly in that context. When laterooms.com tried Mono in early 2006 it quickly gave up, citing problems with Mono's Boehm garbage collector; see the developer's comments to my blog post at the time.
Still, that was three years ago. I had another look a couple of weeks ago, and I've been impressed. In particular, the ability to develop in Visual Studio and deploy to Linux is interesting. I'm working on a small project, and getting this working is remarkably simple. I used Visual Studio 2008, but set the project to target .NET Framework 2.0, as Mono lags behind Microsoft in implementing the latest .NET APIs, and using MySQL rather than SQL Server, since this is available on my Linux web server. Using MySQL with .NET is straightforward thanks to the official ADO.Net provider, which specifically supports Mono as well as Microsoft .NET.
On the web server, running Debian 5.0 Linux (Lenny), I installed the libapache2-mod-mono and mono-apache-server2 packages using Aptitude. Next, I configured Apache to use Mono on a particular web site, with a few lines of manual configuration, as explained here, and imported the MySQL database from the Windows development machine to the Linux web server.
Back in Visual Studio, I compiled the web site, uploaded it, and it worked first try. Performance is good as well.
I realise that a number of caveats apply. It's worth reading this page, the current Mono todo list, which notes some of the important areas where Mono is lacking and includes the comment:
Mono is known to be not as performant as the .NET Framework.
Note that Mono still uses the Boehm garbage collector, though an alternative is in development. Further, Mono does not implement the entire .NET Framework. Mono is a brave choice; Windows and IIS the sensible option for .NET applications.
It still seems to me significant that you can easily deploy to Linux and Apache using Mono. Not all applications are mission-critical, and not all applications need to scale as well as Laterooms.com. Mono has a number of attractions. First, it is open source, so in the event of problems you can always obtain and amend the source code. Second, running on Apache and Linux is a considerable saving in license costs. Third, you can get official developer support from Novell.
Why would you use C# and ASP.NET rather than PHP or Java? The main reason would be because you know and like the language, the platform, and/or the Visual Studio IDE. In an interesting report on the state of the computer book market, O'Reilly notes that C# is now the largest programming language for all book sales. Thanks to Mono, you can use C# but still deploy to an open source platform.
It also seems to me that Microsoft's official support for Moonlight, the Mono implementation of Silverlight, is important. Microsoft now needs Mono, in order to tick the cross-platform box and compete with Flash, giving more assurance to its long-term future.
Mono's growth over nearly a decade has been slow but steady. Perhaps now is the moment that it creeps into the mainstream.
Are you using Mono, for web or desktop development? I'd be interested in your comments.
Listed below are links to blogs that reference this entry: Bridging open source and .NET with Mono.
TrackBack URL for this entry: http://www.itjoblog.co.uk/blogadmin/mt-tb.cgi/81
Hello Tim,
We continue to use the Boehm GC in Mono, but much has changed on it since the LateRooms use of Mono. We now use Boehm's GC in precise mode and the GC itself has been upgraded, tuned and supports parallel marking (this is a compile time flag as of Mono 2.2, a default after that).
It is a shame that LateRooms did not work with us at the time as we could have used the help from someone running a large web site to profile the actual bottlenecks and the performance limitations that prevented Mono from running.
A year ago, we started a project with a large ASP.NET user that wants to use Mono, and we went through a couple of phases with it.
Their large application was brutal on the GC, but mostly due to our own bugs in our code: the server code paths had not been tuned for those workloads. With the help of this user we were able to pinpoint with real code what the problems were and fixed these issues.
With this complicated piece of software we originally were running about 60times slower than .NET on Windows. After we tuned Mono under real time loads being helped by this user giving us access to profile and time things we have matched Windows/.NET (on average: in some cases we are a few percent points slower, in some others a few percent points faster) but also we noticed that Linux/Apache/Mono were able to sustain more load during peak times than Windows did.
That being said, we have been very impressed with how well tuned the .NET runtime has been for so long in terms of their multi-threading support. We only were able to test this functionality with Mono once we were able to get our hands on real code, running on 8-way SMP machines with real users.
Boehm still plays a role in our performance limitations, and we are working on a replacement, but in real world scenarios we have found that the majority of the problems lied elsewhere.
As for users of Mono on server settings, a big driver for Mono deployments is Deki from Mindtouch.com. You can follow @Roebot on twitter to get a sense of the number of deployments they have. They are not strictly ASP.NET apps, they are DREAM on the server (Mono) with a PHP front-end.
Well I for one am very excited at how far Mono has come throughout the years. It used to be that if you wanted to code cross platform and be taken seriously by companies (as a contractor) you would have to go with Java. Now with Mono maturing, I can see a huge potential in shifting that point of view and letting us C# .NET developers skip Java and go for cross platform .NET goodness.
I would honestly rather target common denominators between Mono and .NET than have to learn Java from scratch and deal with runtime caveats as I go.
Hi Tim,
I have had good experiences with Mono so far and I am explicitly targeting Mono as a runtime for dashCommerce as I think the cross-platform win there is huge - especially for an open source e-commerce application. :)
In case you are interested and what to target the mono compiler through visual studio, I have a write up and some downloadable project files here:
http://chriscyvas.com/2009/02/16/getting-mono-and-visual-studio-to-play-nice-together/
Nice writeup and thanks for sharing. There are some nuggets in here for me to check out. :)
Chris