From Bauman National Library
This page was last modified on 1 June 2016, at 16:33.
LOLCode logo.png
Paradigm esoteric
Designed by Adam Lindsay
First appeared 2007
Filename extensions .lol, .lols
Website None

LOLCODE is an esoteric programming language inspired by lolspeak, the language expressed in examples of the lolcat Internet meme. The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of Lancaster University.

The language is not clearly defined in terms of operator priorities and correct syntax, but several functioning interpreters and compilers exist. One interpretation of the language has been proven Turing-complete.


Lolcat is a composite of two words, "lol" and "cat". "Lol" stands for "Laugh out Loud" or "Laughing out Loud"; hence, lolcats are intended to be funny and to include jokes. Lolcats images comprise a photo of a cat with a large caption characteristically set in a sans serif font such as Impact or Arial Black. The image is, on occasion, digitally edited for effect.


The caption generally acts as a speech balloon encompassing a comment from the cat, or as a description of the depicted scene. The caption is intentionally written with deviations from standard English spelling and grammar, featuring "strangely-conjugated verbs, but a tendency to converge to a new set of rules in spelling and grammar". The text parodies the grammar-poor patois stereotypically attributed to Internet slang. Frequently, lolcat captions take the form of phrasal templates. Some phrases have a known source, usually a well-known Internet meme, such as All your base are belong to us or Do not want, while others don't. The language of lolcats has also been likened to baby talk.

Common themes include jokes of the form "Im in ur [noun], [verb]-ing ur [related noun]." Many lolcat images capture cats performing characteristically human actions or appearing to use modern technology, such as computers.

There are several well-known lolcat images and single-word captions that have spawned many variations and imitations, including "Ceiling Cat" (see below). Others include Fail (a cat with a slice of processed cheese on its face) and "I Can Has Cheezburger" (a portrait of a blue British Shorthair).


All LOLCODE programs must be opened with the command HAI. HAI should then be followed with the current LOLCODE language version number (1.2, in this case). There is no current standard behavior for implementations to treat the version number, though. A LOLCODE file is closed by the keyword KTHXBYE which closes the HAI code-block.

Single line comments are begun by BTW, and may occur either after a line of code, on a separate line, or following a line of code following a line separator (,). All of these are valid single line comments:

I HAS A VAR ITZ 12          BTW VAR = 12

Multi-line comments are begun by OBTW and ended with TLDR, and should be started on their own lines, or following a line of code after a line separator. These are valid multi-line comments:

    OBTW this is a long comment block
         see, i have more comments here
         and here


All variable scopes are local to the enclosing function or to the main program block. Variables are only accessible after declaration, and there is no global scope.

Variable identifiers may be in all small or lowercase letters (or a mixture of the two). They must begin with a letter and may be followed only by other letters, numbers, and underscores. No spaces, dashes, or other symbols are allowed. Variable identifiers are CASE SENSITIVE – "cheezburger", "CheezBurger" and "CHEEZBURGER" would all be different variables.

To declare a variable, the keyword is I HAS A followed by the variable name. To assign the variable a value within the same statement, you can then follow the variable name with ITZ <value>. Assignment of a variable is accomplished with an assignment statement, <variable> R <expression>.

I HAS A var            BTW 'var' is null and untyped
var R "three"          BTW 'var' is now a YARN and equals "three"
var R 3                BTW 'var' is now a NUMBR and equals 3


The variable types that LOLCODE currently recognizes are: strings (YARN), integers (NUMBR), floats (NUMBAR), and booleans (TROOF) (Arrays (BUKKIT) are reserved for future expansion.) Typing is handled dynamically. Until a variable is given an initial value, it is untyped (NOOB).

The untyped type (NOOB) cannot be implicitly cast into any type except a TROOF. A cast into TROOF makes the variable FAIL. Any operations on a NOOB that assume another type (e.g., math) results in an error. Explicit casts of a NOOB (untyped, uninitialized) variable are to empty/zero values for all other types.

The two boolean (TROOF) values are WIN (true) and FAIL (false). The empty string (""), an empty array, and numerical zero are all cast to FAIL. All other values evaluate to WIN.

The TYPE type only has the values of TROOF, NOOB, NUMBR, NUMBAR, YARN, and TYPE, as bare words. They may be legally cast to TROOF (all true except for NOOB) or YARN. TYPEs are under current review.


Mathematical operators and functions in general rely on prefix notation. By doing this, it is possible to call and compose operations with a minimum of explicit grouping. When all operators and functions have known arity, no grouping markers are necessary. In cases where operators have variable arity, the operation is closed with MKAY. An MKAY may be omitted if it coincides with the end of the line/statement, in which case the EOL stands in for as many MKAYs as there are open variadic functions.

The AN keyword can optionally be used to separate arguments. An expression containing an operator with arbitrary arity can then be expressed with the following syntax:

<operator> <expr1> [[[AN] <expr2>] [AN] <expr3> ...] MKAY
SUM OF <x> AN <y>       BTW +
DIFF OF <x> AN <y>      BTW -
PRODUKT OF <x> AN <y>   BTW *
MOD OF <x> AN <y>       BTW modulo
BIGGR OF <x> AN <y>     BTW max
SMALLR OF <x> AN <y>    BTW min

BOTH OF <x> [AN] <y> BTW and: WIN iff x=WIN, y=WIN EITHER OF <x> [AN] <y> BTW or: FAIL iff x=FAIL, y=FAIL WON OF <x> [AN] <y> BTW xor: FAIL if x=y NOT <x> BTW unary negation: WIN if x=FAIL ALL OF <x> [AN] <y> ... MKAY BTW infinite arity AND ANY OF <x> [AN] <y> ... MKAY BTW infinite arity OR

BOTH SAEM <x> [AN] <y>   BTW WIN iff x == y
DIFFRINT <x> [AN] <y>    BTW WIN iff x != y

Input / Output

The print (to STDOUT or the terminal) operator is VISIBLE. It has infinite arity and implicitly concatenates all of its arguments after casting them to YARNs. It is terminated by the statement delimiter (line end or comma). There is currently no defined standard for printing to a file.

To accept input from the user, the keyword is GIMMEH

VISIBLE <expression> [<expression> ...]
GIMMEH <variable>

Conditions and loops

The traditional if/then construct is a very simple construct operating on the implicit IT variable. In the base form, there are four keywords: O RLY?, YA RLY, NO WAI, and OIC. O RLY? branches to the block begun with YA RLY if IT can be cast to WIN, and branches to the NO WAI block if IT is FAIL. The code block introduced with YA RLY is implicitly closed when NO WAI is reached. The NO WAI block is closed with OIC. Here is an example of a condition clause:

    YA RLY
        VISIBLE "J00 HAV A CAT"
    NO WAI
        VISIBLE "J00 SUX"

The elseif construction adds a little bit of complexity. Optional MEBBE <expression> blocks may appear between the YA RLY and NO WAI blocks.

The LOLCODE keyword for switches is WTF?. The WTF? operates on IT as being the expression value for comparison. A comparison block is opened by OMG and must be a literal, not an expression.

  OMG "R"
  OMG "Y"
  OMG "G"
  OMG "B"

Simple loops are demarcated with IM IN YR <label> and IM OUTTA YR <label>. Loops defined this way are infinite loops that must be explicitly exited with a GTFO break. Currently, the <label> is required, but is unused, except for marking the start and end of the loop.


A function is demarked with the opening keyword HOW IZ I and the closing keyword IF U SAY SO. The syntax is as follows:

HOW IZ I <function name> [YR <argument1> [AN YR <argument2> …]]
  <code block>

Currently, the number of arguments in a function can only be defined as a fixed number. The <argument>s are single-word identifiers that act as variables within the scope of the function's code. The calling parameters' values are then the initial values for the variables within the function's code block when the function is called. Currently, functions do not have access to the outer/calling code block's variables.

Return from the function is accomplished in one of the following ways:

  • FOUND YR <expression> returns the value of the expression.
  • GTFO returns with no value (NOOB).
  • in the absence of any explicit break, when the end of the code block is reached (IF U SAY SO), the value in IT is returned.

A function of given arity is called with:

I IZ <function name> [YR <expression1> [AN YR <expression2> [AN YR <expression3> ...]]] MKAY

That is, an expression is formed by the function name followed by any arguments. Those arguments may themselves be expressions. The expressions' values are obtained before the function is called. The arity of the functions is determined in the definition.


The most recent and up-to-date interpreter for the LOLCODE language is lci, written in C by Justin Meza. It interprets LOLCODE efficiently on a variety of platforms.

The first LOLCODE implementation was a PHP parser written by Jeff Jones. The parser's website was also the first website using LOLCODE as an actual web scripting language. Being open source with a BSD style license, it has been forked and used by multiple websites to implement LOLCODE scripting.

There is a .NET compiler for LOLCODE written by Nick Johnson, and featured in Microsoft developer training seminars, TechEd 2007 Conference (Australia).

lolcode-java (A Java grammar / interpreter for the LOLCODE programming language) is a project also available but it appears to not yet be compliant with the version 1.3 specification.

A LOLCODE to JavaScript translator is also available.

External links

  1. Official website
  2. Wiki about LOLCODE
  3. Open-source interpreter
  4. Specification of LOLCODE v1.2
  5. LOLPython