Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

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

share|improve this question

closed as off topic by dmckee Nov 30 '11 at 13:35

Questions on Programming Puzzles & Code Golf Stack Exchange are expected to relate to programming puzzles or code golf within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
This sort of reminds me of this IOCCC entry, which is written as an exchange of letters –  Hasturkun Jul 28 '11 at 15:13
    
I hope you mean only up to 2 words in string literals? Otherwise combining strings would be illegal. –  jpjacobs Jul 28 '11 at 20:57
    
@jpjacobs Yup. Though something like "Hi how" + "are you" + "doing today" would be lame. ;) –  Shaz Jul 29 '11 at 2:52
    
No objective winning criteria. –  dmckee Nov 30 '11 at 13:35
1  

10 Answers 10

up vote 17 down vote accepted

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();
share|improve this answer
1  
Now there's a JavaScript Book. ;) –  Shaz Jul 28 '11 at 1:55
2  
@Shaz HA yup. Imagine a book explaining JS written like that. O_o –  Thomas Shields Jul 28 '11 at 1:56
1  
Yeah it would certainly be interesting. :P I'm just glad English is my native language. –  Liam William Jul 28 '11 at 2:03

JavaScript

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

The output is: 0 on console :D

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

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.
share|improve this answer

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
share|improve this answer
    
Interesting never heard of LOLCode. However, can you come up with something original or is this the only syntax available? o.O –  Shaz Jul 28 '11 at 0:46
2  
That reminds me of Shakespeare programming language. lol. –  JiminP Jul 28 '11 at 2:38
1  
lol yeah lmfao en.wikipedia.org/wiki/Shakespeare_(programming_language) –  Mob Aug 6 '11 at 0:22
    
Downvoted for being neither interesting nor innovative. Should have been a comment, not an answer. –  cemper93 Oct 16 '11 at 18:26
1  
"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. –  cemper93 Oct 16 '11 at 18:35

BASIC

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

On Error GoTo sleep
share|improve this answer

Brainfuck

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

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

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

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

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

It's Me

*SCNR* :)

share|improve this answer
    
Interesting! :P –  Shaz Aug 3 '11 at 21:55

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.

share|improve this answer

bash or other shells on Unix or Linux:

who am I & whereis edit || eliza && find ada 
share|improve this answer

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;
share|improve this answer

C

double d_is_her_bra_size;

share|improve this answer
5  
creative, but you didn't follow the rules... –  Liam William Jul 29 '11 at 5:40

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