Table of Contents

  1. Introduction to .NET
  2. Introduction to the Mono Project
  3. But... What About Licensing?
  4. Using Mono
  5. Applications Using Mono
  6. Programming with Mono
  7. Questions?
  8. References

Introduction to .NET

Convention goes that most Unix software has to be recompiled to move between architectures. Compilers generate code that runs on one processor, that typically depends on one flavor's libraries, and that is simply the way Unix software works. Java is a notable exception to this, but very little Java software exists that is tailored for a Unix environment. Most of it integrates poorly into a Linux environment, and there are no complete and free Java engines that run on Unix. Enter .NET.

.NET is a technology developed by Microsoft for their next-generation software development. It consists of a virtual machine specification coupled with a CLR (Common Language Runtime) execution engine, and it also includes a set of programming languages designed to operate in the CLR environment. Each of these languages can be compiled into this common form and executed on the same virtual machine.

In short, .NET is a bytecode technology, like Java, but with a twist: the virtual machine supports multiple languages. And, as of today, at least 40 languages are supported1. Objects defined in one language can be used in another, which allows different code modules to be written in different languages and still interoperate fully. The .NET architecture also includes an extensive set of classes for everything from XML handling to image manipulation to database interaction.

So, why do we want to use this on Linux and Unix? A major reason is interoperability: most future Windows software will be written in a .NET language and compiled to CLR form. If there is a free .NET engine for Linux, a lot of future Windows software will run on Linux unmodified.

Another major reason to adopt .NET is that the design makes sense. It is cross-platform, extensible, and can be used as a back-end for dozens of existing and popular programming languages. Suddenly, the process of recompiling for different architectures vanishes. Any .NET program runs on any system with the runtime engine.

Indeed, software is already being developed using these technologies on Linux.


Introduction to the Mono Project

A popular and growing implementation of .NET for Unix-like systems is Mono. The Mono Project is attempting to build a complete implementation of .NET, including support for Windows.Forms, one user interface "toolkit" used in Windows software developed under .NET. They released Mono 1.0 some time ago, and it is beginning to find some traction — distributions like Fedora have begun to include Mono and software developed for it.

Mono implements the full .NET stack, including the runtime libraries, the execution engine, and a C# compiler to build software using .NET2. It also includes several Unix-specific frameworks and libraries, such as Gtk#, a set of GTK+ bindings for .NET to allow developers to create GTK+ software using Mono. Qt#, a set of Qt bindings for .NET, is also available, as is Cocoa# for development of software for Mac OS X. As of this writing, the current version of Mono is 1.1.133.

Mono was founded by Miguel de Icaza, the creator of the GNOME Project, in 20014. It was developed into an open source project, and that project released Mono version 1.0 in 2004. The project was started at Ximian and then opened to the outside world.


But... What About Licensing?

The Mono implementation itself is licensed under a combination of licenses:

Unfortunately, that's not the end of the licensing considerations. The C# language and CLR specifications themselves are ECMA standards, making them free for all to use. Microsoft holds patents covering some .NET technologies, but it has offered a royalty-free license allowing their use. The complication lies here.

Because there is no guarantee that Microsoft may not change the licensing of the related patents in the future, some fear that by using .NET technologies in Linux and Unix, developers may be walking into a trap. If Microsoft does change the licensing terms in the future, there is a possibility that open source software developed using .NET may be hindered by the patents, destroying years of work and progress and causing projects to throw away large amounts of code. The jury is still out on whether this is a significant threat or not a real problem.


Using Mono

Running .NET applications with Mono is simple. Just type:

        mono myprogram.exe
      

(Yes... The dreaded ".exe" extension. Don't worry, you will survive!)

If you want a Linux system to know how to execute .exe files using Mono directly, you can use a feature called binfmt, which may be built as a module depending on your system configuration. The method to configure it varies by distribution, but instructions are available in the Running Mono Applications guide on the Mono website.

That's it! If the program is a CLI-based program, it will execute on the console. If it is graphical — provided you have X running and the right libraries are available — the program will appear on your screen.


Applications Using Mono

A number of open source .NET applications for the Linux and Unix platform have begun to appear as Mono has matured. Some of the most popular options are listed below. Note that some of these are Linux-specific, as they depend on certain kernel features and other functionality not found on the BSDs or other Unix systems. This is not a complete list; check out the Mono Software page for more choices!


Programming with Mono

For developers, Mono includes a C# compiler, .NET debugger, and other features and tools. The C# compiler is currently C# 1.0 feature-complete and is nearing full C# 2.0 language feature support5.

As mentioned above, Monodevelop is an IDE designed for developing applications using .NET in Mono. Of course, you may use any editor you like to edit C# programs and compile them using the C# compiler.

For those unfamiliar with C# and the .NET API, the language is very similar to Java, with syntax and structures that will appear very familiar. There are a few differences in language features (string is a primitive type instead of a class, for instance, and there is a bool primitive), a different class library structure, more complete namespace support, explicit getter and setter support, and some other items that a Java programmer will find slightly unfamiliar. Many of these features are helpful and improvements over what is available in Java; despite the concern by some that C# is "bad" because it was developed by Microsoft, it is a powerful and full-featured language that has learned from some of the mistakes of its predecessors.

More help with Mono development can be found on the Mono Project's Use page.


Conclusion

Mono is a powerful tool that brings a flexible framework to the Unix platform. Applications such as Beagle set a new standard for features and usability on the desktop, and they become increasingly portable as Mono (and .NET) matures.

The need for compiled, architecture-specific binaries will never go away. Many tasks that require cross-platform compatibility turn to the many scripting languages available to developers today, but sometimes an interpreted language doesn't offer the power or speed required. Mono and .NET fill another niche, and despite licensing concerns, their use is increasing around the community.

As mentioned before, the Fedora Project recently decided to bundle Mono with its distribution (over the objections of its sponsor, Red Hat). Some GNOME developers are pushing to develop next-generation software using Mono instead of shifting to other technologies.

Mono also opens the Unix platform to .NET programmers, trained on Windows, who may be interested in developing software for other operating systems. Some argue that this is bad, bit with the right developer resources and community effort, these programmers can learn to better use the platform instead of breaking the conventions that are in place. All in all, an influx of developers and users may be A Good Thing™, despite concerns.

Take a look at Mono and, if you're feeling adventurous, give it a try. If you are running Linux with an inotify-enabled kernel, check out Beagle, the current Mono poster child (and a very impressive and useful program). Enjoy!


Questions?







References

  1. Wikipedia: Common Language Runtime
  2. Mono Project: FAQ: General
  3. Mono Project: Mono 1.1.13 has been released
  4. Wikipedia: Mono Development Platform
  5. Mono Project: CSharp Compiler