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, a 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.
LOLCODE's keywords are drawn from the heavily compressed (shortened) patois of the lolcat Internet meme. Here follow a "Hello, World!" program and a simple program to output a file to a monitor. Similar code was printed in the Houston Chronicle.
In this example, commands to open a file (<code>PLZ OPEN FILE "NAME"?</code>âÂÂ"Please open this file?"), and error handling (<code>AWSUM THX</code>âÂÂ"Awesome, thanks!", and <code>O NOES</code>âÂÂ"Oh no!") are introduced.
Other commands include <code>I HAS A variable</code> for declaring variables, <code>variable R value</code> ("variable [is/are/being] value") for assigning them, sending error messages to the front end via <code>INVISIBLE</code> instead of <code>VISIBLE</code>, and <code>BTW</code> ("by the way") to denote a comment, making the parser ignore the rest of the line.
Loops are created with <code>IM IN YR label</code> (inspired by the "Im in ur noun, verbing yr related noun" LOLcat meme), and ended with <code>IM OUTTA YR label</code>. Loops can be broken with the keyword <code>ENUF</code> ("enough"), or in older versions, <code></code>. Loops can also be ended with the conditional <code>IZ</code> command, as demonstrated in the next example.
This simple program displays the numbers 1âÂÂ11 and terminates (as of specification 1.0). The same program as of specification 1.2 is (assuming VAR starts at 0):
The above example will return the following:
This is because line 3 outputs <code>U SEE THIS</code> but line 5 is ignored due to the fact that it is commented out by the <code>BTW</code> keyword. Lines 8 and 9 aren't run because they are in a multiline comment that starts in line 7, and ends on line 10. Line 12 outputs <code>U SEE THIS</code> and line 13 terminates the program.
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 licence, it has been forked and used by multiple websites to implement LOLCODE scripting. The winning Pecha Kucha presentation at PHP Works 2008 was about this parser.
There is a .NET compiler for LOLCODE written by Nick Johnson, and featured in Microsoft developer training seminars, TechEd 2007 Conference (Australia).
PL/LOLCODE, a project headed by Josh Tolley, makes LOLCODE available as a server-side programming language inside PostgreSQL.
Microsoft Dynamic Language Runtime has an implementation of LOLCODE for testing purposes.
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.
There is also a LOLCODE compiler included with the Parrot virtual machine as one of the languages demonstrating the use of Parrot's compiler tools.
A compiler, virtual machine and debugger, created by Piper, for a LoLCode like language, LoLCode 1337, written in C.
A version for parallel and distributed computing can be found.
LOLCODE has also inspired LOLPython, written by Andrew Dalke. LOLPython uses LOL-inspired syntax similar to that of LOLCODE, but with a Python-like style. It operates by translating the LOLPython source into Python code.
ArnoldC is an offshoot of LOLCODE that replaces lolspeak with quotes from different Arnold Schwarzenegger movies.