One day in the not too distant past I took on the unwise decision to attempt port a Ruby application to C#. The decision was unwise primarily due to the fact that I have probably wrote less than 20 lines of Ruby code in my life! But I wasn’t about to let a little thing like not understanding a programming language stop me, after all code is code!!

Now, I’m still currently about 3 weeks into this port (minus the time to fix hard drive failure) and I have to say I’m still quite a way from completing it. The application in question is Less, which is a great little parser that allows CSS type syntax with niceties such as variables, mixins and nested rules.

The source for Less is open source and freely avaliable from github, so there should be no problem porting it right? Well that’s what I thought too, but the interesting thing about Ruby is that it is a very free and dynamic language that allows the definition of what an object “is” to be determined at build and runtime. It does this through a variety of techniques the most impressive one is the use of mixins.

Mixins are a clever way to inject code from a module into a class without having to bring multiple inheritance to the table. This type of thing can only be achieved in C# with clever use of proxy classes, possibly using Castle Windsors IoC continer. Fortunately the structure of Less was such that I haven’t thus far had to go down this route, but it sure didn’t make it too much fun to understand what was going on intially.