LOLCODE

Last updated
LOLCODE
LOLCode logo.png
Paradigm esoteric
Designed by Adam Lindsay
First appeared2007
Filename extensions .lol, .lols
Website lolcode.org
Influenced by
Lolcats

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

Contents

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. [4]

Language structure and examples

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. [5] Similar code was printed in the Houston Chronicle . [1]

Example 1

HAI 1.2 CAN HAS STDIO? VISIBLE "HAI WORLD!" KTHXBYE 
CodeComment
HAI [VERSION]In all LOLCODE programs, HAI ("Hi!") introduces the program and specifies the version (although this isn't actually used yet).
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.h> (stdio standing for standard input/output library). This command is a tongue-in-cheek corruption of that, asking if a library is obtainable, obtaining it if possible, and raising an exception if not. [6] It is there primarily for verisimilitude—in fact, it is ignored in current implementations of LOLCODE.
VISIBLE [MESSAGE]Prints a message to the screen.
KTHXBYEJust as HAI introduces the program, KTHXBYE (which is "K," "THX," and "Bye" all strung together, meaning "OK, thanks, bye") terminates it.
BTW [MESSAGE]To write a single line comment in LOLCODE, you use the BTW keyword. Comments are ignored by the compiler and are written for better understanding of the program.
OBTW [MESSAGE]TLDRSimilar to the BTW keyword, the OBTW keyword marks a multiline comment, a comment that spans multiple lines. In LOLCODE, the OBTW keyword signifies the start of a multiline comment while the TLDR keyword ends it.

Example 2

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

[5]

In this example, commands to open a file (PLZ OPEN FILE "NAME"?—"Please open this 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'' (inspired by the "Im in ur noun, verbing yr related noun" LOLcat meme), and ended with IM OUTTA YR ''label''. Loops can be broken with the keyword ENUF ("enough"), or in older versions, GTFO . [7] Loops can also be ended with the conditional IZ command, as demonstrated in the next example.

Example 3

HAI 1.0 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

[5]

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):

HAI 1.2 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

Example 4

HAI 1.0 CAN HAS STDIO? VISIBLE "U SEE THIS" BTW VISIBLE "U SEE NOTHING" OBTW VISIBLE "U SEE NOTHIN" VISIBLE "U STIL SEE NOTHIN" TLDR VISIBLE "U SEE THIS" KTHXBYE 

The above example will return the following:

U SEE THISU SEE THIS

This is because line 3 outputs U SEE THIS but line 5 is ignored due to the fact that it is commented out by the BTW 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 U SEE THIS and line 13 terminates the program.

Implementations

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. [8]

The first LOLCODE implementation was a PHP parser written by Jeff Jones. [9] [10] 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. [11] [12]

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

PL/LOLCODE, a project headed by Josh Tolley, makes LOLCODE available as a server-side programming language inside PostgreSQL. [17]

Microsoft Dynamic Language Runtime has an implementation of LOLCODE for testing purposes. [18]

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

A LOLCODE to JavaScript translator is also available. [20]

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. [21]

A compiler, virtual machine and debugger, created by Piper, for a LoLCode like language, LoLCode 1337, written in C. [22]

A version for parallel and distributed computing can be found. [23]

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. [24]

ArnoldC is an offshoot of LOLCODE that replaces lolspeak with quotes from different Arnold Schwarzenegger movies. [25]

Related Research Articles

In computing, a compiler is a computer program that translates computer code written in one programming language into another language. The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a low-level programming language to create an executable program.

<span class="mw-page-title-main">Interpreter (computing)</span> Program that executes source code without a separate compilation step

In computer science, an interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. An interpreter generally uses one of the following strategies for program execution:

  1. Parse the source code and perform its behavior directly;
  2. Translate source code into some efficient intermediate representation or object code and immediately execute that;
  3. Explicitly execute stored precompiled bytecode made by a compiler and matched with the interpreter's virtual machine.

In computer programming, the scope of a name binding is the part of a program where the name binding is valid; that is, where the name can be used to refer to the entity. In other parts of the program, the name may refer to a different entity, or to nothing at all. Scope helps prevent name collisions by allowing the same name to refer to different objects – as long as the names have separate scopes. The scope of a name binding is also known as the visibility of an entity, particularly in older or more technical literature—this is in relation to the referenced entity, not the referencing name.

In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions. Operationally, a closure is a record storing a function together with an environment. The environment is a mapping associating each free variable of the function with the value or reference to which the name was bound when the closure was created. Unlike a plain function, a closure allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.

<span class="mw-page-title-main">Conditional (computer programming)</span> Control flow statement that executes code according to some condition(s)

In computer science, conditionals are programming language constructs that perform different computations or actions or return different values depending on the value of a Boolean expression, called a condition.

<span class="mw-page-title-main">Foreach loop</span> Control flow statement for traversing items in a collection

In computer programming, foreach loop is a control flow statement for traversing items in a collection. foreach is usually used in place of a standard for loop statement. Unlike other for loop constructs, however, foreach loops usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This avoids potential off-by-one errors and makes code simpler to read. In object-oriented languages, an iterator, even if implicit, is often used as the means of traversal.

This article compares two programming languages: C# with Java. While the focus of this article is mainly the languages and their features, such a comparison will necessarily also consider some features of platforms and libraries. For a more detailed comparison of the platforms, see Comparison of the Java and .NET platforms.

In computer programming, volatile means that a value is prone to change over time, outside the control of some code. Volatility has implications within function calling conventions, and also impacts how variables are stored, accessed and cached.

In computer science, an operator precedence parser is a bottom-up parser that interprets an operator-precedence grammar. For example, most calculators use operator precedence parsers to convert from the human-readable infix notation relying on order of operations to a format that is optimized for evaluation such as Reverse Polish notation (RPN).

The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise. The term usually refers to programming interfaces similar to the classic Lisp machine interactive environment. Common examples include command-line shells and similar environments for programming languages, and the technique is very characteristic of scripting languages.

<span class="mw-page-title-main">Oxygene (programming language)</span> Object Pascal-based programming language

Oxygene is a programming language developed by RemObjects Software for Microsoft's Common Language Infrastructure, the Java Platform and Cocoa. Oxygene is based on Delphi's Object Pascal, but also has influences from C#, Eiffel, Java, F# and other languages.

In computer programming, a programming language implementation is a system for executing computer programs. There are two general approaches to programming language implementation:

The following outline is provided as an overview of and topical guide to computer programming:

This article compares a large number of programming languages by tabulating their data types, their expression, statement, and declaration syntax, and some common operating-system interfaces.

<span class="mw-page-title-main">Sass (style sheet language)</span> Stylesheet language

Sass is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets (CSS). SassScript is the scripting language itself.

<span class="mw-page-title-main">Rexx</span> Command/scripting/programming language

Rexx is a programming language that can be interpreted or compiled. It was developed at IBM by Mike Cowlishaw. It is a structured, high-level programming language designed for ease of learning and reading. Proprietary and open source Rexx interpreters exist for a wide range of computing platforms; compilers exist for IBM mainframe computers.

Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful. Tcl casts everything into the mold of a command, even programming constructs like variable assignment and procedure definition. Tcl supports multiple programming paradigms, including object-oriented, imperative, functional, and procedural styles.

In computer programming languages, an identifier is a lexical token that names the language's entities. Some of the kinds of entities an identifier might denote include variables, data types, labels, subroutines, and modules.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

References

  1. 1 2 Dwight Silverman (2007-06-06). "I'm in ur newspaper writin mah colum". Chron.com. Retrieved 2007-06-06.
  2. "Computing Department at Lancaster University – News". Lancaster University, Computing Department. Archived from the original on 2009-05-28. Retrieved 2009-06-09.
  3. Hammock, Anne (2008-05-01). "The new fame: Internet celebrity". CNN. Archived from the original on 2009-04-30.
  4. Arachnid. "Proof that LOLCode is turing complete:BrainF*** interpreter in LOLCode". forum.lolcode.com. Archived from the original on 2007-07-11. Retrieved 2008-10-05.
  5. 1 2 3 Adam Lindsay (2007-05-25). "LOLCODE main page". lolcode.com. Archived from the original on 2007-10-02. Retrieved 2007-10-02.
  6. "keywords:can-has · LOLCODE". Archived from the original on 2008-02-06. Retrieved 2008-02-10.
  7. "SORN.net". Archived from the original on February 16, 2009. Retrieved 2007-11-07.
  8. "LOLCODE + lci".
  9. "First Parser Comment". Lindsay.at. Archived from the original on 2009-05-19. Retrieved 2009-06-09.
  10. "Tetraboy's LOLCODE parser". Tetraboy.com. Archived from the original on 2009-02-27. Retrieved 2009-06-09.
  11. ""The Best Web Language: LOLCODE" Slides". Slideshare.net. 7 March 2009. Retrieved 2009-06-09.
  12. "PHP Works". mtacon.com. Retrieved 4 November 2014.
  13. LOLCODE .NET compiler at Google Code
  14. TechEd Day 2: Microsoft announces LOLCode support, Long Zheng
  15. LOLcode in next Visual Studio? For young and funny cats, NetworkWorld.com
  16. "Video of LOLCODE presentation at TechEd 2007". Blip.tv. 2007-08-17. Archived from the original on 2009-02-05. Retrieved 2009-06-09.
  17. PL/LOLCODE Archived 2010-11-28 at the Wayback Machine , pgFoundry
  18. Deep DLR, John Lam and Martin Maly
  19. "lolcode grammar interpreter written in Java".
  20. "LolCode". Fullvolume.co.uk. Retrieved 2009-06-09.
  21. "Lightning-Parrot". lolcode.com. Archived from the original on 2009-03-22. Retrieved 2009-06-20.
  22. "LoLCode 1337".
  23. "Parallel and Distributed Computing with LOLCODE".
  24. "LOLPython". Dalkescientific.com. 2007-06-01. Retrieved 2009-06-09.
  25. "ArnoldC".