Scott Hanselman

The Weekly Source Code 11 - LOLCode DLR Edition

November 11, '07 Comments [11] Posted in ASP.NET | Learning .NET | Microsoft | Programming | Source Code | Speaking
Sponsored By

During my Friday Keynote at the PNPSummit I did a silly 30 minute PowerPoint that ended with some LOLCats and a few examples of LOLCode. If you're not familiar with LOLCats, they are basically silly pictures of cats that speak a l33tspeak-like language, like IM IN UR BASE KILLIN YUR D00DS.

This language has turned into a Programming Language called LOLCode for which there are already at least TWO .NET implementations. The first implementation of LOLCode.NET is up on Google Code and is by Nick Johnson.

During my talk, unbeknownst to me, literally that minute John Lam was uploading the DLR team's own implementation of LOLCode implemented from scratch on the DLR. The amazing Martin Maly of the DLR team implemented LOLCode on his plane ride to Spain for presentation at TechEd.

I invited John up on stage spontaneously to give a demo of LOLCode and he did...he showed a Fibonacci implementation.

This is great code to read for two reasons. It's two completely separate implementations of the same general idea - an LOLCode compiler. However, they are implemented completely differently. Of course, the DLR team images this as a Dynamic Language so their implementation is a great primer on how to make your own language on the DLR.

HAI

CAN HAS STDIO?
VISIBLE "HAI WORLD!"

I HAS A CODE ITZ "CRAZY"
VISIBLE CODE

I HAS A NUMBR
LOL NUMBR R 2
VISIBLE NUMBR TIEMZ 2

I HAS A FIB
I HAS A A ITZ 1
I HAS A B ITZ 0

VISIBLE "Fibonacci: "
GIMMEH FIB

IM IN YR
    VISIBLE B

    IZ FIB SMALR 1?
		YARLY
			GTFO
	KTHX

    I HAS A TEMP ITZ A UP B
    LOL A R B
    LOL B R TEMP

    NERFZ FIB!!
KTHX

CAN HAS System?

VISIBLE CurrentDirectory ON Environment ON System
NJU Hashtable ON Collections ON System
I HAS A HT ITZ IT

I HAS A DT
LOL DT R DateTime ON System
VISIBLE Now ON DT

COL Add ON HT WIT "LolCode" AN "Rulezz!!"
VISIBLE COL get_Item ON HT WIT "LolCode"

COL Concat ON String ON System WIT "LolCode " AN "Rulezz!!"
VISIBLE IT

KTHXBYE

In order to get the DLR Team's implementation running on your own machine, you need to do the following:

  1. Get the LOLCode sources
  2. Get IronPython 2.0 Alpha 6
  3. Get the Gardens Point Parser Generator (GPPG) 
  4. Get the Gardens Point Scanner Generator (GPLEX)
    These are kind of Lex and Yacc for C#. Open up the Parser.y and Scanner.l to see the language grammar details.
  5. Confirm the PostBuild steps point to the right locations and make sure the Microsoft.Scripting.dll reference points to the Microsoft.Scripting.dll from the IronPython download.

Enjoy! If you don't think this is fun, go play with the MVC Demo Source Code from DevConnections and the PNPSummit.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Sunday, November 11, 2007 3:37:34 PM UTC
ZOMG, SW33T LOL CODE, LOL

Pop Catalin
Sunday, November 11, 2007 4:42:48 PM UTC
LOLZ I'M IN UR BLOGG!!!111
Sunday, November 11, 2007 5:53:53 PM UTC
Ahhhh, this is so beautiful it makes me cry ;'D
loloolllool
Sunday, November 11, 2007 6:18:37 PM UTC
Its really very good to hear that you are going to give the training for .Net through mails like this...
I am very happy about that and I am eager to learn the .net course through mails like this.....please send me the material of .net.
and Please let me know all the latest updates of this technology
Madhumathi.M
Monday, November 12, 2007 3:26:02 PM UTC
implemented LOLCode on his plane ride to Spain


I know LOLCode is a fairly simple language, but that's still impressive!
Andy
Monday, November 12, 2007 7:48:59 PM UTC
Is that cat saying Leroy from the movie "The last dragon"? ; )
Cameron
Monday, November 12, 2007 9:55:52 PM UTC
I think the cat's yelling at Leroy Jenkins, not worrying about whether Taimak's got the glow on him or whose Converse it'll have to kiss.
When cultural ephemera clash, everybody wins.
Monday, November 12, 2007 11:05:46 PM UTC
Scott, thanks for the LOLCODE mention. Martin Maly has contributed further details on behind the scenes implementation details at the LOLCODE site.
Tuesday, November 13, 2007 8:31:17 PM UTC
scott,

lolcats and fibonacci, not sure what to say to that, but thanks for posting something to make me laugh!
Saturday, November 17, 2007 12:08:25 PM UTC
This is great work. Not wanting Mac and Linux users to be left behind, I've written an article about running the DLR Edition of LOLCODE on Mono...

http://sorn.net/blog/2007/11/LOLCODE-DLR-Edition-on-OS-X-and-Linux-with-Mono
Tuesday, November 20, 2007 4:14:48 AM UTC
Bloody brilliant!!
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.