I’m a C# fan. Its been on my list for a while to finally install mono on my Linux machine (running redhat 9).
Download
For the initial download, I picked up the following packages (I know, if I were 3 years younger I’d pick up the sources and compile them myself!)
Writing My First Application
OK – so lets see if I can’t create my first mono application. Shall it be “hello world”? Lets try something a little more original (but not much)…. Keep in mind that I don’t run X on my linux box. So I’m compiling this from the command line. In my first attempt, I tried to write C# by hand. But, as anyone who has used C# will tell you, the code pretty much writes itself. Turns out, even though I have written plenty of C#, I can’t write a program that compiles without help. OK, so instead I created the following code via Microsoft’s visual studio. Took about 2 minutes to write:
using System; namespace helloworld { /// /// Summary description for Class1. /// class Class1 { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { Console.WriteLine("does this work?"); DateTime start = DateTime.Now; for (int i=0; i
Compiling
Compiling turns out to be very easy, just use:
mcs mike.cs
Mono compiles the source and creates “mike.exe” for you. Its a little wierd to see “.exe” files on linux, but I can deal with that.
To run the compiled executable, you now type:
mono mike.exe
And viola, I can see that it takes about 187ms to count to 100million on my linux machine. (The linux machine is a 1.0GHz AMD Duron).
Comparing the same program on windows (without the debugger, of course) takes 140ms. My windows machine, however, is a 2.8GHz Pentium 4. Quite a bit faster.
So Mono looks very promising so far! The next step is to get the Mono IDE installed. Trying to write C# code without an IDE is just not a very fun experience. In order to that, I need to get X up and running again on this box.