Beginner

Hello World in LOLCODE

Your first LOLCODE program - the classic Hello World example with Docker setup

Writing “Hello, World!” in LOLCODE is a fun introduction to one of the most approachable esoteric programming languages. Unlike the cryptic minimalism of Brainfuck or the deliberate frustration of INTERCAL, LOLCODE reads like an enthusiastic cat learning to code.

The Code

Create a file named hello.lol:

HAI 1.2
  VISIBLE "Hello, World!"
KTHXBYE

That’s it! Three lines that perfectly capture the spirit of lolspeak programming.

Understanding the Code

Let’s break down each line:

HAI 1.2

HAI 1.2

HAI is how a LOLCODE program says hello to the interpreter - it marks the start of the program. The 1.2 specifies the LOLCODE language version we’re using (the most common specification).

Think of it as the Internet equivalent of #include <stdio.h> or public static void main() - but friendlier.

VISIBLE

VISIBLE "Hello, World!"

VISIBLE is LOLCODE’s print statement. Whatever you put after it becomes visible to the user - hence the name. It’s more intuitive than printf or console.log when you think about it!

Strings in LOLCODE are enclosed in double quotes, just like most languages.

KTHXBYE

KTHXBYE

KTHXBYE (“OK, thanks, bye!”) marks the end of the program. It’s the polite way to tell the interpreter you’re done.

Running with Docker

The easiest way to run LOLCODE without installing an interpreter locally:

1
2
3
4
5
# Pull the LOLCODE interpreter image
docker pull esolang/lolcode

# Run the program
docker run --rm -v $(pwd):/code esolang/lolcode lci /code/hello.lol

Expected Output

Hello, World!

Variations

Minimal Version

You can write it even more compactly (though it’s less idiomatic):

HAI 1.2
VISIBLE "Hello, World!"
KTHXBYE

With a Comment

LOLCODE supports comments using BTW (by the way) for single lines:

HAI 1.2
  BTW This is my first LOLCODE program!
  VISIBLE "Hello, World!"
KTHXBYE

For multi-line comments, use OBTW and TLDR:

HAI 1.2
  OBTW
    This is a longer comment
    that spans multiple lines.
    Because sometimes you have a lot to say!
  TLDR
  VISIBLE "Hello, World!"
KTHXBYE

Using a Variable

You can also store the message in a variable first:

HAI 1.2
  I HAS A MESSAGE ITZ "Hello, World!"
  VISIBLE MESSAGE
KTHXBYE

I HAS A declares a variable, and ITZ initializes it with a value.

Common Mistakes

Forgetting HAI

Every LOLCODE program must start with HAI. Without it, the interpreter doesn’t know you’re talking to it:

BTW This won't work!
VISIBLE "Hello, World!"
KTHXBYE

Missing KTHXBYE

While some interpreters are forgiving, proper LOLCODE programs should end with KTHXBYE:

HAI 1.2
VISIBLE "Hello, World!"
BTW Forgetting to say goodbye is rude!

Case Sensitivity

LOLCODE keywords are typically uppercase. Lowercase might not be recognized:

hai 1.2
visible "Hello, World!"
kthxbye
BTW This might not work depending on the interpreter

The Lolspeak Dictionary

Here’s a quick reference for the keywords we’ve used:

LOLCODEEnglishProgramming Equivalent
HAIHi!Program start / main()
KTHXBYEOK, thanks, bye!Program end / return
VISIBLE(make it) visibleprint / console.log
BTWBy the way// single-line comment
OBTW…TLDROh by the way…Too long, didn’t read/* multi-line comment */
I HAS AI have aVariable declaration
ITZIt isVariable initialization

Historical Note

LOLCODE was created in 2007 by Adam Lindsay at Lancaster University, at the height of the lolcat phenomenon. The language specification version 1.2 that we use was released that same year and remains the standard.

The esolang/lolcode Docker image uses the lci interpreter written in C by Justin Meza, which is the most complete and well-maintained LOLCODE implementation available.

Next Steps

Now that you’ve said “HAI” to LOLCODE, explore more of its features:

  • Variables with I HAS A
  • Conditionals with O RLY?, YA RLY, and NO WAI
  • Loops with IM IN YR and IM OUTTA YR
  • Functions with HOW IZ I and IF U SAY SO

KTHXBYE for now, and happy coding!

Running Today

All examples can be run using Docker:

docker pull esolang/lolcode
Last updated: