LOLCODE: Part 4, A New Beginning

Time to LOLCODE. Watching the forums, it’s fun watching the definition of a programming language where the grammar is obvious.

And I’ve also thought of a great, quotable reason to use LOLCode:

Nick Hodge, Enthusiast Evangelist for Microsoft, recommends the investigation of LOLCODE as Enterprise-worthy Programming Language if your development project has a strong requirement to entertain future system maintenance engineers, and your present development team gets LOLCATS humor.” You can quote me on that.

What was not immediately obvious, another effort is to make your lines of LOLCode funny. Careful choice of variable names should result in LULZ.

There were a few occasions where I had a peek at the C# source code of the LOLCode compiler. It will be interesting to see how much of the engine that makes the compiler is taken over by the new DLR, and how hard/easy it is to create a domain specific language. The DLR contains mainy of the infrastructure pieces, such as creation of abstract syntax trees, etc.

Note that these examples compiled with LOLCODE.Net Build 35, and are based on the 1.2 specification.

First program: Hello World

HAI
VISIBLE “hello world”
KTHXBYE

What’s going on here? HAI is the indication of the beginning of the lolcode app; KTHXBYE is the end.

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

Second program: Getting Input

HAI
    I HAS A FLUFFYZ
    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 variable called FLUFFYZ

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

The exclamation mark at the end of the VISIBLE “hello “! keeps the printout on the same line

VISIBLE FLUFFYZ prints out the content of the variable FLUFFYZ. Simple

Third program: Looping, 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 compiles in lolc but neatly stops when running in the CLR. The new parts are the assignment of a value to a variable (I HAS A LIFE ITZ 1)

Secondly, the line  “I am in your loop increasing your LIFE until both-the same life and OSCARZ” is a simple loop with increment and a test.

The “IM IN YR HEADSPIN” is an example/attempt at humor. HEADSPIN is the name of the loop. Crafting these names to something funny will provide a future code maintenance geek some LULZ in the future.

2 thoughts on “LOLCODE: Part 4, A New Beginning”

Comments are closed.