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.
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
I HAS A CODE ITZ "CRAZY"
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: "
IM IN YR
IZ FIB SMALR 1?
I HAS A TEMP ITZ A UP B
LOL A R B
LOL B R TEMP
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!!"
In order to get the DLR Team's implementation running on your own machine, you need to do the following:
Enjoy! If you don't think this is fun, go play with the MVC Demo Source Code from DevConnections and the PNPSummit.
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.
implemented LOLCode on his plane ride to Spain
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.