Hello World in LOLCODE: A Very Peculiar Programming Language

<!-- **This post is originally from [xtrp.io](https://xtrp.io/), a blog about CSS, JavaScript, and just about anything programming.** -->
1HAI 1.2 2 VISIBLE "Hello, World!" 3KTHXBYE 4

Yes, that was a "Hello, World!" program in the famous LOLCODE programming language.

LOLCODE is an esoteric programming language, a type of programming language which is defined by the Esolang Wiki as follows:

An esoteric programming language is a computer programming language designed to experiment with weird ideas, to be hard to program in, or as a joke, rather than for practical use.

Other esoteric programming languages include the famous Brainf*** programming language, Malbolge, and more.

LOLCODE was written to be programming language to mimic the "lolcats" meme which became popular in the mid-2000s, with basic syntax including words such as HAI (start program with version number) and KTHXBYE (end program).

Like many other esoteric programming languages, LOLCODE is actually very featured, and has the capability to be used to write many complex programs.

In fact, Justin Meza, the creator of the most recent LOLCODE interpreter, created httpd.lol, an HTTP server written entirely in LOLCODE.

Let's Write a Basic LOLCODE Program

First, to run actual LOLCODE programs, I'll be using the LOLCODE Repl.it Online Interpreter, although you can download the LOLCODE C Interpreter to run LOLCODE programs locally.

HAI and KTHXBYE for starting and ending programs

Every LOLCODE program starts with a HAI declaration, followed by a version number. For example:

1HAI 1.2 2

With the HAI declaration, the end of every program must include a KTHXBYE statement, for example:

1HAI 1.2 2 3KTHXBYE 4

BTW and OBTW for comments

The BTW keyword introduces a single line comment, like this:

1BTW this is a single line comment 2

Whereas the OBTW and TLDR keywords are used to start and end a multiline comment respectively, for example:

1OBTW 2This is a multiline comment 3TLDR 4

VISIBLE for printing to stdout

To print text in LOLCODE, the VISIBLE keyword is used as follows:

1VISIBLE "Hello, World!" 2

Variables with I HAS A [varname] ITZ [value]

Variables in LOLCODE are written with the syntax I HAS A [var] ITZ [value], for example:

1BTW this sets the variable NAME to the value "Gabriel Romualdo" 2I HAS A NAME ITZ "Gabriel Romualdo" 3

Variables can then be referenced later with the same name.

SMOOSH and AN for concatenation

To concatenate strings and variables, SMOOSH is used. Example is provided in basic program below.

A Basic Program to Concatenate Strings and Variables

Now, we'll combine these basic LOLCODE keywords and syntax to create a very, very basic program which concatenates strings and variables.

The Python equivalent of this would be:

1name = "Gabriel Romualdo" 2website = "xtrp.io" 3favorite_color = "blue" 4 5print("Hi, I am " + name + ", my website is at " + website + " and my favorite color is " + favorite_color + ".") 6

Which in LOLCODE is:

1HAI 1.2 2 OBTW 3 This program creates several variables, concatenates them, and prints them. 4 TLDR 5 6 BTW create variables 7 I HAS A NAME ITZ "Gabriel Romualdo" 8 I HAS A WEBSITE ITZ "xtrp.io" 9 I HAS A FAVORITECOLOR ITZ "blue" 10 11 BTW concatenate with SMOOSH and AN 12 VISIBLE SMOOSH "Hi, I am " AN NAME AN ", my website is at " AN WEBSITE AN " and my favorite color is " AN FAVORITECOLOR AN "." 13KTHXBYE 14

And produces the following output successfully:

Hi, I am Gabriel Romualdo, my website is at xtrp.io and my favorite color is blue.

Note that some interpreters may require LOLCODE programs to include the STDIO library, which can be included with a CAN HAS [library]? statement.

Conclusion

I hope you enjoyed this post and found LOLCODE to be a funny yet interesting programming language. You can read more about LOLCODE and its syntax on the LOLCODE Esolang Wiki Page, and check out The LOLCODE Website.

<!-- **This post is originally from [xtrp.io](https://xtrp.io/), a blog about CSS, JavaScript, and just about anything programming.** -->

Thanks for scrolling.

— Gabriel Romualdo, January 11, 2020