Follow this link for a table of contents.
Follow this link for a version of this page with improved navigation for graphical browsers.

The head of a GNU is the logo of the GNU project  DotGNU DotGNU logo

DotGNU Portable.NET

The goal of DotGNU Portable.NET is to build a suite of Free Software tools to compile and execute applications for the Common Language Infrastructure (CLI), which is often referred to as ".NET".

The initial target platform was GNU/Linux, but DotGNU Portable.NET has been known to work under Windows, NetBSD, FreeBSD, Solaris, and MacOS X, amongst others. It also runs on a variety of CPUs including x86, PPC, ARM, Sparc, s390, Alpha, ia-64, and PARISC.

Focus on Compatibility

DotGNU Portable.NET is focused on compatibility with the ECMA-334 and ECMA-335 specifications for C# and CLI, and with Microsoft's commercial CLI implementation. Our main goal is to make it easy to write portable application programs which work well both on DotGNU Portable.NET and on Microsoft's .NET platform.

In addition, we want to make sure that many application programs which were written for Microsoft's .NET platform (with no consideration for portability) will work well with DotGNU on many operating systems.

Installing

DotGNU Portable.NET can be installed either from a binary package or from source code (recommended).

Once you have installed DotGNU Portable.NET, you may want to install DGEE. Also, check out the demo and sample programs.

Runtime engine

The runtime engine in DotGNU Portable.NET, called "ilrun", is used to interpret programs in the Common Intermediate Language (CIL) bytecode format, described in the ECMA-335 specifications.

Because interpreting CIL bytecode directly is quite inefficient, we take a different approach. We first convert the CIL bytecode into a simpler instruction set for what we call the Converted Virtual Machine (CVM). The simpler CVM instructions are then executed using a high-performance interpreter. A description of the CVM instruction set can be found here.

The CVM approach gives us many of the benefits of a Just-In-Time compiler (JIT), in that the opcodes can be tailored to handle system differences (e.g. 32-bit vs 64-bit CPU's). At the same time, the engine's source code is highly portable to new platforms.

As another optimization on some CPU's (currently x86 and ARM), we further translate CVM opcodes into native machine code for direct execution. This gives an additional performance improvement with only a small coding effort required.

We will eventually write a full JIT for DotGNU Portable.NET, but we are currently focused on completeness and stability.

See the file "pnet/engine/HACKING" in the source code for further information on the structure of the runtime engine.

The license

The 'ilrun' runtime engine is made available under the terms of the GNU General Public License (GPL), the 'pnetlib' class library under the terms of the GPL with a "linking exception" which allows you to link application programs with pnetlib regardless of what license has been chosen for your application program. In other words, the "linking exception" causes the GPL to only extend to the C# library's API boundaries and then stop there.

Compiler

The DotGNU Portable.NET compiler, cscc, is a modular compiler system with good support for the C# and C programming languages. Work on support for some other languages (Java and VB.NET) has been started. The C# front-end implements the ECMA C# Language Specification ECMA-334. The C language front-end implements ANSI C.

Implementing additional languages is aided significantly by the innovative "Tree Compiler Compiler" (treecc) program, which uses aspect-oriented programming techniques to manage the complexity of compiler construction. See the treecc documentation for more information on this tool.

The compiler is designed to support bytecode generation for multiple bytecode systems. The current bytecode back-end supports the Common Language Infrastructure (CLI) defined byECMA C# Language Specification ECMA-335. Other back-ends to support the Java Virtual Machine (JVM) and the Perl 6 Parrot engine are in progress. (Note however that the JVM lacks sufficient instructions to run C code, so cscc will never be able to compile C to the JVM.)

System.Windows.Forms

WinForms screenshot - click to enlargeAn advantage of our implementation of System.Windows.Forms is that we don't try to wrap up third party widget sets like Gtk, Qt, Wine, etc. Instead, we provide a basic drawing layer and then render the controls ourselves. The approach is similar to Java Swing, in that all controls are implemented in pure C#.

This approach should allow us to emulate the Windows visual appearance and behavior more closely and portably than other approaches because we don't need to work around the quirks in foreign toolkits. Our implementation has been known to run on x86, PPC, and ARM based GNU/Linux systems, as well as Mac OS X. See the DotGNU Web site for current screenshots.

The DotGNU Portable.NET Forms implementation is structured into three layers, which are found in the source directories System.Drawing, System.Drawing/Toolkit, and System.Windows.Forms.

System.Drawing provides the basic drawing functionality, emulating the Windows GDI layer as faithfully as possible. When drawing to a control, use the definitions in System.Drawing.Graphics.

System.Drawing/Toolkit defines an interface to primitive drawing toolkits. Toolkits provide simple line/text/etc drawing (IToolkitGraphics), plus a simple window mechanism (IToolkitWindow).

There may be multiple toolkits in the system, each providing drawing functionality in a different manner. The current toolkits include System.Drawing.Xsharp, which wraps around the DotGNU Portable.NET Xsharp library; and System.Drawing.Win32, which wraps up the native Win32 API under Windows.

System.Windows.Forms builds upon the primitive drawing and window facilities from System.Drawing and System.Drawing/Toolkit to implement the various controls, forms, dialogs, etc, that are defined by the Forms API.

The file "pnetlib/System.Windows.Forms/HACKING" in the source code contains more information on developing for our implementation of System.Windows.Forms.

We are looking for volunteers to help us finish the System.Windows.Forms implementation, and are offering cash prizes. See the competition page for more details.

Further information

For further information on DotGNU Portable.NET, please refer to the FAQ of the Portable.Net development project. "Latest Changes" information with information on source code packages released by the project is available here.


Verbatim copying and distribution of this entire article are permitted in any medium or format, provided this notice is preserved.

This page is maintained by Norbert Bollow <nb@SoftwareEconomics.biz> with support from the DotGNU Developers mailing list.