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">JavaScript</span> High-level programming language

JavaScript, often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2023, 98.7% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. All major web browsers have a dedicated JavaScript engine to execute the code on users' devices.

Rebol is a cross-platform data exchange language and a multi-paradigm dynamic programming language designed by Carl Sassenrath for network communications and distributed computing. It introduces the concept of dialecting: small, optimized, domain-specific languages for code and data, which is also the most notable property of the language according to its designer Carl Sassenrath:

Although it can be used for programming, writing functions, and performing processes, its greatest strength is the ability to easily create domain-specific languages or dialects

<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 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.

In computer programming, a global variable is a variable with global scope, meaning that it is visible throughout the program, unless shadowed. The set of all global variables is known as the global environment or global state. In compiled languages, global variables are generally static variables, whose extent (lifetime) is the entire runtime of the program, though in interpreted languages, global variables are generally dynamically allocated when declared, since they are not known ahead of time.

<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 commands for handling decisions. Specifically, conditionals perform different computations or actions depending on whether a programmer-defined Boolean condition evaluates to true or false. In terms of control flow, the decision is always achieved by selectively altering the control flow based on some condition . Although dynamic dispatch is not usually classified as a conditional construct, it is another way to select between alternatives at runtime. Conditional statements are the checkpoints in the programe that determines behaviour according to situation.

<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.

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

<span class="mw-page-title-main">Syntax (programming languages)</span> Set of rules defining correctly structured programs

In computer science, the syntax of a computer language is the rules that define the combinations of symbols that are considered to be correctly structured statements or expressions in that language. This applies both to programming languages, where the document represents source code, and to markup languages, where the document represents data.

<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.

Haxe is a high-level cross-platform programming language and compiler that can produce applications and source code for many different computing platforms from one code-base. It is free and open-source software, released under the MIT License. The compiler, written in OCaml, is released under the GNU General Public License (GPL) version 2.

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

<span class="mw-page-title-main">Lolcat</span> Image combining a photograph of a cat with text intended to contribute humour

A lolcat, or LOLcat, is an image macro of one or more cats. Lolcat images' idiosyncratic and intentionally grammatically incorrect text is known as lolspeak.

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">Cosmos (operating system)</span> Toolkit for building GUI and command-line based operating systems

C# Open Source Managed Operating System (Cosmos) is a toolkit for building GUI and command-line based operating systems, written mostly in the programming language C# and small amounts of a high level assembly language named X#. Cosmos is a backronym, in that the acronym was chosen before the meaning. It is open-source software released under a BSD license.

<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.

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".