Advertisment

.NET on Linux

author-image
PCQ Bureau
New Update

.NET from Microsoft that has a fast growing community of developers. Yes, it’s strange to have a MS technology article in a Linux story; however it is important to realize that MS has an advantage in the number of deployed desktops around the world by a large margin. And ignoring these desktops may not be a very wise decision for any development house. 

Advertisment

So how does one target both Windows and Linux platforms at minimum cost? One of the first choices is of course the much hyped Java. As you know, you can use Java for developing and running applications on all platforms. However, there are a few significant disadvantages to this approach. The first is that your developers require to know Java, the language itself. Reusing their existing knowledge is not possible, if they do not know Java. The second is more important — Java has had problems on the performance and scalability fronts. In fact an internal memo from Sun Microsystems, leaked on the Web in the middle of Feb 2003, revealed that Sun themselves do not trust or recommend Java for mission critical systems — especially on their Solaris servers!!!

Anjuta

Anjuta is a

versatile IDE (Lead developer is an Indian) for C and C++,

written for GTK/GNOME. Anjuta is a fully customizable

integrated editor, with features like automatic syntax

highlighting, automated code formatting, text zooming, code

auto-completion, automatic indentation and indentation

guides. 



Anjuta provides the facility of opening each file in either
paged mode or windowed mode and has a powerful and interactive

source-level debugger with interactive execution and

breakpoints/signals/watches/stack manipulation. It also

supports other languages like Java, Perl and Pascal but doesn’t

provide the Project Management facilities for them. Currently

the team is working on immediate features like Interactive

Help System, Source code version management system (CVS) and

increased speed to help the programmer throughout the life

cycle of the project. 

What is the solution you ask? Well, .NET does offer you an alternative for this. Create an application that runs on Windows and run on Linux or vice-versa. The .NET framework from Microsoft provides a runtime layer that abstracts calls to the lower layers. Developers can also use the language of their choice — C++, Visual Basic or the new C#. C# is a C-like fully object-oriented language, much like Java, but with more features. 

Advertisment

Mono is the runtime engine for Linux - called the CLI (short for Common Language Infrastructure). There are two main parts of the .NET Framework — the Common Language Runtime (CLR) and the Base Class Libraries. Both these together provide the infrastructure that allows you to start creating .NET applications.

Mono is installed by default if you choose the Workstation install type. There is no GUI IDE for development as yet.

However, you can easily use this from the command line once your program is created. As an example, let us quickly create a .NET program. What better example than the standard “Hello World” program.

Advertisment

Type the following in your favorite text editor and save it as “HelloWorld.cs”.

Imports System.Console

Private void Main()



{


WriteLine(“Hello World”);


}

Advertisment

Now at the command line, enter the following command:

msc HelloWorld.cs

The Mono compiler — msc — is the one that compiles the source file into an executable format. When the compile is over, you will end up with a file called HelloWorld.exe. To run the file, give the following command:

Advertisment

mono HelloWorld.exe



This will show you the text “Hello World” and exit. This is of course a very simple program. But the power of mono comes now. Simply copy this EXE over to a Windows machine where the .NET Framework is installed (the EXE will not work on a machine without this). Simply double-click the file or run it from the Command Prompt to see the same output as that on the Linux box. 

You can do the reverse as well — create a file in C# or VB.NET in Windows, compile it and copy it to Linux and run it to see it work. Mono currently supports only compilation of programs written in C#, but can run console based EXEs written in any language. 

For graphical apps that run on Linux, there are new class libraries called GTK# and Qt# that let you create GUI Linux apps using .NET for Gnome and

KDE respectively. An add-on to mono also lets you create ASP.NET applications that are served through Apache if you wish (this is still in the preliminary stages).

Mono is a great way to start working on .NET — to learn and to experiment. 

Vinod Unny

Advertisment