Scott Hanselman

The Weekly Source Code 11 - LOLCode DLR Edition

November 11, 2007 Comment on this post [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. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
November 11, 2007 19:37
ZOMG, SW33T LOL CODE, LOL

November 11, 2007 20:42
LOLZ I'M IN UR BLOGG!!!111
November 11, 2007 21:53
Ahhhh, this is so beautiful it makes me cry ;'D
November 11, 2007 22:18
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
November 12, 2007 19:26
implemented LOLCode on his plane ride to Spain


I know LOLCode is a fairly simple language, but that's still impressive!
November 12, 2007 23:48
Is that cat saying Leroy from the movie "The last dragon"? ; )
November 13, 2007 1:55
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.
November 13, 2007 3:05
Scott, thanks for the LOLCODE mention. Martin Maly has contributed further details on behind the scenes implementation details at the LOLCODE site.
November 14, 2007 0:31
scott,

lolcats and fibonacci, not sure what to say to that, but thanks for posting something to make me laugh!
November 17, 2007 16:08
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
November 20, 2007 8:14
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.