Jump to content

LOLCODE: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Formatting & technicals
No edit summary
Line 14: Line 14:
| date = 2007-06-06
| date = 2007-06-06
| url = http://www.chron.com/disp/story.mpl/business/silverman/4862013.html
| url = http://www.chron.com/disp/story.mpl/business/silverman/4862013.html
| accessdate = 2007-06-06 }}</ref> The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of [[Lancaster University]].<ref>{{cite web|url=http://www.comp.lancs.ac.uk/department/news.html |title=Lancaster University Computing Department News |publisher=Comp.lancs.ac.uk |date= |accessdate=2009-06-09}} {{Dead link|date=September 2010|bot=H3llBot}}</ref>
| accessdate = 2007-06-06 }}</ref> The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of [[Lancaster University]].<ref>{{cite web|url=http://www.comp.lancs.ac.uk/department/news.html |title=Lancaster University Computing Department News |publisher=Comp.lancs.ac.uk |date= |accessdate=2009-06-09}} {{Dead link|date=September 2010|bot=H3llBot}}</ref> It is Andrew Belu's favourite language.


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]].<ref>{{cite web
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]].<ref>{{cite web

Revision as of 19:10, 27 September 2013

LOLCODE
Paradigmesoteric
Designed byAdam Lindsay
First appeared2007
Filename extensions.lol, .lols
Websitelolcode.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, researcher at the Computing Department of Lancaster University.[2] It is Andrew Belu's favourite language.

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

Language structure and examples

LOLCODE's keywords are drawn from the heavily compressed (shortened) patois of the lolcat 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.[1]

Example 1

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

[4]

Code Comment
HAI In all LOLCODE programs, HAI ("Hi!") 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 <cstdio> [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.[5] 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 Just as HAI introduces the program, KTHXBYE (meaning "OK thanks, bye") terminates it.

Example 2

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

In this example,[4] 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 Leetspeak (old version GTFO)[6] 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

[4]

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


Example 4

<?LOL

HAI;
	PLz SHOWS ALL UR VARS;
	YINz CAN HAS VARS++;
		OK SO $THIS Iz A LooP
		{ 
			(( WOW YINz JAGOFF;)
 				i CaN HAZz BA$$;
 				(123 CHECK ITz;)
								)				
		} // uR OUTTA Da LooP NOW;
	LOLZ++;
KTHXBYE;

?>

[7]

Example#4 Info LOLCode Hint
from LOL code TutorialZ by Monkai entitled:

"diss izz a WOW loop example fors uAllz."

Monkai's code hint:

a WOW loop is similar to a WHILE loop in other code languages

Implementations

The first LOLCODE implementation was a PHP parser written by Jeff Jones.[8][9] 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 presentation at PHP Works 2008 was about this parser.[10][11]

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

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

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

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

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

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

An interpreter written in C by Justin J. Meza interprets LOLCODE efficiently on a variety of platforms.[21]

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

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

References

  1. ^ a b Dwight Silverman (2007-06-06). "I'm in ur newspaper writin mah colum". Chron.com. Retrieved 2007-06-06.
  2. ^ "Lancaster University Computing Department News". Comp.lancs.ac.uk. Retrieved 2009-06-09. [dead link]
  3. ^ Arachnid. "Proof that LOLCode is turing complete:BrainF*** interpreter in LOLCode". forum.lolcode.com. Retrieved 2008-10-05.
  4. ^ a b c Adam Lindsay (2007-05-25). " "LOLCODE main page". lolcode.com. Retrieved 2007-10-02. {{cite web}}: Check |url= value (help)
  5. ^ "keywords:can-has · LOLCODE". Retrieved 2008-02-10.
  6. ^ Archived 2009-02-16 at the Wayback Machine
  7. ^ Monkai & PeteS (2013-06-20). "LOLCODE main page". Peter S. Sysko. Retrieved 2013-06-20.
  8. ^ "First Parser Comment". Lindsay.at. Retrieved 2009-06-09.
  9. ^ "Tetraboy's LOLCODE parser". Tetraboy.com. Retrieved 2009-06-09.
  10. ^ ""The Best Web Language: LOLCODE" Slides". Slideshare.net. Retrieved 2009-06-09.
  11. ^ PHP Works
  12. ^ LOLCODE .NET compiler at Google Code
  13. ^ TechEd Day 2: Microsoft announces LOLCode support, Long Zheng
  14. ^ LOLcode in next Visual Studio? For young and funny cats, NetworkWorld.com
  15. ^ "Video of LOLCODE presentation at TechEd 2007". Blip.tv. 2007-08-17. Retrieved 2009-06-09.
  16. ^ PL/LOLCODE, pgFoundry
  17. ^ Deep DLR, John Lam and Martin Maly
  18. ^ "lolcode grammar interpreter written in Java".
  19. ^ "LolCode". Fullvolume.co.uk. Retrieved 2009-06-09.
  20. ^ "Lightning-Parrot". lolcode.com. Retrieved 2009-06-20.
  21. ^ "lci - a LOLCODE interpreter written in C".
  22. ^ http://the-green-leaf.de/lolcode1337.html
  23. ^ "LOLPython". Dalkescientific.com. 2007-06-01. Retrieved 2009-06-09.