LOLCODE
Encyclopedia
LOLCODE is an esoteric programming language
Esoteric programming language
An esoteric programming language is a programming language designed as a test of the boundaries of computer programming language design, as a proof of concept, or as a joke...

 inspired by the language expressed in examples of the lolcat
Lolcat
A lolcat is an image combining a photograph of a cat with text intended to contribute humour. The text is often idiosyncratic and grammatically incorrect, and its use in this way is known as "lolspeak" or "kitty pidgin"....

 Internet meme
Internet meme
The term Internet meme is used to describe a concept that spreads via the Internet. The term is a reference to the concept of memes, although the latter concept refers to a much broader category of cultural information.-Description:...

. The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of Lancaster University
Lancaster University
Lancaster University, officially The University of Lancaster, is a leading research-intensive British university in Lancaster, Lancashire, England. The university was established by Royal Charter in 1964 and initially based in St Leonard's Gate until moving to a purpose-built 300 acre campus at...

.

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

Language structure and examples

LOLCODE's keyword
Keyword (computer programming)
In computer programming, a keyword is a word or identifier that has a particular meaning to the programming language. The meaning of keywords — and, indeed, the meaning of the notion of keyword — differs widely from language to language....

s are drawn from the heavily compressed (shortened) patois
Patois
Patois is any language that is considered nonstandard, although the term is not formally defined in linguistics. It can refer to pidgins, creoles, dialects, and other forms of native or local speech, but not commonly to jargon or slang, which are vocabulary-based forms of cant...

 of the lolcat
Lolcat
A lolcat is an image combining a photograph of a cat with text intended to contribute humour. The text is often idiosyncratic and grammatically incorrect, and its use in this way is known as "lolspeak" or "kitty pidgin"....

 Internet meme. Here follows a Hello world program and a simple program to output a file to a monitor. Similar code was printed in the Houston Chronicle
Houston Chronicle
The Houston Chronicle is the largest daily newspaper in Texas, USA, headquartered in the Houston Chronicle Building in Downtown Houston. , it is the ninth-largest newspaper by circulation in the United States...

.

Example 1


HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE

{| class="wikitable" width="80%"

! Code
! Comment
|-
| HAI
| In all LOLCODE programs, HAI introduces the program.
|-
| CAN HAS [LIBRARY]?
| In many programming languages, one of the first statements will be a library inclusion for common functions such as input and output. Typically this is included by a call such as #include [stdio standing for standard input/output library]. This command is a tongue-in-cheek
Tongue-in-cheek
Tongue-in-cheek is a phrase used as a figure of speech to imply that a statement or other production is humorously intended and it should not be taken at face value. The facial expression typically indicates that one is joking or making a mental effort. In the past, it may also have indicated...

 corruption of that, asking if a library is obtainable, obtaining it if possible, and raising an exception if not. It is there primarily for authenticity — in fact, it is ignored in current implementations of LOLCODE.
|-
| VISIBLE [MESSAGE]
| prints a message to the screen.
|-
| KTHXBYE
| HAI introduces the program, so KTHXBYE (meaning "Okay thanks, bye") terminates it.
|}

Example 2


HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
AWSUM THX
VISIBLE FILE
O NOES
INVISIBLE "ERROR!"
KTHXBYE

In this example, commands to open a file (PLZ OPEN FILE "NAME"? — "Please try to open a file?"), and error handling (AWSUM THX — "Awesome, thanks!", and O NOES — "Oh no!") are introduced.

Other commands include I HAS A variable for declaring variables, variable R value ("variable [is/are/being] value") for assigning them, sending error messages to the front end via INVISIBLE instead of VISIBLE, and BTW ("by the way") to denote a comment, making the parser ignore the rest of the line. Loops are created with IM IN YR label (from an internet meme "I'm in your ___"), and ended with IM OUTTA YR label. Loops lack counters or conditions, and thus do not cease inherently. They must be manually broken with the ENUF, "enough" in Leet
Leet
Leet , also known as eleet or leetspeak, is an alternative alphabet for the English language that is used primarily on the Internet. It uses various combinations of ASCII characters to replace Latinate letters...

speak (old version GTFO) command. Loops can also be ended with the conditional IZ command:

Example 3


HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
VISIBLE VAR
IZ VAR BIGGER THAN 10? KTHX
IM OUTTA YR LOOP
KTHXBYE

This simple program displays the numbers 1–10 and terminates (as of specification 1.0). The same program as of specification 1.2 is (assuming VAR starts at 0):


HAI
CAN HAS STDIO?
IM IN YR LOOP UPPIN YR VAR TIL BOTH SAEM VAR AN 10
VISIBLE SUM OF VAR AN 1
IM OUTTA YR LOOP
KTHXBYE

Implementations

The first LOLCODE implementation was a PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

 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. The winning Pecha Kucha
Pecha Kucha
Pecha Kucha is a presentation methodology in which 20 slides are shown for 20 seconds each, usually seen in a multiple-speaker event called a Pecha Kucha Night ....

 presentation at PHP Works 2008 was about this parser.

There is a .NET
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

 compiler for LOLCODE written by Nick Johnson, and featured in Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 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
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 Dynamic Language Runtime
Dynamic Language Runtime
The Dynamic Language Runtime from Microsoft is an ongoing effort to bring a set of services that run on top of the Common Language Runtime and provides language services for several different dynamic languages...

 has an implementation of LOLCODE for testing purposes.

A LOLCODE to JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

 translator is also available

There is also a LOLCODE compiler included with the Parrot virtual machine
Parrot virtual machine
Parrot is a register-based process virtual machine designed to run dynamic languages efficiently. It uses just-in-time compilation for speed to reduce the interpretation overhead. It is currently possible to compile Parrot assembly language and PIR to Parrot bytecode and execute it...

 as one of the languages demonstrating the use of Parrot's compiler tools.

A low-level interpreter written in C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

exists, maintained by Justin J. Meza, to provide native LOLCODE interpretation on a variety of platforms.

Related projects

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.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK