Hello World in LOLCODE: A Very Peculiar Programming Language
Tags: programming, lolcode
Published: 2020-01-11 20:15:47

---
title: "Hello World in LOLCODE: A Very Peculiar Programming Language"
published: true
description: "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."
tags: #programming, #lolcode
cover_image: "https://xtrp.io/api/content/static_files/hello-world-in-lolcode/photo2.jpg?v=1"
---

```LOLCODE
HAI 1.2
	VISIBLE "Hello, World!"
KTHXBYE
```

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](https://esolangs.org/) 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\*\*\*](https://esolangs.org/wiki/Brainfuck) programming language, [Malbolge](https://esolangs.org/wiki/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](https://github.com/justinmeza/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](https://repl.it/languages/lolcode), although you can download the [LOLCODE C Interpreter](https://github.com/justinmeza/lci) 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:

```LOLCODE
HAI 1.2
```

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

```LOLCODE
HAI 1.2

KTHXBYE
```

### `BTW` and `OBTW` for comments

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

```LOLCODE
BTW this is a single line comment
```

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

```LOLCODE
OBTW
This is a multiline comment
TLDR
```

### `VISIBLE` for printing to stdout

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

```LOLCODE
VISIBLE "Hello, World!"
```

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

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

```LOLCODE
BTW this sets the variable NAME to the value "Gabriel Romualdo"
I HAS A NAME ITZ "Gabriel Romualdo"
```

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:

```python
name = "Gabriel Romualdo"
website = "gabrielromualdo.com"
favorite_color = "blue"

print("Hi, I am " + name + ", my website is at " + website + " and my favorite color is " + favorite_color + ".")
```

Which in LOLCODE is:

```LOLCODE
HAI 1.2
	OBTW
		This program creates several variables, concatenates them, and prints them.
	TLDR

	BTW create variables
	I HAS A NAME ITZ "Gabriel Romualdo"
	I HAS A WEBSITE ITZ "gabrielromualdo.com"
	I HAS A FAVORITECOLOR ITZ "blue"

	BTW concatenate with SMOOSH and AN
	VISIBLE SMOOSH "Hi, I am " AN NAME AN ", my website is at " AN WEBSITE AN " and my favorite color is " AN FAVORITECOLOR AN "."
KTHXBYE
```

And produces the following output successfully:

```
Hi, I am Gabriel Romualdo, my website is at gabrielromualdo.com 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](https://esolangs.org/wiki/LOLCODE), and check out [The LOLCODE Website](http://www.lolcode.org/).

Thanks for scrolling.

*&mdash; Gabriel Romualdo, January 11, 2020*