AlaaShaker's Weblog

// untitled …

LOLCode: Who said programming wasn’t fun?!

with 2 comments

LOLCodeLOLCode is a programming language originated in May, 2007, with the aim of adding some fun to programming languages and making the learning process easier.

Take a look at the “Hello World” example in the image on the right. This is more likely to output our usual “Hai World!” statement.
As you see, the program starts at HAI and ends with at KTHXBYE, and that, I guess, requires no explanation! The CAN HAS STDIO? resembles our traditional include or require lines for the standard input/output header file STDIO. To output the “Hai World!” message, the keyword VISIBLE is used, similar to print. BTW is used to signal a comment.

So far, the code looks nice and easy. Things get wilder if you go on with LOLCode. See this example:

   1: HAI
   2: CAN HAS STDIO?
   3:   I HAS A var
   4:   GIMMEH var
   5:   VISIBLE "You said " N var N " !!"
   6:   IZ var LESS THAN 10?
   7:     YARLY
   8:       BTW this is true, execute loop
   9:       VISIBLE "BIG NUMBER!"
  10:       IM IN YR LOOPUP var!!1
  11:         VISIBLE var
  12:         IZ var BIGGER THAN 10? KTHX
  13:       IM OUTTA YR LOOP
  14:     NOWAI
  15:       BTW this is false, so do nothing
  16:       VISIBLE "LITTLE NUMBER!"
  17:   KTHX
  18: KTHXBYE

The previous example starts by reading a number from the user using the GIMMEH variable phrase. The number is declared using the I HAS A variable statement. If the number is less than 10, it prints a message then enters a loop (do-while) that increments the number by 1 until it exceeds 10. If not, it just prints a message. A loop starts with IM IN YR LOOP and ends with IM OUTTA YR LOOP. The word KTHX is a block-closing keyword but it is used here as break if the IZ-statement – resembling the IF-statement – evaluates to true. The UP var!!1 statement is equivalent to var+=1 or var++ in C++. The rest of the code is self-explainable ..

You’d be amazed that LOLCode even has try/catch blocks as in the following PLZ-block:

PLZ OPEN FILE "MYFILE.TXT"?
  AWSUM THX
    VISIBLE FILE
  O NOES
    INVISIBLE "ERROR!"
KTHX

The exception is handled in the O NOES block. The INVISIBLE keyword sends a inner message to the debugger. Moreover, the foreach loops are defined as:

IM IN YR loop WATCHIN YR item IN bukkit-var
  ...
KTHX

LOLCode is a pretty interesting and funny language. The syntax and keywords are created, enhanced, added-to and documented by its community through voting. Check out more details on their website or through their FaceBook Profile.

Advertisements

Written by AlaaShaker

March 11, 2008 at 6:15 am

Posted in Development, Technology

Tagged with ,

2 Responses

Subscribe to comments with RSS.

  1. lool, I didn’t check the website yet
    But I imagine that the IDE will be something like MSN messenger. Zaman el 3agayeb!

    mmmzeg

    January 15, 2008 at 5:21 pm

  2. good job alaa what really funny worl yeah
    i think it will be so easier than C++
    (hahahahaha)why don’t we uas it other than C++ ….
    but so funny blog post
    and so great work in your blog
    so technical , light and easy

    N0Ga (Yasmeen)
    Little programmer(Bashmobarmega)

    N0Ga

    February 20, 2008 at 9:47 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: