The best web language: LOLCODE!!! - Presentation Transcript
The best web language.
language
Which is the best programming language for you?
Perl?
PHP?
OR
Python? Ruby?
ASP?
The one true answer is:
LOL Code!!1one
LOLCode is an esoteric language by geeks with too much free time.
There are multiple lolcode interperters, parsers, and even compilers.
“Laser Cats”
I wrote the first working lolcode parser
And the first lolcode powered website.
I am one of those geeks.
“LOLCode By O'RLY”
Basic Usage
CODE SNIPPET
!BEWARE!
HAI <- Opening tag
MUST HAS STDIO <- Require File
VISIBLE \"HAI WORLD!\" <- Print
KTHXBYE <- Closing Tag
Variables
CODE SNIPPET
!BEWARE!
I HAS COLOR1 <- Initiate Variable
I HAS COLOR2 IZ GREEN
^- Initiate and Set Var
COLOR1 IZ RED
^Set existing var
More Variables
CODE SNIPPET
!BEWARE!
VISIBLE “COLOR IS &COLOR1&”
^- Print with Var replacement.
IVAR IZ 1 < Set var to 1.
IVAR UPUP!< Increment twice.
IVAR UPUP!
< IVAR is 3.
BTW THIS IS A COMMENT
^- Use BTW to comment line.
Control Structures
CODE SNIPPET
!BEWARE!
IZ &IVAR& == 1 < IF.
BTW IF
VISIBLE \"YEAH RLY\"
VISIBLE __SKY__ <-Print Constant
NOWAI
BTW ELSE <- ELSE
VISIBLE \"NOWAI\"
KTHX
IF Control Structure
CODE SNIPPET
!BEWARE!
IZ &IVAR& == 1 < IF.
BTW IF
VISIBLE \"YA RLY\"
ORLY &IVAR& == 2
< ELSEIF
VISIBLE \"ORLY\"
ORLY &IVAR& == 2
< ELSEIF
VISIBLE \"ORLY RLY\"
NOWAI
<- ELSE
VISIBLE \"NOWAI\"
KTHX
Arrays
CODE SNIPPET
!BEWARE!
ARRAY IZ BUCKET
< Create Bucket
^Variable Name
0 FISH \"zero\" !! < Numerical
1 FISH \"one\" !! < Keys
< String Keys
two FISH \"two\" !!
BUCKET
<- Prints “two”
VISIBLE &ARRAY#two&
Multidemensional Arrays
CODE SNIPPET
!BEWARE!
ARRAY IZ BUCKET
< Create Bucket
^Variable Name
0 FISH \"zero\" !!
three FISH IZ BAG <- Use bag or buckets
!! FISH \"three\" !!
!! FISH \"two\" !!
^New Dimension
BAG
BUCKET
<- Prints “two”
VISIBLE &ARRAY#two,1&
BAG Arrays
CODE SNIPPET
!BEWARE!
ARRAY IZ BUCKET
< Create Bucket
^Variable Name
0 FISH \"zero\" !!
three FISH IZ BAG <Create BAG
!! FISH \"three\" !!
!! FISH \"two\" !!
BAG ^BAG uses auto
incremented keys.
BUCKET
<- Prints “two”
VISIBLE &ARRAY#two,1&
Looping
CODE SNIPPET
ARRAY IZ BUCKET !BEWARE!
< Create Bucket
0 FISH \"zero\" !!
1 FISH \"1\" !!
2 FISH \"2\" !!
BUCKET
<- Foreach
IM IN UR ARRAY ITZA NUMBA
VISIBLE \"&NUMBA&!\"
^Prints “zero!1!2!”
KTHX
Functions
CODE SNIPPET
!BEWARE!
SO IM LIKE UPPING WITH VAR VAR2=0
^Var Name ^Arguments ^Default
Value
VAR UPUP!
<- Increment VAR
I FOUND MAH VAR<- Return VAR
KTHX <End Function
VISIBLE \"FOUR UP? ITZA \".UPPING(4)
^Prints “5”
Advanced Features
CODE SNIPPET
!BEWARE!
THEVAR IZ GOLD
VARNAME IZ THEVAR
VISIBLE &&VARNAME&& <-Prints “GOLD”
^- Variable Variable
ALWAYZ SKY IZ BLUE <- Set Constant
VISIBLE __SKY__ <- Print Constant
Embed in HTML
CODE SNIPPET
<html> !BEWARE!
<head>
<title>LOL Power</title>
<- HTML
</head>
<body> Subset of XML
HAI
MUST HAS STDIO
VISIBLE \"<!-- Copyright 2007 Jeff
Jones, www.tetraboy.com -->\\n\"
VISIBLE \"HAI WORLD!\"
KTHXBYE
^ Code in tags is parsed.
</body>
</html>
SQLite Databases
CODE SNIPPET
!BEWARE!
CAN HAS SQL? <- Include SQL Lib
DBASE IZ GETDB('lolz')<-Select DB File
FUNNAHS IZ DBUCKET(
^Get Array from DB
&DBASE&,
\"CAN I PLZ GET joke ALL UP IN funnahs\"
)
^LOL-SQL.
“Select joke from funnahs”
SQLite Databases, Part Deux
CODE SNIPPET
!BEWARE!
CAN HAS SQL? <- Get Array from DB
DBASE IZ GETDB('lolz')
FUNNAHS IZ DBUCKET(&DBASE&,\"CAN I PLZ
GET joke ALL UP IN funnahs\")
< Loop It
IM IN UR FUNNAHS ITZA JOKE
VISIBLE \"<P>\".&JOKE#joke&.\"</P>\"
^Print each joke
KTHX
(dbucket returns assoc array)
Tetra LOLCode Parser
How to make a new lang work?
With little to no work?
Convert it to PHP!
How?
preg_replace!
function lol_core_parse($code)
Takes incoming code and runs through 36 regular expressions
/e is your new best friend.
Tetra LOLCode
Works with apache!
Easiest way to run .lol on apache?
Set .lol to parse as PHP
Use PHP's prepend/append
Output Buffering to catch LOL
Parse src
Write source to temporary file
Include temporary file
More info?
http://www.lolcode.com
Official Website
http://www.tetraboy.com/lolcode/
My LOLCode website, powred by LOLCODE!
irc.freenode.net #lolcode
Community IRC Channel. (I Hope noone still goes there..)
MailChimp LOL Parser
Based on my lolcode parser, download their improved version.
1 comments
Comments 1 - 1 of 1 previous next Post a comment