Procedural LOLCoding

Recently I had the great pleasure to be introduced to LOLCode. It’s an idiomatic syntax based on a series of images found at LOLCat and ICanHasCheezeBurger. In any event, currently LOLCode syntax is at specification 1.2. There are several compilers including a LOLCode.NET compiler. I gave it a try, but as of the time of this posting, it didn’t seem to be able to handle if statements too well.Currently in specification 1.2, everything is still procedural, though there are proposals for OOP LOLCode in the proposed 1.3 specification. I thought for fun I’d post up some LOLCode snippets from a tic tac toe program I wrote in LOLCode to see if I could get it to work.

HOW DUZ I CheckForWinningMatch YR index1 AN YR index2 AN YR index3 AN YR array

               BOTH SAEM array!!index1 AN array!!index2, O RLY?
                       YA RLY
                               BOTH SAEM array!!index1 AN array!!index3, O RLY?
                                       YA RLY
                                               BOTH SAEM array!!index1 AN “X”, O RLY?
                                                       YA RLY
                                                               FOUND YR WIN

                                                       MEBBE BOTH SAEM array!!index1 AN “O”
                                                               FOUND YR WIN
                                                       OIC
                                       OIC
                       OIC


               FOUND YR FAIL

       IF U SAY SO

The above code snippet checks a one dimensional array (I don’t think it supports multidimensional arrays yet, though I could be wrong) for combinations of the letters X and O for any sort of winning combination. Some of LOLCode syntax includes:


  • Functions declarations in LOLCode start with “HOW DUZ I” and end with “IF YOU SAY SO”.

  • IF statements are equivilent to “O RLY?” and and equivilency is expressed as “BOTH SAEM”.

  • “YA RLY” indicates a positive match, and “NO WAI” indicates a negative match on the condition.

  • “MEBBE” corresponds to “else if”

  • If statements are closed with “OIC” (oh, I see)

  • Return statements are expressed as either “FOUND YR”, followed by a value, or as “GTFO” which returns a void

  • The !! operator acts as an indexer, though my understanding is that in OOP LOLCode it may be used to access properties and methods as well

  • The TROOF data type (boolean), is expressed as either WIN (true) and FAIL (false)

  • Other data types include BUKKIT (array), NOOB (null), NUMBAR (float), NUMBR (int), YARN (string)

  • The SMOOSH keyword handles string concatenation

  • Programs start with HAI and end with KTHXBYE

Here is my “main” method’s code.

HAI

       I HAS A array ITZ A BUKKIT
       I HAS A char ITZ “X”

       DrawTicTacToe array
       

       IM IN YR LOOP

               BOTH SAEM
GetWinningCombination array AN WIN, O RLY?
               YA RLY
                       VISIBLE SMOOSH char ” is winnar!!”
                       
GTFO
               OIC

               GetUserInput char array

               DrawTicTacToe array

               
BOTH SAEM char AN “X”, O RLY?
                       YA RLY
                               char R “O”
                       NO WAI
                               char R “X”
               OIC

       IM OUTTA YR LOOP


KTHXBYE

I grabbed a java compiler from the LOLCode website that appears to have support for the proposed 1.3 specs.

OOP LOLCode, here I come!

 

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.lostechies.com/blogs/joe_ocampo/ Joe Ocampo

    Your a mad man! You find this readable?

  • mbratton

    hey, I got the whole app running, but I’ve seen a lot of lolcats, so…

    I get a real laugh out of reading other people LOLCode. If you name your variables correctly, you can produce some almost fluent code. ;)

    Besides, it’s legitimate, there’s even a subsonic provider for it:

    http://blog.wekeroad.com/2007/10/26/new-subsonic-provider-lolcodenet/

    and here’s the link to a resource about the .net compiler:

    http://blog.notdot.net/archives/32-LOLCode.net-Now-your-LOLCats-can-use-the-CLR!.html

  • ItWorksOnMyMachine

    I can’t wait to see the LOLNUnit implementation.

  • http://anydiem.com Sean Scally

    This is surely a harbinger of the apocalypse.

    Also, I, too wanted to see the lolUnit tests for this code.

  • mbratton

    I’m sure I’ll get into LOL Driven Development when they get enough support built into their .NET implementation to be able to put dependencies on NUnit, or any other unit testing framework (unless you’re suggesting I write my own LOLUnit framework myself, in which case… maybe in a few versions :D )

  • http://anydiem.com Sean Scally

    WTB: More Bratton Blogging