Roslyn, deux qui la tiennent...

Roslyn September CTP is out, despite rumors of it  being dead, and although there is no redist, it solves all the issues I had with type dependency (Mono's terrible API really does not help) and opens-up the road for VS.Net integration.

This is very exiting news for C#ylon!

using Roslyn.Compilers;
using Roslyn.Compilers.CSharp;

namespace RoslynTest
    class Program
        static void Main(string[] args)

            var comp = Compilation.Create("Test.dll"
                , syntaxTrees: new[] { CreateTree("Foo", "Bar"), CreateTree("Bar", "Foo") }
                , references: new[] { new MetadataFileReference("mscorlib.dll") }
                                   , options: new CompilationOptions(OutputKind.DynamicallyLinkedLibrary)

            EmitResult a = comp.Emit("Test.dll");

        private static SyntaxTree CreateTree(string a, string b)
            return SyntaxTree.Create(Syntax.CompilationUnit()
                                         .WithMembers(Syntax.List(CreateCoDep(a, b))));

        private static MemberDeclarationSyntax CreateCoDep(string typeName, string fieldName)
            return Syntax.ClassDeclaration(typeName)

Back to hacking  tonight!

Project of the week: Left-handed guitar

All this quest for a perfect keyboard layout made me realize that I have lost a lot of mobility in my left hand.

I had a series of pretty bad accidents when I was a kid that damaged my left hand, and I believe that coupled with old age, my left hand is getting weaker and weaker. Here's the list of mishaps:

-Left hand stuck in the emergency brake of my mother's car.
-Middle finger stuck in security door.
-Torus fracture of the cubital bone (x2)
-Wrist fracture (x1)
-RSI, stayed stuck for 3 weeks, never fully recovered (damned ants in my left hand)!

So, I picked-up my guitar to relieve stress after a particularly nasty time spent with ceylon and Irony (If I get my hand on the smartass who decided to add the \i and \I prefixes to identifiers....) I realized my ring and middle fingers were just inert.

So here's a fun experiment, I will restring my sg upside-down tonight, and have a go at it. I'll try to use GnR's Nightrain solo as my benchmark (I am never playing Are You Gonna Go My Way ever again...) and report when things improve!

Ceylon's cool features are too addictive for my own good

I have been playing around with Ceylon after hearing UnFromage singing its praises and it is very addictive.

In my mind there is no contest the C# language is much, much more streamlined and expressive than Java7


I am already wishing C# used some of Ceylon's cool features, namely union types.
Consider the following scenario where we use the template method pattern.
    public abstract class Handler<T>
        // do some stuff but don't let the implementor decide of the ordering of actions
        public void DoIt(T value)
            // we're handling the ordering here!
            //  Implementor only provides ways to start and complete
        protected abstract T Start(T value);
        protected abstract void Complete(T value);

Now,  suppose we want to provide a handler that does satisfy both intand double. We have to write two implementations, as C# doesn't do multiple inheritance. If Foo and Bar's implementation are similar we've got to break-down the handler in a third common class. Moar clutter. Don't like it.

Introducing Ceylon's union types!

A union type is defined as being any of the possible types in the union. The type system works its magic retrieves the correct value. Let's pretend our C# union also defines implicit conversion operators and let's take a ride to wonderland.

    public class NumberHandler:Handler<int|double> 
        protected override int|double  Start(int|double value)
            return Math.Pow(value,2);
        override  override void  Complete(int|double value)
            Console.Out.WriteLine("Got {0}",value);

The compiler has to do some magic casting behind the scenes for this to actually work

I'm spoiled already.

Go get hooked on Ceylon now!

I'm itching to see some of those features in the .Net framework...

Weekly project: Dev Dvorak

So I'm nearly touch-typing in QWERTY at a whooping 30WPM...

I realized something in the process. I HATE this layout as a developer, I spend most of my time with my pinky on punctuation.

Exit QWERTY, come-in Developer Dvorak : placing punctuation on the home row and stronger fingers.

Here's my current setup using the mighty Portable Keyboard Layout which works even when remoting / using RGS...

I might switch to Programmer's Dvorak which does not use any dead keys and also works on Macs but we will see...

Resharper lifesaver: Complete current statement

You've entered all your text, your cursor is in the middle of a 200chars long lambda and you can't be bothered to close all parenthesis, go to the end of line and add the last semicolumn?


You will thank me later. With bacon. And kisses.

Weekly Project

Fuck it I'm getting older by the minute, if I don't do stuff now I'll never do it.

Goal of the week: I can reach 74 WPM on The Hobbit Test and I'm a kind of keyboard anorak...But I have a terrible secret : I only use three fingers from each hand.

So, the goal of this week: learn to touch-type on qwerty using all fingers. See you next Friday!

3 steps to coder nirVIna

Step 1: Grab a good keyboard (Filco Majestouch 2, US layout, Cherry Browns for our tests)
Step 2: Install AutoHotKeys from
Step 3: Edit your Autohotkey.ahk file in "My Documents" and add these:

; CapsLock navigation
Suspend On


 Suspend Off
 SetCapsLockState On
CapsLock Up::
 Suspend On
 SetCapsLockState Off

You can now enjoy your capslock key switching between  qwerty and arrows on ijkl. Note that the indicator reflects the state of arrows vs keys, and you can use the original capslock with shift caps or ctrl caps

Fight ADHD and get instant gratification on a succesful build with Growl for Windows

In the words of Wil Wheaton, "I have the attention span of a gerbil" - sometimes I forget I have just built a project and build it again, and again... and again... then actually hit debug. Let's fix this pathetic behaviour with... technology!

Step 1: Install Growl For Windows
Growl is a system notifier that originally came to life as a Mac OSX application. The kind souls at Growl for Windows have ported it over in .Net, so grab it and install it pronto.

Step 2: Install the VS2010 build notifier plugin
Growl uses various plugins for non growl-aware applications. The Growl Visual Studio Add-In needs to be installed after Growl ran for the fist time.

Step 5: Configure notifications
Open Growl, select your favourite display (or install extras, my favourite is Risor), then configure the VS addin so it doesn't notify on every project build, but only on solution build + project failures, such as:

Now run a build and enjoy the sweet, sweet notification of success!

Fall-Through switch statements in C#

Everybody's been told C# switch statements don't support fall-through, this is a fallacy.

var foo=true;
switch (foo)
    case true:
        Console.Out.WriteLine("Bools have 3 values: True");
        goto case false;
    case false:
        goto default;

I feel dirty.