About Me

microformats hcard approaching

is a Professional Geek for Microsoft Australia. More info lives underneath the About Box...

-33.831416, 151.222526
MrCell+61.417.212181
Work:
1 Epping Road
North Ryde, NSW 2113
Australia
photo of nick hodge

Stuff

View Nick Hodge's profile on LinkedIn

msdn channel 9

LOLCODE: Part 4, A New Beginning">LOLCODE: Part 4, A New Beginning

By Nick Hodge | August 3, 2007

Time to LOLCODE. Watch­ing the for­ums, it’s fun watch­ing the defin­i­tion of a pro­gram­ming lan­guage where the gram­mar is obvious.

And I’ve also thought of a great, quot­able reason to use LOLCode:

Nick Hodge, Enthu­si­ast Evan­gel­ist for Microsoft, recom­mends the invest­ig­a­tion of LOLCODE as Enterprise-worthy Pro­gram­ming Lan­guage if your devel­op­ment pro­ject has a strong require­ment to enter­tain future sys­tem main­ten­ance engin­eers, and your present devel­op­ment team gets LOLCATS humor.” You can quote me on that.

What was not imme­di­ately obvi­ous, another effort is to make your lines of LOL­Code funny. Care­ful choice of vari­able names should res­ult in LULZ.

There were a few occa­sions where I had a peek at the C# source code of the LOL­Code com­piler. It will be inter­est­ing to see how much of the engine that makes the com­piler is taken over by the new DLR, and how hard/easy it is to cre­ate a domain spe­cific lan­guage. The DLR con­tains mainy of the infra­struc­ture pieces, such as cre­ation of abstract syn­tax trees, etc.

Note that these examples com­piled with LOLCODE.Net Build 35, and are based on the 1.2 spe­cific­a­tion.

First pro­gram: Hello World

HAI
VISIBLE “hello world“
KTHXBYE

What’s going on here? HAI is the indic­a­tion of the begin­ning of the lol­code app; KTHXBYE is the end.

VISIBLE “hello world” prints out, well, hello world.

Second pro­gram: Get­ting Input

HAI
    I HASFLUFFYZ
    VISIBLE “ur namez is?”
    GIMMEH LINE FLUFFYZ
    VISIBLE “hello “!
    VISIBLE FLUFFYZ
KTHXBYE

So, what’s going on this time?

I HAS A FLUFFYZ– declares a vari­able called FLUFFYZ

GIMMEH LINE FLUFFYZ– gets some input, in this case from the keyboard

The exclam­a­tion mark at the end of the VISIBLE “hello “! keeps the prin­tout on the same line

VISIBLE FLUFFYZ prints out the con­tent of the vari­able FLUFFYZ. Simple

Third pro­gram: Loop­ing, Conditionals

HAI
I HAS A LIFE ITZ 1
I HAS A OSCARZ ITZ 10
IM IN YR HEADSPIN UPPIN YR LIFE TIL BOTH SAEM LIFE AN OSCARZ
    VISIBLE LIFE
IM OUTTA YR HEADSPIN
KTHXBYE

This code example should work; it com­piles in lolc but neatly stops when run­ning in the CLR. The new parts are the assign­ment of a value to a vari­able (I HAS A LIFE ITZ 1)

Secondly, the line  “I am in your loop increas­ing your LIFE until both-the same life and OSCARZ” is a simple loop with incre­ment and a test.

The “IM IN YR HEADSPIN” is an example/attempt at humor. HEADSPIN is the name of the loop. Craft­ing these names to some­thing funny will provide a future code main­ten­ance geek some LULZ in the future.

Topics: lolcode, teched, technology | 2 Comments »

2 Responses to “LOLCODE: Part 4, A New Beginning”

  1. LOLCODE IN UR TECHED | nickhodge.com | mungenet Says:
    August 9th, 2007 at 12:53 pm

    […] Stage 1: http://www.nickhodge.com/blog/archives/2025Stage 2: LOLCODE HAS LULZ http://forum.lolcode.com/viewtopic.php?id=304Stage 3: Seems that the […]

  2. Adam Says:
    November 10th, 2007 at 2:12 am

    Dunno if you’ve seen this or the further-linked art­icle, but:
    http://icanhaz.com/DLR !

Comments