Thursday, July 30, 2009

Mono for .Net on Mac

I am a .Net developer and with the new Mac, Mono has been inviting me for a long time now. With my baby's (long!) nap for an hour provided me with the opportunity to try out Mono and blog about it!

Why Mono?
1. A .Net developer since I learn to code - you know how addicted you can get to VS :)
2. A new Mac enthusiast

Steps to start trying out Mono
1. Get the installable from the go-mono site.
2. Run the installer. Mono installs under /Library/Frameworks/Mono.Framework
3. Here comes the famous 'Hello World'!!

using System;
public class Hello
static public void Main()
Console.WriteLine("Hello World, Here I come");
Note: For those of us .Net developers that hadn't worked in a shell terminal for a long time now, here are some of the notes to freshen up your memory!
  1. 1. vi filename - opens the vi editor with the filename
  2. 2. to save the file - :w
  3. 3. to quit the editor - :q
  4. 4. obviously, to save and quit - :wq (although, you would have figured it by now!)
4. Compile the code with - 'gmacs hello.cs'
5. Execute the code with - 'mono hello.exe'

There you go! Your first C# program on a Mac! Though simple, doesn't it thrill you?

Bang! Bang!! - The first time I compile the program - I got the error,
"`System.Console' does not contain a definition for `Writeline'". It took a full thirty seconds to spot the reason for the error - It should have been WriteLine!! Darn, VS has us fully spoiled!

Wednesday, July 29, 2009

Is C++ really dead?

Is it?? Read this discussion group thread

Inline Vs. Code Behind

StackOverflow has this discussion on some code being inline in the aspx page versus it getting into the code behind file.

Well, it made me start thinking. Thinking about it, I used to hate code getting into aspx pages with my colleagues. It led into code getting scattered and ended up losing the control of the code. Somehow, code behind makes it look more natural.

However, in case of a gridview - some people get more code into code behind

<asp:Literal ID="litExample" runat="server"

OnDataBinding="litExample_DataBinding" />

protected void litExample_DataBinding(object sender, System.EventArgs e)


Literal lit = (Literal)(sender);

lit.Text = string.Format("{1} - {2}",




There will be no performance difference on either type of the code. It's more to do with the best practices and to improve the readability of the code.

In this case, I like to keep the code in the aspx page as the code here is more declarative and design oriented.

    Text='<%# Eval("ExampleField").ToString() %>' />