12
\$\begingroup\$

Make a story out of your programming. Example in JavaScript:

self.book = {
    "story": function() {
        var once = "upon",
            aTime = setTimeout(function() {
                // Code would continue...
            }, 1000)
    }
};

self.book.story();

Stipulations:

  • Must run error-free before, during, and after it's compiled.
  • You can only use up to two words for the story per String/name.
    • JavaScript Example:
      var story = "Once upon a"; // Wrong (Using more than two words)
      var story = "Onceupona"; // Wrong (Using more than two "words")
      var onceUponA = "time"; // Wrong (more than two words as a variable name)
      var onceUpon = "a time"; // This is fine
      var story = "Once upon"; // This is fine
  • The story must be a complete sentence (at least).
  • Having some sort of output (such as "printing" the story itself) is not necessary, but it's a plus.
  • Bring some creativity into it.

Since there are no length rules, the answer with the most votes / best creativity will win. :)

\$\endgroup\$
5
  • 2
    \$\begingroup\$ This sort of reminds me of this IOCCC entry, which is written as an exchange of letters \$\endgroup\$
    – Hasturkun
    Commented Jul 28, 2011 at 15:13
  • \$\begingroup\$ I hope you mean only up to 2 words in string literals? Otherwise combining strings would be illegal. \$\endgroup\$
    – jpjacobs
    Commented Jul 28, 2011 at 20:57
  • \$\begingroup\$ @jpjacobs Yup. Though something like "Hi how" + "are you" + "doing today" would be lame. ;) \$\endgroup\$
    – Shaz
    Commented Jul 29, 2011 at 2:52
  • \$\begingroup\$ No objective winning criteria. \$\endgroup\$ Commented Nov 30, 2011 at 13:35
  • 1
    \$\begingroup\$ DevExpress published a creative job offer for their Russian office. \$\endgroup\$
    – shamp00
    Commented Jan 3, 2012 at 9:47

9 Answers 9

18
\$\begingroup\$

JavaScript

Not sure how historically accurate this, but it's a mini-history of ECMAScript. Please feel free to suggest improvements.

function story() {
    var IE = {
        from: "Microsoft"
    },
        Netscape = {
            from: "Mozilla"
        };
    var setUp = {
        oncethere: "were two",
        browsers: IE + Netscape
    };
    var parts = {

        And: function() {
            var theyfought = "to be",
                theBest = "browser";
        },
        oneday: function() {
            var they = {
                added: function() {
                    var add = "scripting languages";
                    Netscape.language = add;
                    IE.language = add;
                    return add;
                },
                thought: function() {
                    if (what(they.added) === good) {
                        they.wouldBeat = "the other";
                    }
                }
            };

        },
        andso: function() {
            function callLanguage(name) { return name };
            Netscape.language = callLanguage("Javascript");
            IE.language = callLanguage("JScript");
        },
        butThen: function() {
            var ECMA = "Standards Committee";
            (function standardized(languages) {
                (function into() {
                    return "ECMAScript";
                })();
            })([IE.language, Netscape.language]);

        },
        theEnd: function() {
            return {
                andWe: "all lived",
                happilyEver: "after..."
            };
        },
        what: function(thing) {
            return thing;
        },
        good: true || false
    };
}
story();
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Now there's a JavaScript Book. ;) \$\endgroup\$
    – Shaz
    Commented Jul 28, 2011 at 1:55
  • 3
    \$\begingroup\$ @Shaz HA yup. Imagine a book explaining JS written like that. O_o \$\endgroup\$ Commented Jul 28, 2011 at 1:56
  • 1
    \$\begingroup\$ Yeah it would certainly be interesting. :P I'm just glad English is my native language. \$\endgroup\$
    – William
    Commented Jul 28, 2011 at 2:03
14
\$\begingroup\$

Reminds me of LOLCode, everything is sort of a story (or at least a "conversation"):

HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
    UPZ VAR!!1
    VISIBLE VAR
    IZ VAR BIGR THAN 10? GTFO. KTHX
KTHX
KTHXBYE
\$\endgroup\$
6
  • \$\begingroup\$ Interesting never heard of LOLCode. However, can you come up with something original or is this the only syntax available? o.O \$\endgroup\$
    – Shaz
    Commented Jul 28, 2011 at 0:46
  • 2
    \$\begingroup\$ That reminds me of Shakespeare programming language. lol. \$\endgroup\$
    – JiminP
    Commented Jul 28, 2011 at 2:38
  • 1
    \$\begingroup\$ lol yeah lmfao en.wikipedia.org/wiki/Shakespeare_(programming_language) \$\endgroup\$
    – Mob
    Commented Aug 6, 2011 at 0:22
  • \$\begingroup\$ Downvoted for being neither interesting nor innovative. Should have been a comment, not an answer. \$\endgroup\$
    – cemper93
    Commented Oct 16, 2011 at 18:26
  • 2
    \$\begingroup\$ "flag this post for serious problems or moderator attention" - that kind of scares me away ;) And I like the question even though it is subjective. It's interesting, and I don't think you have to always have an objective winning criterion. Look at the Code Golfs: Everyone knows in advance Golfscript will be the winner, yet there are other entries. If everyone would only play by objectiveness, this site would soon be dead. \$\endgroup\$
    – cemper93
    Commented Oct 16, 2011 at 18:35
14
\$\begingroup\$

JavaScript

'How';do{'computers'^Function}while(0);'they have'|'no power?'

The output is: 0 on console :D

\$\endgroup\$
6
  • \$\begingroup\$ I like this. :) \$\endgroup\$
    – Shaz
    Commented Jul 28, 2011 at 1:51
  • 2
    \$\begingroup\$ this.is,2,'show my',/appreciation/ \$\endgroup\$
    – William
    Commented Jul 28, 2011 at 2:06
  • \$\begingroup\$ What console? Perhaps you should indicate which language you used. \$\endgroup\$
    – PhiLho
    Commented Jul 28, 2011 at 8:30
  • \$\begingroup\$ It's JavaScript just paste it into firebug/console. \$\endgroup\$
    – William
    Commented Jul 28, 2011 at 13:40
  • \$\begingroup\$ Doesn't do anything here. Or is it just me? \$\endgroup\$
    – jpjacobs
    Commented Jul 28, 2011 at 21:02
13
\$\begingroup\$

It's not so much of a story, and what the program does has nothing to do with what the code says, but...

C++

/* Preface (assuming nobody reads it anyway): */
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <functional>
#include <time.h>
using namespace std;
int



/*Beginning   the*/ main(){//story:

#define   a   string
ofstream ing___water;   a   river;

#define   the
long   rivers,
each,  is
(a ( river +"of").length() > 4 );
a   normal ( river +"has   the");
a bility;   for ( float ing;  short (~1 - - 2 );){
char coal,  loaded,  ships,  on,  its,  water;
coal = is;  a   lot,   lighter;
if ( lighter  .compare ( normal ))water = 'H'*2+'O'; }

a   heavier,  ship,  may;  do { a   worse,  job;  a nd,  run;
a ground; }while ( "you"&&false)//ly
;try { a nd ( "navigate   through");
a ny, such ( normal.size()==rivers     ? 

the  "ship" : may + "then"); }
catch ( exception ally ) { a wful;}} struct ural___damage {
long   before ( the   time_t o)                                                                                               const{
return "to" == a( "harbour");
for ( a   rescue ("from   leaking"),
its ("load   or");o<the'r';) {
ofstream ing,  substances;
if ("not"=="even"||substances/*that*/.put( 'a').bad())
double   damage,  to,  both   the ((short) "river"[1]);
a nd   the ("overall   environment[2].");}}

a   sentient,  ship_owner,  should,  h;int //to
the operator<( struct ural___damage   might)                                                                                  const{
a lso( "occur"), to( "his   own"),health( "when   not");
using   the ::map;
to  .find(  a ( "river   that's"),long( ~3 ) );
(to+="avoid")+=the "trouble   and";
(to+="cause")+=(less</*r*/ural___damage>()
(*this,/*seems like*/*this)?"is": a( "good   idea"));


return before ( the   time(0))||"is"==to +"late";}};

As plain text:

Beginning the main story:
define a string ofstreaming water a river;
define the long rivers, each is a river of length > 4;
a normal river has the ability for floating short (~1--2) charcoal-loaded ships on its water; coal is a lot lighter if lighter compare normal water = H2O;
a heavier ship may do a worse job and run aground while you falsely try and navigate through any such normalsize rivers, the ship may then catch exeptionally awful structural damage long before the time toconst return to a harbour for a rescue from leaking its load or other ofstreaming substances, if not even substances that put a bad double damage to both the short river [1] and the overall environment[2].
a sentient ship_owner should hint to the operator structural damage mightconst also occur to his own health when not using the map to find a river that's long(~3) to avoid the trouble and to cause less rural damage. this seems like this is a good idea. return before the time is to late.
\$\endgroup\$
12
\$\begingroup\$

Brainfuck

+++++ +   + +++++ +++++ +++++   +++++ +++++ 
  +   +   + +     +   + +         +   +     
  +   +++++ +++   +++++ +++       +   +++++ 
  +   +   + +     + ++  +         +       . 
  +   +   + +++++ +   + +++++   +++++ +++++ 

+++++ +   + +     +   +   +++++ +   + +.+++ 
[   + ]+  + +      + +    +   + ++  + +     
+   + + [ + ]       +     +   + + + + +++   
+   + +  ++ +       +     +   + +  ++ +     
+++++ +   + +++++   +     ++++. +   + +++++ 

++++  +++++ +++++ +++++  +   +              
+   + +   + +   +   +    ++  +              
++++  +++++ +++++   +    + + +              
+   + + +   +   +   +    +  ++     +        
++++  +   + +   + +.[+]  +   +    +         

+++++ +   + +++++ +   + +++++ +++++ +++++ . 
+     +   + +     +  +  +     +   + +     + 
+++   +   + +     +++   +++   +++++ +++++ + 
+     +   + +     +  +  +     + ++      +   
.     +++++ +++++ +   + +++++ +   + +++++ . 

I "accidentally" ran this through bf and that came out

It's Me

*SCNR* :)

\$\endgroup\$
1
  • \$\begingroup\$ Interesting! :P \$\endgroup\$
    – Shaz
    Commented Aug 3, 2011 at 21:55
10
\$\begingroup\$

BASIC

slightly simplistic, but very true for those of us who stay up till 3 AM debugging...

On Error GoTo sleep
\$\endgroup\$
1
  • \$\begingroup\$ much nicer than PHP's or die \$\endgroup\$
    – tsh
    Commented Jul 6, 2017 at 2:44
8
\$\begingroup\$

Python Love

def initely(there, were):
    if not None:
        atLeast = not "many"
    who.made("my heart")
    "beat as", you.do(_,_)
    return your.smile
warm = "ly"

try:
    toKeep = "it" + warm
    while walkingHome: pass
    ing(emptyWindows)
except:ionally = "sad"
finally: it = "'s over"

your = not any([1, "to me"]) or "just my toy" and \
type("",(), {"youWere": "more"} )()

your.smile = "kept me"
_ = warm in "these days"

but, you = "were failed by", your #love: me

if _: only(I)
hadKnown, you.were = "innocent as a", lambda \
young, blueEyed: \
[("but ", "the retribution") for myMisdoings #comes
in "time"]

sometimes, you.do = ("make me", #think of who
you.were) 
""in "another story"

I, who = "I've been", your#'s
"sit" in "my room"
"look"in"g at" #old photographs
#relentlessly remembering
the, love = you.do, "give to me"
who.made = all #these mistakes

"Had thought" + it + "would go"
on = "inf"+initely(
"Oh!, the", "fool I've")#been
regretting = all("my errors") #today

_, im = "hold" in "paraly","sys"
_ = open; "cans" and "cans of" 
_ = _(__import__(#ed beer
im).#in a d
argv[0]#id
).read() #sad poems

love, is_ = the, "thing I" #miss forever
iTake = "my camera"
go = "out to have"
new, photos = "to look", _ #at

print ("them" if 0 #they're dull
else _); "they make" + "me think of", love("lost", "for me")

EDIT: This is now a (if cheated) quine.

\$\endgroup\$
3
\$\begingroup\$

bash or other shells on Unix or Linux:

who am I & whereis edit || eliza && find ada 
\$\endgroup\$
2
\$\begingroup\$

I really can't claim this one to myself, but I think it would be really good for you all to be able to look at it.

This is called PHP Sad Poem, and comes from here.

$timeWaiting = 0;
while (!$you->near($me)) {
    $me->thinkAbout($you);
    switch (true) {
        case $timeWaiting < 5:
            $me->wait($you);
            break;
        case $timeWaiting < 10:
            $me->worry();
            break;
        case $timeWaiting < 20:
            $me->lookFor($you);
            break;
        case $timeWaiting < 40:
            $me->worry();
            $me->lookFor($you);
            break;
        case $timeWaiting < 80:
            $me->worry();
            $me->cry();
            $me->lookFor($you);
            $me->lookFor($you);
            $me->lookFor($you);
            break;
        case $timeWaiting < 160:
            $me->worry();
            $me->cry();
            $me->drink();
            $me->lookFor($you);
            $me->lookFor($you);
            $me->lookFor($you);
            $me->thinkAbout($you);
            $me->thinkAbout($you);
            $me->cry();
            $me->lookFor($you);
            $me->lookFor($you);
            $me->drink();
            $me->drink();
            break;
        default:
            throw new CantLiveWithoutYou();
            die(“alone”);
        }
    $timeWaiting++;
}
$me->happy = true;
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.