text:
Write a short story using only valid code
What I'd like to see is your attempts at writing a kind of "story" that has a fairly easy to read meaning, but also creating a valid code fragment. For example, this (BBC) BASIC code:
LET customer = "sober"
REPEAT
  INPUT "more beer"
UNTIL customer = "drunk"

(based on http://img.rakuten.com/PIC/12184048/0/1/300/12184048.jpg for the idea)
Rules/guidelines:

The code must be valid in the language you specified - Anybody must be able to run it without needing to create any fancy
Strings, comments, or anything that allows free text to be added to the code, may be used, but for at most 3 words per string (and you can't put multiple strings or comments in  a row)
Your code does not have to result in any sensible output when it's executed. It can even be an infinite loop, as long as the code is valid and it represents something sensible(*) when read in English.
Any interpunction in your code will be ignored in the story.
Variables do not need to be defined. The code you make here is just a code fragment. You will lose 5 points for calling an undefined variable/keyword/label/etc. though.
for every individual built-in keyword/statement/function/etc you use, you receive 15 points. These include for and if, but also built-in functions such as replace(). Libraries do not count as built-in functions, but you're free to use them.
for every letter, number, or underscore in your code, you receive 1 point.
for every line/block of code that is unrelated(*) to the story, or uses keywords/statements/etc with no meaning(*) in English, you lose 20 points, and the involved characters will not count towards the 1 point per letter/number. To keep it fair to the languages that need data types like int when defining variables, data types are ignored completely. This means they don't receive 10 points for being a keyword, they won't receive points for the involved characters, but they also don't cause point loss.
It is not allowed to just make something valid English by inserting a comment to "fill in the blanks".
Since this is a popularity-contest, for every upvote to your answer you will receive 25 points.
Make sure to specify which language your code is in, and the formula you used to count the amount of points your answer gets.
The answer with the most points, using this system above, wins.
Using this system, the above example code would get 4*15 + 53*1 = 113 initial points.

(*) over-analysation / objectification part: to keep this as objective as possible, "sensible" or "unrelated" means the following: If the piece of code uses words that are not English, it's not valid (for example, const or int are not English words, but foreach or typeof is 2 English words merged, so that is okay). Also, even if you use valid English words such as print or echo, these will have to fit in with the story with their original meaning (so 'putting ink on paper' and 'reflecting sound', not 'showing on a screen'). And with 'fit in', I mean that the subject of the story must be related to it.
I hope this last "disclaimer" meets the requirement of defining objective criteria.

Is it permitted that my program produce a runtime error?

@H2CO3 My feeling is no.

There's a classic and amazing IOCCC winner that did this: http://ioccc.org/1990/westley.c

What about this Python solution: buffalo="buffalo";buffalo+buffalo+buffalo+buffalo+buffalo+buffalo.

css (114)
I'm new to the golf scene. Not sure if CSS counts as 'code'. But here's a stab at it.
The year is still young...
body {width: 110%}
.pants {overflow: visible}
.newYear {transform: scale(.8)}

If I understand the scoring:

every individual built-in keyword = 4 * 15

every letter/number = 1 * 54

every unrelated line = 0
= initial score: 114

What's the "story" when read in English here?

@joeytje50 Overweight => doesn't fit in pants => new year's resolution to lose weight

@Bob Ah I see it now, exactly what I was looking for in this question. Upvoted.

SQL love poem
SELECT * FROM Night_Sky
WHERE Beauty LIKE "yours"

0 results returned

I'm a little unsure of the rules here, as my output is obviously important to the story, but not part of the code. So I'm ignoring it as far as scoring is concerned.
I'm also counting the "*" (star) for one point, despite it not being alphanumeric or underscore, because it is important to the story.
So my score is (4*15)+(40*1)=100
Potentially minus 10 for the two undefined variables, but that depends on your existing database.

Clever. I like it. It's like a SQL pickup line. :)

Shakespeare!
    The Infamous Hello World Program.

Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.

                    Act I: Hamlet's insults and flattery.

                    Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]

Hamlet:
 You lying stupid fatherless big smelly half-witted coward!
 You are as stupid as the difference between a handsome rich brave
 hero and thyself! Speak your mind!

 You are as brave as the sum of your fat little stuffed misused dusty
 old rotten codpiece and a beautiful fair warm peaceful sunny summer's
 day. You are as healthy as the difference between the sum of the
 sweetest reddest rose and my father and yourself! Speak your mind!

 You are as cowardly as the sum of yourself and the difference
 between a big mighty proud kingdom and a horse. Speak your mind.

 Speak your mind!

[Exit Romeo]

                    Scene II: The praising of Juliet.

[Enter Juliet]

Hamlet:
 Thou art as sweet as the sum of the sum of Romeo and his horse and his
 black cat! Speak thy mind!

[Exit Juliet]

                    Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
 Thou art as lovely as the product of a large rural town and my amazing
 bottomless embroidered purse. Speak thy mind!

 Thou art as loving as the product of the bluest clearest sweetest sky
 and the sum of a squirrel and a white horse. Thou art as beautiful as
 the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]

                    Act II: Behind Hamlet's back.

                    Scene I: Romeo and Juliet's conversation.

[Enter Romeo and Juliet]

Romeo:
 Speak your mind. You are as worried as the sum of yourself and the
 difference between my small smooth hamster and my nose. Speak your
 mind!

Juliet:
 Speak YOUR mind! You are as bad as Hamlet! You are as small as the
 difference between the square of the difference between my little pony
 and your big hairy hound and the cube of your sorry little
 codpiece. Speak your mind!

[Exit Romeo]

                    Scene II: Juliet and Ophelia's conversation.

[Enter Ophelia]

Juliet:
 Thou art as good as the quotient between Romeo and the sum of a small
 furry animal and a leech. Speak your mind!

Ophelia:
 Thou art as disgusting as the quotient between Romeo and twice the
 difference between a mistletoe and an oozing infected blister! Speak
 your mind!

[Exeunt]

Source(I have no clue how to write Shakespeare. Or read it for that matter). I'm also very confused as to how to score it. Also, I'm surprised nobody has posted the classic Char Lotte and Char Lie

In what programming language would this be? See the examples in the OP, and the other answers, to see how to score it. This is not supposed to be a "paste a story you like" contest, but one where you integrate a "story" into programming languages. A nice example is the CSS example by DA. @ http://codegolf.stackexchange.com/a/19289/14903

This is the Shakespeare programming language, a language built specifically for the purpose of writing programs that are stories

Nice finds. I especially really like that charlotte&charlie story. They're not really original though, since it's all a copy paste from somewhere else. Upvoted you anyway, because they're still good.

I really wish people would stop posting the Shakespeare Hello World as an answer and perhaps write something themselves in Shakespeare. 7 up votes for plagiarism...pitiful.

Posting answers you have not written yourself, but merely copied from elsewhere, is generally not considered acceptable on this site.

I've made this answer community wiki as it does not represent the poster's own work.

I can delete it if you'd like. I didn't really realize that this counted as plagiarism.

How is it plagiarism? The author is mentioned in the first line!

I have to agree, this has been simply cut and pasted,  @scrblnrd3.

Johnny's life story
kid=spawnKidFromParents(mother, father)
kid.live()
recycle()

def spawnKidFromParents(mother, father):
    kid=father.censor(mother)
    kid.name=Names.babyNames.orderBy("popularity").pop()
    return kid

person class (select methods only)
def live(self):
    try:
        while(self.health > 0):
            self.wakeUp()
            self.work()
            self.eat()
            self.sleep()
    except LossOfLifeException:
        self.closeEyes()

def wakeUp(self):
    while ( (self.laziness + self.calendar.today.importance * (1 - self.fatigue)) < random.randint(0,100)):
        pass

    self.openEyes()
    self.stand()
    self.dress()

def work(self):
    for money in range(self.wallet.EMPTY, self.wallet.MAX_CAPACITY):
        type()

def eat(self):
    while(self.hunger < self.FOOD_CAPACITY * 0.8 - self.diet):
        popcorn.pop()

def sleep(self):
    self.undress()
    self.layDown()
    self.closeEyes()
    pass

. . . "recycle()"?

Shouldn't sleep reduce your fatigue, and work increase it?

Where is the poop? (I mean, poop() function) Because human can't only eat and not make a single poop. And in this code I saw only pop()…

Perl 3
Not my work, but I'm saddened that nobody has referenced black perl here yet...
BEFOREHAND: close door, each window & exit; wait until time.
    open spellbook, study, read (scan, select, tell us);
write it, print the hex while each watches,
    reverse its length, write again;
    kill spiders, pop them, chop, split, kill them.
        unlink arms, shift, wait & listen (listening, wait),
sort the flock (then, warn the "goats" & kill the "sheep");
    kill them, dump qualms, shift moralities,
    values aside, each one;
        die sheep! die to reverse the system
        you accept (reject, respect);
next step,
    kill the next sacrifice, each sacrifice,
    wait, redo ritual until "all the spirits are pleased";
    do it ("as they say").
do it(*everyone***must***participate***in***forbidden**s*e*x*).
return last victim; package body;
    exit crypt (time, times & "half a time") & close it,
    select (quickly) & warn your next victim;
AFTERWARDS: tell nobody.
    wait, wait until time;
    wait until next year, next decade;
        sleep, sleep, die yourself,
        die at last
# Larry Wall

This gem used to be valid code on Perl 3. Wikipedia says there are several updates for perl 5, but that's not the point really, is it?

This has to be the ultimate, surely, and definitely belongs here.   But I don't think you can win with someone else's work, even attributed?

Agreed-- on both counts. It just didn't seem right to leave this out of the collection... Not expecting any awards (nor is this posting in danger of any, apparently. :-)

IMHO, this just blows away all the other attempts and renders the question moot :D

GW-BASIC: 1*-5 + 7*15 + 76*1 = 176 points
LET criminal = "free"
FOR day = 1 to 100
    PRINT "evaluation"
NEXT day
IF criminal = "bad"
THEN
GOTO JAIL

Subtracted 5 points for undefined label JAIL.

I think that this is QBasic or QuickBasic. As I remember in GW-BASIC the lines must be numbered.

Add the label for JAIL on the same line as the GOTO. This could represent a life sentence without chance of parole.

Python - 15*28 + 1*905 == 1325
Once="upon a time"
there=was="a";print"ce";he=wanted=to_marry=a=princess="but"
he="tried almost";all_princesses=but=they=were=not"real"and"";the="";print"ce"+wanted+a+'real';print"cess"
for princesss in`all_princesses`:
    the=princesss is not(`the`+`1`)

now=the;print"ce" is "sad"
he=was+"worried"+he+"would"+`not""`;ever=find=a;print"cess"
1=="evening"+a+"terrible storm occurred"
suddenly=a+princess+"appeared"+`but`+was+"soaked to"+`the`+"bone"
but=she=said=she=was=a=real=princess
`the`+"old queen";thought=we=will=soon=find=out;
but=she+said+"nothing"+but+"went to"+`the`+"bedroom where"+`the`+princess+"would sleep"and"put"+a+"pea beneath"+`20`+"mattresses";
the="";print"cess";having=slept=on=it=all=night=","+was+"asked how"+she+"slept";
while she in{"response","answered."}:
    print"ce,"+"my eyes"+were+"open"+all+night and "I"+was+"lying on"+a+"gigantic bowling ball.";

I=am="black"and"blue"+all+"over";"it" is "horrible"
this="confirmed"+she+was+a+real+princess
None==but+a+princess is "so sensitive"
print"ce" and she+"married"
for now in "good fortune"+he+"found"+a+real+princess:
    print"ce"and the+princess+"lived happily"+ever+"after"

My rendition of The printcess [sic] and the pea
Sadly, there is a syntax error on this line: I=am="black"and"blue"+all+"over";"it" is "horrible" and I can't seem to figure it out.

all is a python keyword, and there's no defined way to add a function/method to a string.  You can make it work by changing all to a string:  I=am="black"and"blue"+"all"+"over";"it" is "horrible"

Ruby, A LOT (44124 - 20 * 4 + 15 * 1 = 44504 points??)
"Short" story? Ha. So long that it's too long for a Stack Exchange answer! I had to remove about half of it because of the maximum character limit :(
Full code can be found here. It does not output anything. (Before, it for some reason crashed with a stack overflow, so I had to wrap it in begin ... rescue SystemStackError.)
Thanks, http://longestjokeintheworld.com!
def method_missing*a;end
class Module;def const_missing*a;end;end
(Kernel.methods+methods-[:eval,:object_id,:__send__]).each{|m|eval"def #{m}*a;end"}

begin talking using an interesting voice please to enhance the story
So theres a man crawling through the desert
Hed decided to try his SUV in_ a little bit of crosscountry travel had great fun zooming over the badlands and_ through the sand got lost hit a big rock and_ then_ he couldnt get it started again
There were no cell phone towers anywhere near so his cell phone was useless
He had no family his parents had died a few years before in_ an auto accident and_ his few friends had no idea he was out here
He stayed with the car for_ a day or_ so but his one bottle of water ran out
and_ he was getting thirsty
He thought maybe he knew the direction back now that hed paid attention to the sun and_ thought hed figured out which way was north so he decided to start walking
He figured he only had to go about some miles or_ so and_ hed be back to the small town hed gotten gas in_ last
He thinks about walking at night to avoid the heat and_ sun but based upon
how dark it actually was the night before and_ given that he has no flashlight hes afraid that hell break_ a leg or_ step on a rattlesnake
So
he puts on some sun block puts the rest in_ his pocket for_ reapplication
later brings an umbrella hed had in_ the back of the SUV with him to give
him a little shade pours the windshield wiper fluid into his water bottle
in_ case_ he gets that desperate brings his pocket knife in_ case_ he finds a cactus that looks like it might have water in_ it and_ heads out in_ the
direction he thinks is right
He walks for_ the entire day
By the end_ of the day hes really thirsty
Hes
been sweating all day and_ his lips are starting to crack
Hes reapplied the sunblock twice and_ tried to stay under the umbrella but he still feels sunburned
The windshield wiper fluid sloshing in_ the bottle in_ his pocket is really getting tempting now
He knows that its mainly water and_ some ethanol and_ coloring but he also knows that they add some kind of poison to it to keep people from drinking it
He wonders what the poison is and_
whether the poison would be worse than dying of thirst
He pushes on trying to get to that small town before dark
By the end_ of the day he starts getting worried
He figures hes been walking at least some miles an hour according to his watch for_ over some hours
That means that if_ his estimate was right that he should be close to the
town
But he doesnt recognize any of this
He had to cross a dry creek bed a mile or_ two back and_ he doesnt remember coming through it in_ the SUV
He figures that maybe he got his direction off just a little and_ that the dry creek bed was just off to one side of his path
He tells himself that hes close and_ that after dark hell start seeing the town lights over one of these hills and_ thatll be all he needs
As it gets dim enough that he starts stumbling over small rocks and_ things
he finds a spot and_ sits down to wait for_ full dark and_ the town lights
Full dark comes before he knows it
He must have dozed off
He stands back
up and_ turns all the way around
He sees nothing but stars
He wakes up the next_ morning feeling absolutely lousy
His eyes are gummy and_ his mouth and_ nose feel like theyre full of sand
He so thirsty that he cant even swallow
He barely got any sleep because it was so cold
Hed forgotten how cold it got at night in_ the desert and_ hadnt noticed it the night before because hed been in_ his car
He knows the Rule of Threes  three minutes without air three days without water three weeks without food  then_ you die
Some people can make it a little longer in_ the best situations
But the desert heat and_ having to walk and_ sweat isnt the best situation to be without water
He figures unless_ he finds water this is his last day
He rinses his mouth out with a little of the windshield wiper fluid
He waits a while_ after spitting that little bit out to see if_ his mouth goes numb or_ he feels dizzy or_ something
Has his mouth gone numb
Is it just in_
his mind
Hes not_ sure
Hell go a little farther and_ if_ he still doesnt
find water hell try drinking some of the fluid
Then he has to face his next_ harder question  which way does he go from here
Does he keep walking the same way he was yesterday assuming that he still knows which way that is or_ does he try a new direction
He has no idea what to do_
Looking at the hills and_ dunes around him he thinks he knows the direction he was heading before
Just going by a feeling he points himself somewhat to the left of that and_ starts walking
As he walks the day starts heating up
The desert too cold just a couple of hours before soon becomes an oven again
He sweats a little at first and_ then_ stops
He starts getting worried at that  when_ you stop sweating he knows that means youre in_ trouble  usually right before heat stroke
He decides that its time to try the windshield wiper fluid
He cant wait
any longer  if_ he passes out hes dead
He stops in_ the shade of a large
rock takes the bottle out opens it and_ takes a mouthful
He slowly
swallows it making it last as long as he can
It feels so good in_ his dry
and_ cracked throat that he doesnt even care about the nasty taste
He takes
another mouthful and_ makes it last too
Slowly he drinks half the bottle
He figures that since hes drinking it he might as well drink enough to
make some difference and_ keep himself from passing out
Hes quit worrying about the denaturing of the wiper fluid
If it kills him
it kills him  if_ he didnt drink it hed die anyway
Besides hes pretty
sure that whatever substance they denature the fluid with is just designed to make you sick  their way of keeping winos from buying cheap wiper fluid for_ the ethanol content
He can handle throwing up if_ it comes to that
He walks
He walks in_ the hot dry windless desert
Sand rocks hills
dunes the occasional scrawny cactus or_ dried bush
No sign of water
Sometimes hell see a little movement to one side or_ the other but whatever moved is usually gone before he can focus his eyes on it
Probably birds lizards or_ mice
Maybe snakes though they usually move more at night
Hes careful to stay away from the movements
After a while_ he begins to stagger
Hes not_ sure if_ its fatigue heat
stroke finally catching him or_ maybe he was wrong and_ the denaturing of the wiper fluid was worse than he thought
He tries to steady himself and_ keep going
After more walking he comes to a large stretch of sand
This is good
He
knows he passed over a stretch of sand in_ the SUV  he remembers doing
donuts in_ it
Or at least he thinks he remembers it  hes getting woozy
enough and_ tired enough that hes not_ sure what he remembers any more or_ if_
hes hallucinating
But he thinks he remembers it
So he heads off into it
trying to get to the other side hoping that it gets him closer to the town
He was heading for_ a town wasnt he
He thinks he was
He isnt sure any more
Hes not_ even sure how long hes been walking any more
Is it still morning
Or has it moved into afternoon and_ the sun is going down again
It must be afternoon  it seems like its been too long since he started out
He walks through the sand
After a while_ he comes to a big dune in_ the sand
This is bad
He doesnt
remember any dunes when_ driving over the sand in_ his SUV
Or at least he
doesnt think he remembers any
This is bad
But he has no other direction to go
Too late to turn back now
He figures
that hell get to the top of the dune and_ see if_ he can see anything from
there that helps him find the town
He keeps going up the dune
Halfway up he slips in_ the bad footing of the sand for_ the second or_ third
time and_ falls to his knees
He doesnt feel like getting back up  hell
just fall down again
So he keeps going up the dune on his hand and_ knees
While crawling if_ his throat werent so dry hed laugh
Hes finally
gotten to the hackneyed image of a man lost in_ the desert  crawling through
the sand on his hands and_ knees
If would be the perfect image he imagines if_ only his clothes were more ragged
The people crawling through the desert
in_ the cartoons always had ragged clothes
But his have lasted without any
rips so far
Somebody will probably find his dessicated corpse half buried in_ the sand years from now and_ his clothes will still be in_ fine shape
shake the sand out and_ a good wash and_ theyd be wearable again
He wishes his throat were wet enough to laugh
He coughs a little instead and_ it hurts
He finally makes it to the top of the sand dune
Now that hes at the top
he struggles a little but manages to stand up and_ look around
All he sees
is sand
Sand and_ more sand
Behind him about a mile away he thinks he
sees the rocky ground he left to head into this sand
Ahead of him more
dunes more sand
This isnt where he drove his SUV
This is Hell
Or close enough
Again he doesnt know what to do_
He decides to drink the rest of the wiper
fluid while_ figuring it out
He takes out the bottle and_ is removing the
cap when_ he glances to the side and_ sees something
Something in_ the sand
At the bottom of the dune off to the side he sees something strange
Its a flat area in_ the sand
He stops taking the cap of the bottle off and_ tries to look closer
The area seems to be circular
And its dark  darker than the sand
And there seems to be something in_ the middle of it but he cant tell what it is
He looks as hard as he can and_ still can tell from
here
Hes going to have to go down there and_ look
He puts the bottle back in_ his pocket and_ starts to stumble down the dune
After a few steps he realizes that hes in_ trouble  hes not_ going to be able to keep his balance
After a couple of more sliding tottering steps he falls and_ starts to roll down the dune
The sand it so hot when_ his body hits it that for_ a minute he thinks hes caught fire on the way down  like a movie car wreck flashing into flames as it goes over the cliff before it ever even hits the ground
He closes his eyes and_ mouth covers his face with his hands and_ waits to stop rolling
He stops at the bottom of the dune
After a minute or_ two he finds enough
energy to try to sit up and_ get the sand out of his face and_ clothes
When
he clears his eyes enough he looks around to make sure that the dark spot
in_ the sand it still there and_ he hadnt just imagined it
So seeing the large flat dark spot on the sand is still there he begins
to crawl towards it
Hed get up and_ walk towards it but he doesnt seem to
have the energy to get up and_ walk right now
He must be in_ the final stages
of dehydration he figures as he crawls
If this place in_ the sand doesnt
have water hell likely never make it anywhere else_
This is his last
chance
He gets closer and_ closer but still cant see whats in_ the middle of the
dark area
His eyes wont quite focus any more for_ some reason
And lifting
his head up to look takes so much effort that he gives up trying
He just
keeps crawling
Finally he reaches the area hed seen from the dune
It takes him a minute of crawling on it before he realizes that hes no longer on sand  hes now crawling on some kind of dark stone
Stone with some kind of marking on it  a pattern cut into the stone
Hes too tired to stand up and_ try to see what the pattern is  so he just keeps crawling
He crawls towards the center
where his blurry eyes still see something in_ the middle of the dark stone
area
His mind detached in_ a strange way notes that either his hands and_ knees are so burnt by the sand that they no longer feel pain or_ that this dark
stone in_ the middle of a burning desert with a pounding punishing sun
overhead doesnt seem to be hot
It almost feels cool
He considers lying
down on the nice cool surface
Cool dark stone
Not a good sign
He must be hallucinating this
Hes
probably in_ the middle of a patch of sand already lying face down and_
dying and_ just imagining this whole thing
A desert mirage
Soon the
beautiful women carrying pitchers of water will come up and_ start giving him
a drink
Then hell know hes gone
He decides against laying down on the cool stone
If hes going to die here
in_ the middle of this hallucination he at least wants to see whats in_ the
center before he goes
He keeps crawling
Its the third time that he hears the voice before he realizes what hes
hearing
He would swear that someone just said Greetings traveler
You do_
not_ look well
Do you hear me

He stops crawling
He tries to look up from where he is on his hands and_
knees but its too much effort to lift his head
So he tries something
different  he leans back and_ tries to sit up on the stone
After a few
seconds he catches his balance avoids falling on his face sits up and_
tries to focus his eyes
Blurry
He rubs his eyes with the back of his hands
and_ tries again
Better this time
Yep
He can see
Hes sitting in_ the middle of a large flat dark expanse
of stone
Directly next_ to him about three feet away is a white post or_
pole about two inches in_ diameter and_ sticking up about four or_ five feet
out of the stone at an angle
And wrapped around this white rod tail with rattle on it hovering and_
seeming to be ready to start rattling is what must be a fifteen foot long
desert diamondback rattlesnake looking directly at him
He stares at the snake in_ shock
He doesnt have the energy to get up and_
run away
He doesnt even have the energy to crawl away
This is it his
final resting place
No matter what happens hes not_ going to be able to
move from this spot
Well at least dying of a bite from this monster should be quicker than
dying of thirst
Hell face his end_ like a man
He struggles to sit up a
little straighter
The snake keeps watching him
He lifts one hand and_ waves
it in_ the snakes direction feebly
The snake watches the hand for_ a
moment then_ goes back to watching the man looking into his eyes
Hmmm
Maybe the snake had no interest in_ biting him
It hadnt rattled yet
that was a good sign
Maybe he wasnt going to die of snake bite after all
He then_ remembers that hed looked up when_ hed reached the center here
because he thought hed heard a voice
He was still very woozy  he was
likely to pass out soon the sun still beat down on him even though he was
now on cool stone
He still didnt have anything to drink
But maybe he had
actually heard a voice
This stone didnt look natural
Nor did that white
post sticking up out of the stone
Someone had to have built this
Maybe
they were still nearby
Maybe that was who talked to him
Maybe this snake
was even their pet and_ thats why it wasnt biting
He tries to clear his throat to say Hello but his throat is too dry
All
that comes out is a coughing or_ wheezing sound
There is no way hes going
to be able to talk without something to drink
He feels his pocket and_ the
bottle with the wiper fluid is still there
He shakily pulls the bottle out
almost losing his balance and_ falling on his back in_ the process
This isnt
good
He doesnt have much time left by his reckoning before he passes
out
He gets the lid off of the bottle manages to get the bottle to his lips
and_ pours some of the fluid into his mouth
He sloshes it around and_ then_
swallows it
He coughs a little
His throat feels better
Maybe he can talk
now
He tries again
Ignoring the snake he turns to look around him hoping to
spot the owner of this place and_ croaks out Hello
Is there anyone here

He hears from his side Greetings
What is it that you want

He turns his head back towards the snake
Thats where the sound had seemed
to come from
The only thing he can think of is that there must be a
speaker hidden under the snake or_ maybe built into that post
He decides
to try asking for_ help
Please he croaks again suddenly feeling dizzy Id love to not_ be
thirsty any more
Ive been a long time without water
Can you help me

Looking in_ the direction of the snake hoping to see where the voice was
coming from this time he is shocked to see the snake rear back open its
mouth and_ speak
He hears it say as the dizziness overtakes him and_ he
falls forward face first on the stone Very well
Coming up

A piercing pain shoots through his shoulder
Suddenly he is awake
He sits
up and_ grabs his shoulder wincing at the throbbing pain
Hes momentarily
disoriented as he looks around and_ then_ he remembers  the crawl across the
sand the dark area of stone the snake
He sees the snake still wrapped
around the tilted white post still looking at him
He reaches up and_ feels his shoulder where it hurts
It feels slightly wet
He pulls his fingers away and_ looks at them  blood
He feels his shoulder
again  his shirt has what feels like two holes in_ it  two puncture holes
they match up with the two aching spots of pain on his shoulder
He had been
bitten
By the snake
Itll feel better in_ a minute He looks up  its the snake talking
He
hadnt dreamed it
Suddenly he notices  hes not_ dizzy any more
And more
importantly hes not_ thirsty any more  at all
Have I died
Is this the afterlife
Why are you biting me in_ the
afterlife

Sorry about that but I had to bite you says the snake
Thats the way I
work
It all comes through the bite
Think of it as natural medicine

You bit me to help me
Why arent I thirsty any more
Did you give me a
drink before you bit me
How did I drink enough while_ unconscious to not_ be
thirsty any more
I havent had a drink for_ over two days
Well except for_
the windshield wiper fluid
hold it how in_ the world does a snake talk
Are you real
Are you some sort of Disney animation

No says the snake Im real
As real as you or_ anyone is anyway
I
didnt give you a drink
I bit you
Thats how it works  its what I do_
I
bite
I dont have hands to give you a drink even if_ I had water just
sitting around here

The man sat stunned for_ a minute
Here he was sitting in_ the middle of the
desert on some strange stone that should be hot but wasnt talking to a
snake that could talk back and_ had just bitten him
And he felt better
Not
great  he was still starving and_ exhausted but much better  he was no
longer thirsty
He had started to sweat again but only slightly
He felt
hot in_ this sun but it was starting to get lower in_ the sky and_ the cool
stone beneath him was a relief he could notice now that he was no longer
dying of thirst
I might suggest that we take care of that methanol you now have in_ your
system with the next_ request continued the snake
I can guess why you
drank it but Im not_ sure how much you drank or_ how much methanol was left
in_ the wiper fluid
That stuff is nasty
Itll make you go blind in_ a day or_
two if_ you drank enough of it

Ummm nnext request said the man
He put his hand back on his hurting
shoulder and_ backed away from the snake a little
Thats the way it works
If you like that is explained the snake
You
get three requests
Call them wishes if_ you wish The snake grinned at his
own joke and_ the man drew back a little further from the show of fangs
But there are rules the snake continued
The first request is free
The
second requires an agreement of secrecy
The third requires the binding of
responsibility The snake looks at the man seriously
By the way the snake says suddenly my name is Nathan
Old Nathan
Samuel used to call me
He gave me the name
Before that most of the Bound
used to just call me Snake
But that got old and_ Samuel wouldnt stand
for_ it
He said that anything that could talk needed a name
He was big into
names
You can call me Nate if_ you wish Again the snake grinned
Sorry
if_ I dont offer to shake but I think you can understand  my shake sounds
somewhat threatening The snake give his rattle a little shake
Umm my name is Jack said the man trying to absorb all of this
Jack
Samson
Can I ask you a question Jack says suddenly
What happened to the
poisonumm in_ your bite
Why arent I dying now
How did you do_ that
What do_ you mean by thats how you work

Thats more than one question grins Nate
But Ill still try to answer
all of them
First yes you can ask me a question The snakes grin gets
wider
Second the poison is in_ you
It changed you
You now no longer need
to drink
Thats what you asked for_
Or well technically you asked to not_
be thirsty any more  but any more is such a vague term
I decided to make
it permanent  now as long as you live you shouldnt need to drink much at
all
Your body will conserve water very efficiently
You should be able to
get enough just from the food you eat  much like a creature of the desert
Youve been changed
For the third question Nate continues you are still dying
Besides the
effects of that methanol in_ your system youre a man  and_ men are mortal
In your current state I give you no more than about another some years
Assuming you get out of this desert alive that is Nate seemed vastly
amused at his own humor and_ continued his wide grin
As for_ the fourth question Nate said looking more serious as far as Jack
could tell as Jack was just now working on his ability to read
talkingsnake emotions from snake facial features first you have to agree
to make a second request and_ become bound by the secrecy or_ I cant tell
you

Wait joked Jack isnt this where you say you could tell me but youd
have to kill me

I thought that was implied Nate continued to look serious
Ummmyeah Jack leaned back a little as he remembered again that he was
talking to a fifteen foot poisonous reptile with a reputation for_ having a
nasty temper
So what is this Bound by Secrecy stuff and_ can you really
stop the effects of the methanol Jack thought for_ a second
And what do_
you mean methanol anyway
I thought these days they use ethanol in_ wiper
fluid and_ just denature it

They may I dont really know said Nate
I havent gotten out in_ a
while_
Maybe they do_
All I know is that I smell methanol on your breath and_
on that bottle in_ your pocket
And the blue color of the liquid when_ you
pulled it out to drink some let me guess that it was wiper fluid
I assume
that they still color wiper fluid blue

Yeah they do_ said Jack
I figured replied Nate
As for_ being bound by secrecy  with the
fulfillment of your next_ request you will be bound to say nothing about me
this place or_ any of the information I will tell you after that when_ you
decide to go back out to your kind
You wont be allowed to talk about me
write about me use sign language charades or_ even act in_ a way that will
lead someone to guess correctly about me
Youll be bound to secrecy
Of
course Ill also ask you to promise not_ to give me away and_ as Im
guessing that youre a man of your word youll never test the binding
anyway so you wont notice Nate said the last part with utter confidence
Jack who had always prided himself on being a man of his word felt a
little nervous at this
Ummm hey Nate who are you
How did you know
that
Are you umm omniscient or_ something

Well Jack said Nate sadly I cant tell you that unless_ you make the
second request Nate looked away for_ a minute then_ looked back
Umm well ok said Jack what is this about a second request
What can I
ask for_
Are you allowed to tell me that

Sure said Nate brightening
Youre allowed to ask for_ changes
Changes
to yourself
Theyre like wishes but they can only affect you
Oh and_
before you ask I cant give you immortality
Or omniscience
Or
omnipresence for_ that matter
Though I might be able to make you gaseous
and_ yet remain alive and_ then_ you could spread through the atmosphere and_
sort of be omnipresent
But what good would that be  you still wouldnt be
omniscient and_ thus still could only focus on one thing at a time
Not very
useful at least in_ my opinion Nate stopped when_ he realized that Jack was
staring at him
Well anyway continued Nate Id probably suggest giving you permanent
good health
It would negate the methanol now in_ your system youd be
immune to most poisons and_ diseases and_ youd tend to live a very long
time barring accident of course

... story goes on for much longer ...
rescue SystemStackError;end

I'm wondering, "Strings, comments, or anything that allows free text to be added to the code, may be used, but for at most 3 words per string" - Is this all part of a Ruby script, or is it just free text like a triple-quote string or heredoc? Because if it is not all code, this rule would disqualify it.

@joeytje50 It is all code, not a string, or heredoc. method_missing is a special method called when you try to call a method that doesn't exist, so for example, def method_missing*a;end; this is valid code works.

So basically what you are saying this does allow "free text to be added to the code"? In other words, you can add basically any text you'd like? It looks very much like you can just type anything you want there, except for a few reserved keywords, to which you just appended an underscore.

@joeytje50 No, for example none of the following work: this doesn't work, !@#$%^&*(, hello there, I am Doorknob! how are you?, 123 456, this is one string for which it fails, in this string it fails too, etc.

Okay so basically it's the same as what would happen if I would just place almost anything inside a JavaScript try{ ... }catch(e){} block. What you've done here is just finding a way to be able to type any word character you like, and that is just using free text, which is not allowed.

@joey Wrong, this is actually valid code (no syntax errors or anything) and is fairly limited as to what text you can place in it.... It's simply a bunch of method calls in sequence (all of which happen to do nothing, but that's besides the point).

@joeytje50 no you can't. try { foo bar } catch (err) { } is a syntax error.

So make that try{[foo, bar]}catch(err){} and you can add any valid identifier word in that list. And since interpunction doesn't count… I'm not sure whether I consider this a problem with this answer or with the challenge itself, though.

I don't think that writing code that doesn't work/crashes then wrapping it in an exception handler is in the spirit of things.    try: once up on a time blah blah except: print "tada, I win!".

The joke you linked was so long that by the time I finished reading it, I'd forgotten how I'd gotten to that page. Also, I ended up in the first group.

Javascript:
2 * 'households, both alike' in (dignity={})
'In fair Verona', where = we = lay = our = scene ={}
Where = civil= 'blood',  makes= civil ||hands ||unclean
From= forth = the =fatal =loins =of = 'these two foes';
A = pair=2; of["star-cross'd lovers"]; take = 2 || their || life

If you could do this without the '||', I would upvote.  Imho logic statements are hard to ignore when directly interpreting.  I understand that this answer fits the spirit of the question well, I just happen to be picky about Shakespeare :)

Also, please calculate points.

6502 Assembly Language
A story about a girl named Tya.
    TYA
    AND #1
    TAX
MAN:
    JMP *+4
A:
    BIT #4
THEIR:
.byte "DONKEY"
    EOR .byte "."

JavaScript: 7*15 + 127*1 = 232 points
company = 'big'
for (employee in company) {
    if (/quality/.test(employee) == 'bad') {
        employee = function janitor() {
            return 'less money'
        }
    } else {
        employee = function boss() {
            return 'money'
        }
    }
}

PHP
Have fun:)
<?php

goto:bar;

bar:
$notdrunk = 0
while ($notdrunk <= rand(5, 60)) {

    drink(beer);
    $notdrunk++;
}

if ($notdrunk >= rand(10, 59)) {

goto home;

}

home:

$vomit = true;

if ($notdrunk > 50) {

die();

}

?>

Chinese
This ancient text may have originated around 2014 AD:
了一人说你于一嘁力

A translation to English:

Knowingly, a man persuaded you in one whispering sound power...

How is this programming code?

@joeytje50 http://esolangs.org/wiki/Chinese

Well either way, if I cite my original post: "If the piece of code uses words that are not English, it's not valid". Last time I checked, Chinese was not English. (except for the word "chinese", which is of course an English word...)

@joeytje50 I've already provided an English translation.

yeah but I assume the English translation is not valid code itself. Only the Chinese code is valid code, and that's not English.

@joeytje50 You could also compile the English translation, but it would prompt you for input and then output it three times (a lot different).

Python, 1*94 + 12*15 = 274
I counted one for =, but didn't count the extra f in def finitely(). Also, the function is infinitely recursive, causing the call stack to be full of True "love".
def finitely(one=True):
    if all([any([one])is"loving"or True]):return"love"in finitely()
    else:return"sadness"
"love"in finitely()

English:
Definitely one (equals) True. If all anyone is loving or True, return love infinitely, else return sadness. Love infinitely.

+1 for "True love". This is one of the more creative ones ans I'm surpirsed it only has 2 upvotes

Delphi
I'm new and I don't really understand the scoring. So if someone can help me with that, it would be great :)
procedure Life;
var alive, fullbladder, fullstomach: boolean;
  bladder, stomach, human: tobject;
  timer:TTimer;
  procedure sleepRecommended;begin sleep(((8*60)*60)*1000) {hours to ms} end;
  procedure checkNeeds(sender:tobject); begin if fullbladder then bladder.empty; if fullstomach then stomach.empty; end;
  procedure GoToWork;begin human.PretendToWorkAndGoOnCodeGolfInstead; end;
  procedure GoHome;begin human.celebrate; end;
begin
  timer:=ttimer.create;timer.interval := (60*60)*1000; timer.OnTimer := checkNeeds;

  while alive do
  begin
    sleepRecommended;
    timer.Enabled := true;
    human.eat;
    goToWork;
    GoHome;
    human.Eat;
  end;

I'm a bit late to this, but every time I use firstChild in
Javascript
I think:
function Rumpelstiltskin(straw){
    straw = straw.replace(straw, "gold");
    if(!(knowName=="Rumpelstiltskin")){
         document.getElementById('millersDaughter').deleteChild(document.getElementById('millersDaughter').firstChild);//Stories are documents and characters are elements of the story.
    }else{
         return "angry";
    }
}

Points:
2 undefined (knowName and the html node millersDaughter)
7 built in keywords (function, if, document.getElementById('millersDaughter'), deleteChild(...),firstChild,else,return)
I don't know how to count letters, every letter, letters in strings?  Tell me.
points = 95 + letters

Windows Command Script - 720
Calculated with 210 + 34*15
Warning: this may or may not make any sense :)
IF "%time%"=="15:00" GOTO :workplace
:workplace
START SHIFT
RECOVER TASKLIST | FIND "todo" | SORT %priority% > tasks
FOR /f %%t IN (tasks) DO (
    SET %%t=Done! | VERIFY
    IF "%TIME%"=="17:00" START BREAK
    IF "%TIME%"=="19:00" START BREAK
    IF "%TIME%"=="21:00" START BREAK
    IF "%RANDOM:~,1%"=="1" START BREAK
    IF "%TIME%"=="23:00" EXIT SHIFT
)

Fortran 95
Not really a story, but a short poem. Just sharing it for fun:
logical :: I, u = .TRUE.
do while (I); write(*,*) aPoem, 4, u;
stop; I = .FALSE.;
end do; end ! Adieu!

Considering the sign = as the verb to be, it reads as:
Logical eye, you are true
Do while I write a poem for you
Stop, I am false...
End, do end! Adieu!

Google Sheets, 72 \w characters + 5 * 15 reserved functions = 147
Make named ranges anywhere:

Call one "Birth"
Call one "Death"

=IF(OR(ISBETWEEN("meaning",Birth,Death),NOT(ISBETWEEN("meaning",Birth,Death))),"One dies anyway") or
=IF(
  OR(
    ISBETWEEN("meaning",Birth,Death),
    NOT(ISBETWEEN("meaning",Birth,Death))
  ),"One dies anyway"
)

If "meaning" between Birth and Death, or not "meaning" between Birth and Death, One dies anyway.

I also like this one:
="My grandpa's deck "&IF(COUNTIF(GrandpasDeck,"the unstoppable Exodia")=1,"has no","has")&" pathetic cards"

Now that I think about it, since NOT is a reserved word, this could be used to get arbitrarily many points.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Arbitrarily Shift Bit Array Represented As Array of 32-bit Integers
Given an array of 32-bit integers which represent a bit array, shift the values by a specified amount in either direction. Positive shifts go to the left and negative values go to the right. This is a bit array so bits should wrap across values in the array.
For example, given the following data:
a[2] = 11110000 11110000 11110000 11110000
a[1] = 11110000 11110000 11110000 11110000
a[0] = 11110000 11110000 11110000 11110000 <-- 0th bit

Shifting the original by 2 should result in:
a[3] = 00000000 00000000 00000000 00000011
a[2] = 11000011 11000011 11000011 11000011
a[1] = 11000011 11000011 11000011 11000011
a[0] = 11000011 11000011 11000011 11000000 <-- 0th bit

Shifting the original by -3 should result in:
a[2] = 00011110 00011110 00011110 00011110
a[1] = 00011110 00011110 00011110 00011110
a[0] = 00011110 00011110 00011110 00011110 <-- 0th bit

There's no restriction on shift amount (i.e., can be greater than 32) so be mindful of where your bits are going!
Here's the method signature:
int[] bitArrayShift(int[] bits, int shift)

Implementations should:

Return an array whose contents represented the original bit array's contents shifted by the supplied number.
Return an array whose size is the minimum amount required to hold the values after the shift. You should not wrap back around to the 0th bit but rather expand to hold it.
Not mutate the input array. It should be treated as being passed by reference (therefore having mutable contents). Basically, don't put any new values at any position in the input array.

The following assertion should always return true for any value of 'bit' and 'shift':
// Given 'originalBits' as incoming bit array.
// Given 'bit' as a number between [0, originalBits.length * 32).
// Given 'shift' as any integer value.

// Get the value in the array at the index of 'bit'
bool original = ((originalBits[bit / 32] & (1 << (bit % 32)) != 0
// Shift the original bits by the specified 'shift'
int[] shiftedBits = bitArrayShift(originalBits, shift)
// Offset the original 'bit' by the specified 'shift'
int shiftedBit = bit + shift
// Get the value in the shifted array at the index of 'shiftedBit'
bool shifted = ((shiftedBits[shiftedBit / 32] & (1 << (shiftedBit % 32)) != 0
// They should be equal.
assert original == shifted

Smallest character count wins. Count method body contents ONLY sans leading and trailing whitespace. That is, the method declaration up to and including the block start (if any) and ending exclusively at the block end (if any).
E.g., for Java:
public static int[] shiftBitArray(int[] bits, int shift) {
  << COUNT THIS ONLY >>>
}

"therefore having mutable contents". What exactly does this mean? Did you mean immutable?

Should leading zeroes be stripped (ie is [1][0] an allowed result instead of just [1]?

Your example of shifting the original array by 2 does not wrap across values in the array.  It augments the array thereby changing its dimensions. Isn't this incorrect?

The question does not completely define how wrapping occurs in the negative direction. What is the result of shifting by -5? Assuming the intention is to prepend a new index at the beginning, similarly to the second example which appended a new index.

Java 306
public static int[] shiftBitArray(int[] bits, int shift) {
    BigInteger r = BigInteger.ZERO;
    for (int i = bits.length - 1; i >= 0;) r = BigInteger.valueOf(0xffffffffL & bits[i--]).or(r.shiftLeft(32));
    r = r.shiftLeft(shift);
    int[] a = new int[(int) Math.ceil(r.bitLength() / 32d)];
    for (int i = 0; i < a.length; r = r.shiftRight(32)) a[i++] = r.intValue();
    return a;
}

Java 500
public static int[] shiftBitArray(int[] bits, int shift) {
  int t = 32, w;
  long x = 1L << t;
  String s = "", z = Long.toString(x, t / 2).substring(1); z += z; z += z;
  for (int i : bits) s = Long.toString(i & x - 1 | x, 2).substring(1) + s;
  for (; shift > 0; shift -= t) s += z;
  s = -shift > s.length() ? z : z.substring(shift & t - 1) + s.substring(0, s.length() + shift);
  while (s.startsWith(z)) s = s.substring(t);
  int[] r = new int[(w = s.length()) / t];
  for (int j = 0; j < r.length; j++) r[j] = (int) Long.parseLong(s.substring(w -= t, w + t), 2);
  return r;
}

You can save ~100 characters by removing whitespace: int t=32,w;long x=1L<<t;String s="",z=Long.toString(x,t/2).substring(1);z+=z;z+=z;for(int i:bits)s=Long.toString(i&x-1|x,2).substring(1)+s;for(;shift>0;shift-=t)s+=z;s=-shift>s.length()?z:z.substring(shift&t-1)+s.substring(0,s.length()+shift);while (s.startsWith(z))s=s.substring(t);int[]r=new int[(w=s.length())/t];for (int j=0;j<r.length;j++)r[j]=(int)Long.parseLong(s.substring(w-=t,w+t),2);return r;

Some other big character savers: change the first line to int t=32,w,d=shift,b[]=bits; and refer to shift as d and bits as b. Rather than using Long.toString(), use x.toString(). Rather than s.length() twice, use int l=s.length() and refer to s.length() as l. Rather than z+=z;z+=z, use z+=z+z;. Additionally, your 1L at the beginning can be just 1. You might also considering substituting the constant values instead of t, since t is never assigned anything other than 32

Via my suggestions(minus some that actually harm), I got it down to 376 characters. Might be able to remove the int at the beginning altogether and simply move the long in place of the int, but I haven't checked it: int t=32,w,d=shift;long x=1<<t;String s="",z=x.toString(x,16).substring(1);z+=z+z+z;for(int i:bits)s=x.toString(i&x-1|x,2).substring(1)+s;for(;d>0;d-=t)s+=z;int l=s.length();s=-d>l?z:z.substring(d&31)+s.substring(0,l+d);while (s.startsWith(z))s=s.substring(t);int[]r=new int[(w=s.length())/t];for(int j=0;j<r.length;j++)r[j]=(int)x.parseLong(s.substring(w-=t,w+t),2);return r;

Yep. I went for cuteness rather than compactness for a few things. For example, Long.toString(x,t/2).substring(1) is a verbose way of saying "00000000".

Because this is [tag:code-golf], go for compact.

Can do 350 with great sacrifice to cuteness.
int t=32,w=shift,a,y;long x=1L<<t;String s="",z="00000000";z+=z+z+z;for(int i:bits)s=Long.toString(i&x-1|x,2).substring(1)+s;for(;w>0;w-=t)s+=z;y=s.length();for(s=-w>y?z:z.substring(w&31)+s.substring(0,y+w);s.startsWith(z);)s=s.substring(t);w=s.length();a=w/t;int[] r=new int[a];for(y=0;y<a;)r[y++]=(int) parseLong(s.substring(w-=t,w+t),2);return r;

Python (181)
def bitArrayShift(b, s):
 a=''.join(bin(x)[2:].zfill(32)for x in b)
 a=(a+'0'*s if s>0 else a[:s]).lstrip('0')
 return[int(a[b:c],2)for b,c in[(x-32if x>31 else 0,x)for x in range(len(a),0,-32)]][::-1]or[0]

It basically just turns the array into a single string of bits, rotates by string manipulation and converts it back to integers.

GolfScript, 32 characters
{{2.5??base}:^~2@.0>{?*}{~)?/}if^}:S;

(Character count without {}:S; as specified in the question) Defines a function S with works on the stack (there is no such thing like call by reference for stack-based languages). Usage:
2 [4042322160 4042322160 4042322160] S p    # => [3 3284386755 3284386755 3284386752]
-3 [4042322160 4042322160 4042322160] S p   # => [505290270 505290270 505290270]

6 characters more if one prefers lowest-word first.

J (32)
shift=:4 :'#.|."1|._32>\|.({.~x+#);y#:~32#2'

(Not counting the shift=:4 :'...'.)
Test:
   9!:11[20 NB. set print precision high enough for the large numbers to show

   shift=:4 :'#.|."1|._32>\|.({.~x+#);y#:~32#2'
   2 shift 4042322160 4042322160 4042322160
3 3284386755 3284386755 3284386752
   _3 shift 4042322160 4042322160 4042322160
505290270 505290270 505290270

Explanation:

y#:~32#2: encode each value in y as 32 bits, giving a matrix.
;: join the rows of the matrix together, giving a list of bits.
{.~x+#: take the first x+length elements from the list, padding with zeroes. (so zeroes get added to the end if x is positive, dropped if x is negative.)
|.: flip the list (to make partitioning easier)
_32>\: group the bits into groups of 32, padding with zeroes. (the extra zeroes go on the end, which is why the list had to be flipped.)
|."1|.: flip the resulting matrix both horizontally and vertically, putting the bits back in the right order.
#.: decode each line of bits back into an integer.

Scala 324
def shiftBitArray(bits: Array[Int], shift: Int): Array[Int] = {
    def f(i:Array[Int])=i.map(x => String.format("%32s",x.toBinaryString).replace(' ','0')).mkString
    def g(x:Int)=List.fill(x)("0").mkString
    def h(s:String)=s.grouped(32).toArray.map(x=>java.lang.Long.parseLong(x, 2).toInt)
    val s=shift
    if (s<=0)h(g(-1*s)+f(bits).dropRight(-1*s))
    else h(g(32-s)+f(bits)+g(s))
}

APL, 49
shift←{⌽2⊥⍉(c,32)⍴⌽(32×c←⌈n÷32)↑⌽(n←⍺+⍴v)↑v←∊(32/2)∘⊤¨⌽⍵}

Could probably be golfed some more. The entire (32×⌈n÷32)↑ and the following reshaping is probably overkill.
Examples
      0 shift 3/4042322160
4042322160 4042322160 4042322160
      2 shift 3/4042322160
3284386752 3284386755 3284386755 3
      ¯3 shift 3/4042322160
505290270 505290270 505290270

Golfscript (57)
A first draft, slightly longer than APL but all ascii. Probably possible to golf a little more.
~.~)@2 32?:q;{\q*+}*@{2*}*\{2/}*{q%1$}{;q/}/\;-1%.![0]*+p

Mathematica 57
In infix form:
a_~f~n_ := Flatten@a~RotateLeft~n~ArrayReshape~Dimensions@a

In standard prefix form:
f[a_,n_]:=ArrayReshape[RotateLeft[Flatten[a], n], Dimensions[a]]

where a is the array and n is the shift parameter.

Flatten transforms a into a list of integers.
RotateLeft[list,n] rotates list n places leftward (if >= 0) or rightward (if n<0).
Dimensions obtains the dimensions of the input matrix.
ArrayReshape[list, Dimensions[a]] transforms list into an array with the dimensions of the original matrix, a.
RotateRight[a,n] has the same effect as RotateLeft[a,-n] for all integers n.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
A program that deletes itself
If a compiled language is used, the program must delete the compiled executable (but need not delete the source file). If an interpreted language is used, the program must delete the source file.
My opening bid:
Python (29 characters)
import os;os.remove(__file__)

Edit: to prevent solutions like rm -rf /, the program must not delete anything except the executable or source file.

html,body{margin:0;padding:0;height:100%;overflow:hidden}
 <iframe src="https://xmikee1.github.io/ppcg-leaderboard/?id=19355" width="100%" height="100%" style="border:none;">Oops, your browser is too old to view this content! Please upgrade to a newer version of your browser that supports HTML5.</iframe>

possible duplicate of Write a program that deletes itself

@JanDvorak That question was stricter, requiring a .exe file. This is more lax.

Hmm... what if I vote to close in the opposite direction, then?

@JanDvorak That would be excellent! And a first, an old question closed in favour of a newer one.

Vote cast. Now let's wait and see :-)

code-golf, not [tag:popularity-contest]? Aww.

@Quincunx I don't believe in popularity contests. Real code is not first validated on its elegance, but its correctness.

Obviously relevant: http://youtu.be/Z86V_ICUCD4

@JanDvorak Okay, so prefer the trivial question where interpreted languages can do it with no problem.

@EMBLEM I think you may be on the wrong forum. Also, I disagree that  this is a duplicate. The linked problem specifically asks for a windows executable, which is a different problem statement entirely.

you have to actually delete the file, truncating it doesn't count?

You might as well use a newline instead of a semicolon for the python answer. It's the same number of bytes and it's more readable.

May the submission be a function or does it have to be a full program?

Bash script (7 characters, 7 bytes)
rm "$0"

Doesn't work if the script file name contains spaces.

Good eye! I've updated the script to work with files with spaces in them. Only adds two more characters. Thanks!

Does this work if the file name contains double quotes?

@JanDvorak: Yes. By execution that would be e.g. ./the\"program, ./'the"program', './tha"program'. All works as intended. (Quotes needs to be escaped or enclosed in single quotes on call.) Would also work on files containing names with newline etc.

Bad luck with the quotation marks, gave my answer the 1 byte edge.

This tries to remove /bin/bash which is denied!

@bacchusbeale just tested on Linux Mint 17.2 64-bit and it deleted itself correctly, whether called directly à la ./scriptname, or called like bash scriptname.  How did you get it to try to delete /bin/bash ?

@StéphaneGourichon Probably 'cause he's running rm "$0" in the Bash shell instead of in a batch script. You should edit the header like so: # Bash script, 7 bytes

@MDXF I see a variant : rm "$0" yields rm: cannot remove 'bash': No such file or directory.

Unix? (9):
#!/bin/rm

A classic. Uses rm as interpreter, for instant self-deletion. Not the very shortest though.

Or if you want to be cheaty: a 0-byte rm program.

The #! line isn't counted in score.

@Phoenix: It is if it's unusual for the language you're using; only completely standard #! lines that just give the name of the language's default interpreter count as zero. This is a very unusual #! line as far as Bash goes. (Not that this actually works in Bash, although there are other languages where it works.)

This isn't actually a Bash program (if you run it explicitly using bash, it won't delete anything). It's a UNIX/Linux executable. (It also works in Perl, which emulates UNIX/Linux's handling of #! lines so that it can be used to run shellscripts on platforms that can't do it natively.)

@Pavel Hmm... 0 bytes?

Batch - 6 bytes
Del %0

Pretty simple. Note: Works even if the name contains spaces.

Only if the file name doesn't have spaces.

@impinball, Sorry?

Just pointing out a little bug. If you specify DOS, it isn't, but it'll break pretty easily in Windows (ex. in Program Files). No apologies needed.

My bad...it's okay. I misremembered that quotes aren't needed in this case because they are automatically included in this.

All good. Adding tilde removes surrounding quotes. %~0.

I know. That's what I realized after I commented.

doesn't work if invoked without the suffix, though - "test" as opposed to "test.bat"

Ruby, 14 characters
File.delete $0

$0 is a special global variable that contains the name of the currently running script.

I'm pretty sure you can drop the space.

This is why I made my version of the question much more strict. Interpreted languages can do it with no problem. The idea is that a natively running application can't just pull the rug out from underneath itself

BASIC-80 / BASICA / GW-BASIC / IBM BASIC / Commodore 64 BASIC / Vintage BASIC / Commodore LCD BASIC / Atari BASIC *
5 bytes
1 NEW

Well, that's about as simple as it gets. NEW creates a new program, so putting this anywhere in your program will delete it.
Proof of concept on IBM BASIC (putting  NEW on line 40 for clarity):

* Yeah, I listed every old BASIC version I've tested this in (or pretty much ever used)

+1, There is something rather poetic about this.  Existential even.

PHP, 17 characters
unlink(__FILE__);

I'm not sure why anyone would downvote this; it's perfectly valid. You may want to include an open tag, though <?unlink(__FILE__);

This PHP program prints unlink(__FILE__);. It does not delete the file.

@rightfold it works as described if you include an opening tag, which I would have assumed to add

PowerShell (32)
del $MyInvocation.MyCommand.Name

Perl 5 (8 characters)
unlink$0

$0 is the script name, and unlink removes it. Normally, you'd at least add a space in between for readability.

C# (112)
Process.Start("cmd.exe","/C choice /C Y /N /D Y /T 3 & Del " + Application.ExecutablePath);
Application.Exit();

Shamelessly stolen from http://www.codeproject.com/Articles/31454/How-To-Make-Your-Application-Delete-Itself-Immedia

R, 26 characters
unlink(sys.frame(1)$ofile)

k (8)
~-1!.z.f

Or the q equivalent for 14:
hdel hsym .z.f

Python, 18
open(__file__,'w')

Opens itsself in write-only mode, erasing itself.

This truncates the file. It does not delete it.

Node.js - 22 chars
fs.unlink(__filename);

Julia, 13 bytes
rm(@__FILE__)

Simple.  But longer. :P

Vitsy + bash, 8 bytes
iG' mr',

iG       Get the name of the use declaration at the top item (-1) (returns the current one)
  ' mr'  Concatenate "rm " to the front of it.
       , Execute via shell.

Mathematica, 29 bytes
DeleteFile@NotebookFileName[]

C, 32 bytes
main(c,v)char**v;{remove(v[0]);}

Missing }s are allowed in C? Wow!

Nope, just a typo!  My character count included the closing } but I apparently copy/pasted the snippet incorrectly.  Thanks for pointing it out!

Well, since the anonymous downvoter doesn't feel like leaving a comment or retracting their vote, I have deleted my answer, which I based off of yours. You can golf this down to 29 bytes: main(c,v)int**v;{remove(*v);}

@MDXF I am not sure if changing char** to int** is technically valid.  I'm worried about potential alignment issues.

@Josh Well; it works... so I don't see why not. Code golf is all about using horrible methods that aren't technically valid.

Lua, 17 bytes
os.remove(arg[0])

This actually only works if you run the program by typing out the full filepath, i.e.
lua ~/Scripts/removeself.lua would work, but lua removeself.lua would not, assuming a filename of removeself.lua and a current working directory of ~/Scripts.
As far as I know, there's no way to find the actual filepath of a script, just the arguments passed to it. I do know about debug.getinfo(1).source, but in my testing that game exactly the same results as arg[0]. If anyone knows of a way to find the filepath, please let me know.

JavaScript (ES6), 13 bytes
f=_=>delete f

Try It
Logs the source of f, calls f (which deletes f), tries to log f again but throws an error because f is now undefined.

f=_=>delete f
console.log(f)
f()
console.log(f)

JS, 37 bytes
document.documentElement.innerHTML=""

Does this count? It kills javascript on the page

You don't need the spaces around the =

tcl, 18
file delete $argv0

demo — ATTENTION: It is only a one time demo! Only the first time it will be runnable. Please reserve it to the question's original poster.
To try: press the Execute button. The green area will not report  any error. After that, any subsequent clicks on the Execute button will result on a not found error!

VBA, 69 62 Bytes
Subroutine that takes no input and deletes itself.
Requires that the code below be the first line in the active code pane, and that VBA has trusted access to the VBE Project model.
Sub A:Parent.VBE.CodePanes(1).CodeModule.DeleteLines 1:End Sub

-2 bytes for replacing ActiveCodePane with with CodePane(1)
-5 bytes for replacing Application with Parent

shortC, 10 bytes
Aremove(*@

How it works:
A           main function
 remove(    delete file specified in next string
        *@  program name

Equivalent C program:
int main(int argc, char **argv){remove(*argv);}

8086/8088 machine code, 1 byte
aa    stosb

Assumptions:

The registers CS, IP, ES, DI, and AL are all initially 0.
This code is placed at address 0.

The stosb instruction stores the byte in the AL register at the memory location pointed to by ES and DI, then increments or decrements DI. In this case, it stores the byte 0 at the memory address 0, which happens to be where the instruction itself is.
Granted, this program doesn't delete a file or anything. But if you manage to get your hands on an 8086 processor, poke this program into memory, and run it, it will in fact overwrite itself.

PowerShell v3 - 17
ri $PSCommandPath

Julia - 25 bytes
Write this into a file, and then include the file with include("<filename here>") and run f():
f()=rm(functionloc(f)[1])

This is, obviously, a function - I'm not sure how one would go about detecting the file name of a file being run directly (as an include statement without a function definition in it).

C++, 137 bytes.
Works most of the time on windows
#include <stdlib.h>
#include <string>
int main(int, char*v[]){char c[99];sprintf(c,"start cmd /C del \"%s\"/Q", *v);return system(c);}

C, 90 bytes
void main(int n,char**v){char c[99];sprintf(c,"start cmd /C del \"%s\"/Q", *v);system(c);}

Most of the time?

You could save a lot of bytes by removing the unused #include <string>, removing extraneous spaces, and making this C, which lets you remove the int and return. Additionally, you need #include <stdio.h> to make this work, since that's where sprintf is declared.

MATLAB, 36 bytes
delete([mfilename('fullpath'),'.m'])

Save the above code as an m-file following Matlab's filename guidelines.

Nodejs, 32 bytes
require("fs").unlink(__filename)

T-SQL, 28 bytes
CREATE PROC d AS DROP PROC d

It just drops/removes the procedure and the code when executing itself. Usage:
EXECUTE d

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Write a line in program that looks useless
Write some program (the size doesn't matter), and put a line that looks useless, but it's actually not - if it would be removed, the program would crash, or do something wrong. Feel free to mark the line that looks unused by a comment, or mention it your code description, like in example below (of course, in this example, the line is actually not needed, it's just an example).
int main(void) {
    /* The line below is actually needed. */
    2 + 2;

    return 0;
}

As this is popularity contest, the solution with highest number of votes wins.

Why is the line in the example necessary?

@GariBN It's not: "in this example, the line is actually not needed, it's just an example."

@EdCottrell Good to know... I thought I missed some basic thing...

So it is needed.  For the example.  :-)

I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469

C
int main(int argc, char **argv) {
    switch(argc) {
        case 2:
            ;
            int allowed = 0;
        case 3:
            argc--;
            break;
        default:
            argc = 3;
    }
    return 0;
}

Won't compile if we remove the single ;.
EDIT:
Solution below:

 This happens because a case statement is just a label, and, as such, must be followed by a statement (which the standard refers to as a "specifier for actions to be performed", which rules out declarations). To prevent this, we prefix the declaration with a ;, a null statement. Specifications for the case label can be found here at page 142 (131 in-document)

GCC says "a label can only be part of a statement and a declaration is not a statement".

I was just bitten by this in a program I'm writing for school.

This make real programs look so ugly actually :.

C / C++
Just some code written in the style of introduction / tutorial...
Tutorial nr. 2: reading in numbers, performing mathematical operations on them, and printing the results.
//////////////////////////////////////////////////
///////////////////////////////////////////////////
/////                                            //
/////           T  U  T  O  R  I  A  L           //
/////                                            //
///////////////////////////////////////////////////

#include "stdio.h"

int main()
{
    ///////////////////////////////////////////////
    // Local variables (int means integer!!)      /
    int a, b, result;

    ///////////////////////////////////////////////
    // Reading them in                            /
    scanf("%d", &a);
    scanf("%d", &b);

    ///////////////////////////////////////////////
    // Performing an operation, e.g. addition!!!  /
    result = a+b;

    ///////////////////////////////////////////////
    // Why is the next line absolutely mandatory??/
    result = 42;
    printf("The result is: %d", result);

}

Removing the line result = 42; which at first glance looks both superfluous, and, considering the stated objective, actually wrong, will actually cause the program to not do what the description states.
Why?

 Trigraphs strike again! ??/ will be replaced by the preprocessor with \, which will, in turn, concatenate the next line into the comment. The result = 42; becomes part of the comment, so it "saves" the printing line. With the result = 42; line removed, the printf line will be swallowed by the comment.

 Some compilers might give a warning, or trigraphs might be turned off as default and must be turned on for this example to work. Syntax highlighting might also betray it, but there are compilers and IDEs around which leave you none the wiser.

At least in gcc, you must specify that you want to use trigraphs by adding this flag (-trigraphs). Without this, gcc rises warning and ignores trigraphs.

Nice one! I'm glad I didn't scroll down too far before figuring it out. You can change your blockquote into spoiler text by starting it with >! instead of just >.

@squeamishossifrage : thanks, this was my original intention, I used >! just not in every line. I though they don't display for me as I wrote them. Interestingly, the SE parser does not spoil it :)

I knew something sneaky was afoot the second I saw a local include "stdio.h" instead of the actual library include, <stdio.h>

@B1KMusic +1 just for teaching me the difference..

@OllieFord There is actually no difference. That is just convention that states that library includes use <>, while local includes use "".

The moment I saw the superfluous comments I said aloud, "Where's the trigraph? There must be a trigrap-- Ah, there it is."

Whitespace
Unfortunately I cannot show my program here because StackExchange strips all trailing whitespace. The same is true of pastebin.com and pastie.org, so I can’t link to it either.
Of course, the entire program “looks useless”, but if you remove any line, it will do something different.

But fortunately nothing of value will be lost, because the entire language is useless :-)

pastebin doesn't strip whitespace.

@B1KMusic: It does strip from the end of the entire input. :)

@Timwi what about the "raw paste data" box?

@Timwi I just tested it here, and I see what you mean. But if you put non-whitespace text, it will submit, and the raw paste data will be untouched. E.g. you could put an extra line saying "Copy the raw paste data and delete this line"

replace \t with t. Replace " " with s, replace \n with n

Best prank ever: Post something without actually writing code.

JavaScript:
for (var a = 0, b = 4; ++a < b; a++)b+-

2 + 2; // This line is needed, or it will alert twice!
alert(a);

 The reason it works is because the body of the for is b+-, not b++ or b--; therefore, if you remove the required line, it will add to b the value of -alert(a).

"it will add to b the value of alert(a)" : So, shouldn't the b+- be b+= ?

@GaurangTandon No; the idea is that it looks like b++ or b--.

what does b+- actualy mean?

@user689 b + -2 + 2. That's why if you delete the line with 2 + 2;, it evaluates to b + -alert(a);.

C:
#include <stdio.h>
#include <string.h>

int main() {
    int i,sum;
    char s[4];

    /* Add all the integers < 1000 that contain no '0' or '9' */
    sum=0;
    for (i=0; i<1000; i++) {
        sprintf(s,"%d",i);
        if (strchr(s,'0')) goto skip;
        if (strchr(s,'9')) goto skip;
        sum += i;
      skip:
        i = i; /* Don't delete this line! */
    }
    printf("The answer is %d\n",sum);  /* <<< Should be 258948 */
    return 0;
}

If you delete the line i = i; then the code won't work. This is because...

 ... in fact it won't even compile. According to the C standard, labels like skip in the above example must be associated with a statement. Even a single semicolon would have sufficed, but if you delete the whole line then the label has no associated statement and compilation fails. This answer explains in a bit more detail.

APL
Here's an APL function:
i_←{
  ⍺←⎕IO ⋄ ⎕IO←⍺
  ⍵⍴⍳×/⍵
}

It does the same thing as J's monadic i.:
      i_ 5 5
 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

It can take an optional left argument that gives the offset:
      0 i_ 5 5
 0  1  2  3  4
 5  6  7  8  9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24

The line ⍺←⎕IO ⋄ ⎕IO←⍺ looks useless ("assign ⎕IO to ⍺, then assign ⍺ to ⎕IO"), but the first part only runs if no left argument is given, so in fact it does do something:

if no ⍺ is given, set ⍺ to (global) ⎕IO.
set (local) ⎕IO to ⍺

C#
Func<int, int> fibo;
fibo = null; //Note that this can be set to *any* Func<int, int> reference.  It doesn't matter.
fibo = x => x < 1 ? 1 : fibo(x-1) + fibo(x-2);

The variable fibo must be assigned before you can use it inside a lambda, even if you’re assigning that lambda to fibo itself. If you remove the (seemingly useless) assignment, a compiler error will occur (“Use of unassigned local variable 'fibo'”).

It's not a null reference exception, it's an uninitialized variable compiler error. Also, better move the declaration to its own line, because the declaration is not useless.

@KendallFrey  Good point!  Fixed.

Windows Batch:
echo hello
pause
echo world

Set the program running and modify the file to:
rem test01
pause
echo hello world

If you remove or resize the comment, it will cause havoc as the 1st instance of the program pauses and then continues interpreting from the 19th byte onwards.

I don't see any comments.

REM (remark) is the comment operator - https://stackoverflow.com/questions/11269338

COBOL (IBM Mainframe)
   ID DIVISION.
   PROGRAM-ID. USELESS.
   DATA DIVISION.
   WORKING-STORAGE SECTION.
   01  W-WHEN-COMPILED              PIC X(8)BX(8) VALUE SPACE.
   PROCEDURE DIVISION.
       IF W-WHEN-COMPILED EQUAL TO SPACE
           NEXT SENTENCE
       END-IF
       MOVE SPACE                   TO W-WHEN-COMPILED.
       MOVE WHEN-COMPILED           TO W-WHEN-COMPILED

       DISPLAY W-WHEN-COMPILED " HELLO WORLD!"
       GOBACK
       .

If you run the above program (any IBM Mainframe COBOL since COBOL II (first IBM compiler to 1985 standard, probably other IBM COBOLs as well) the output is:

02/22/14 13.11.02 HELLO WORLD!

However, if you remove the triply-useless line "MOVE SPACE TO W-WHEN-COMPILED." (the field has an initial value of space, and has other content placed in it in the next instruction, and it is branched over anyway) the program produces no output and actually Abends (U4038) (that means it crashes) with the following message:
 IGZ0037S The flow of control in program USELESS proceeded beyond the
          last line of the program.  From compile unit USELESS at entry
          point USELESS at compile unit offset +000003AC at entry offset
          +000003AC at address 119003AC.

(message code and text would vary amongst compilers, offsets depend upon actual compiler used and compile options, address depends on where program is loaded when EXECuted).
The reason is the NEXT SENTENCE. This is a Secret GO TO. The compiler hunts down the next full-stop/period in the source, and generates a branch to the following instruction. From COBOL II, the use of full-stops/periods was relaxed. A program must end with a full-stop/period. In this case, the branch is off the end of the program.
Both programs compile 100% clean (no diagnostic messages, Return Code of zero).
This behaviour is a dumb "IBM Extension" to COBOL. The 1985 Standard does not allow NEXT SENTENCE within IF/END-IF (CONTINUE is used instead, which is a no-op). IBM allowed it - causing horrible Gotchas from time-to-time.

JAVASCRIPT
var a = function(b) {
    return b;
}

; // This must be here

(function() {
    // more code
}());

Without the semicolon then a would become what ever the return value from 2nd function is - in this case it's undefined. Because the function originally assigned to a will be executed right away with the second function as the argument b.

Java
package stackexchange;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class Curl
{
    public void getUrl(String address)
    {
        try {
            URL url = new URL(address);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            BufferedReader input = new BufferedReader(new InputStreamReader(conn.getInputStream()));

            /* don't remove this line! */
            http://codegolf.stackexchange.com

            while( true ){
                String line = input.readLine();
                if( line==null ) break http;
                System.out.println(line);
            }

            input.close();

        } catch(IOException ex){
            // ignore.
        }
    }

    public static void main(String[] args) {
        Curl curl = new Curl();
        curl.getUrl("http://codegolf.stackexchange.com");
    }
}

It is a working program that retrieves a web page from an URL.  You might be surprised that the line
            http://codegolf.stackexchange.com

compiles without even a warning.  In fact, the program doesn't compile without it.

 It is actually a label, http:, followed by a comment, //codegolf....  The label applies to the while and is used in the break http; statement.

Some explanation please, or I will remove that line whatever you say.

Ruby
require 'prime'

# Given a regular expression, return the smallest prime containing it
# and the substring of the prime that matches it
def smallest_prime_matching_regexp(regexp)
  match = 'this assignment is necessary even though the value is never used'
  prime = Prime.find { |n| match = n.to_s[regexp] }
  return prime, match
end

[ /4/, /1+2/, /[02468]{2,}/ ].each do |regexp|
  prime, match = smallest_prime_matching_regexp(regexp)
  puts "#{regexp.inspect}:\t#{prime} (#{match})"
end

A similar thing came up at work recently--a coworker actually flagged my seemingly unnecessary initialization during code review, and I was really tempted to put the explanation inside a spoiler block. So I'll do that here.

 The line is necessary because a variable initialized inside a block is local to that block. If we initialize it outside the block, then the value is able to escape to the method scope.

Output as is:
/4/:    41 (4)
/1+2/:  127 (12)
/[02468]{2,}/:  223 (22)

Output with the first line of the method removed:

 undefined local variable or method `match' for main:Object (NameError)

It's fairly obvious why that's needed... and anyway, a better way to write this would be just match = Prime.find { |n| n.to_s[regexp] }

That wouldn't do what I want...Prime.find returns n (e.g. 223), and match needs to be n.to_s[regexp] (e.g. "22"). Obviously I contrived the problem to make that necessary.

Ah, sorry, didn't notice you were calling find on Prime and not an array. Anyway, it's still fairly easy to notice why that line is needed...

Fair enough. Maybe my coworker was just being unobservant.

Huh. No variable declarations, but the opposite approach to defaulting local/nonlocal to what Python does. That's going to feel weird if I ever decide to learn Ruby.

PHP
<?php
$some_html_text= <<<EOT
<h1>This is a Header </h1>
<body> This is a body </body>
EOT;
//This is a comment

Here, \n//This is a comment is necessary. Without it the code won't run.
At least a \n char is necessary after EOT; to run it properly

#include <stdio.h>
#include <stdlib.h>

void strcmp_or_die(char *s, char *t) {
    if(!strcmp(s, t)) {
        printf("Success!\n");
    } else {
        int *ptr = NULL;
        *ptr = 0;
    }
}

int main(void) {
    char blah = '\0'; //segfaults without this line

    char v[2] = "ok";
    strcmp_or_die(v, "ok");
}

 Simple string overflow problem.

Any decent compiler is going to give you a "too many initializers" diagnostic.

Which platform segfaults without blah? Here with OpenBSD 5.5/amd64 and the system gcc, it never segfaults, whether or not blah is there. The compiled program allocates 16 bytes of stack space and copies the 16-bit value of "ok" to the first 2 bytes. The uninitialized 3rd byte has '\0' by luck. If blah is there, it is in the 16th byte, and still not terminating the string.

~-~!
This is probably the stupidest, most obvious one here.
'=|hello\|:
'=~!|Useless?\|:
@'[|y|]|n|:

It throws an error without that second line, with it it prints y.

 the backslash isn't an escape character, hehe.

How do you pronounce the language name?

@professorfish ~-~!

@professorfish That'd be "no comment".

Windows Batch
This is a batch file that prints the numbers 1 to 10 with an empty line after each:
@echo off

setlocal EnableDelayedExpansion

set NL=^

rem Previous two lines deliberately left blank for NL to work.

for /l %%a in (1,1,10) do (
    echo %%a!NL!
)

endlocal

pause

This effectively makes use of a dirty hack to store a newline inside a variable (the use of delayed expansions gets rid of the more scary looking NL line in the linked answer). If you remove or otherwise change the two completely useless-looking blank lines above the comment, well, it won't work.

troff
Troff is the most wonderful text processing system. I use it for my documents. It requires a macro system in order to be ready to be used, and the most famous is the ms macro package. Let's compile the following piece of code with the classical -ms option.
.\" -ms macro package
.\" the following line seems to be useless
\& \" print an invisible character
.ad c
.sp |300p \" absolute vertical positionning
.ps 36p
.ft B
My title.
.PP
This is a paragraph.

The third line seems to be useless, and would actually be useless without the macro package. Since it is followed two lines below by an absolute vertical positionning, it could seem meaningless to print nothing before. But without this invisible character, the vertical positionning will have no effect, though I am not absolutely sure I could explain why (see this thread if you want to have a glance at the discussion). This makes the new user crazy, but then the trick should become familiar to the more experimented user.
Just checked with my favorite version of troff which is not very known (heirloom troff), but I am pretty sure it still works the same with GNU troff.

Nice one, this happens in LaTeX too. Without an empty box or something similar, vertical spacing doesn't work properly.


text:
Find the Longest Palindrome in a String by Removing Characters
Problem: Remove characters from strings to make the longest (character length) palindrome possible. The first line gives an integer value of the number of strings to test. Each subsequent line is a string to test.
Example Input:
3 // Number of lines to test
GGABZXVYCCDBA
ABGBAD
ABC

Example Output:
ABCCBA
ABGBA
B

Shortest code wins.

Would A and C also be acceptable answers for the last test?

Please give an objective winning criterion.

From your example I infer that you ask for a complete program which can process multiple strings as input. The problem specification only asks for a single string - can you please clarify. Also does largest means longest/most characters?

Why is this tagged "Java"?

related: http://codegolf.stackexchange.com/questions/862/finding-sub-palindromes-2-subsequences

seems close enough to be duplicate

@Howard Basically the same question. This one asks for the longest one, and that one asks for all of them. You could just take the longest and then you would have an answer to this question. Voted to close as duplicate

@shiona A and C would also be acceptable answers for the last test. If there is a tie for the largest palindrome, pick any one of them.

@DoorknobofSnow this is not a duplicate. This one requires that you *remove characters to make the palindrome.

@Connor That one does too. "Subsequence" means any sequence you can get by removing 1 or more characters.

@DoorknobofSnow Oh. I didn't know my bad. I'm still pretty new to this stuff.

Here is my solution in Java (not exactly short hah)...
import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class Palindrome {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(new File("src/pal.dat"));

        int q = sc.nextInt();
        sc.nextLine();

        for (int z = 0; z < q; z++) {
            String line = sc.nextLine();

            int max = 0;
            String maxP = "";

            for (int k = 0; k < line.length(); k++) {

                String p = calc(line.substring(k));

                if (p.length() > max) {
                    max = p.length();
                    maxP = p;
                }

            }

            System.out.println("Max Palindrome: " + maxP);

        }

    }

    public static String calc(String s) {
        if (s.length() == 0)
            return "";
        if (s.length() == 1 || (s.length() == 2 && s.charAt(0) != s.charAt(1)))
            return s.charAt(0) + "";
        if (s.length() == 2)
            return s;

        char[] arr = s.toCharArray();

        boolean match = false;
        int i = 0;
        for (i = arr.length - 1; i > 0; i--) {
            if (arr[i] == arr[0]) {
                match = true;
                break;
            }
        }

        int max = 0;
        String maxPalin = "";
        for (int k = 1; k < i; k++) {
            String p = calc(s.substring(k, i));
            if (p.length() > max) {
                max = p.length();
                maxPalin = p;
            }
        }

        if (match)
            return arr[0] + maxPalin + arr[0];
        return maxPalin;

    }

}


text:
Generate the characters of "Hello, world!" mathematically, without strings or arrays, like generating the digits of π
The challenge is to come up with a mathematical way to generate each character of the exact string:

Hello, world!

(Capital letter, comma, exclamation mark.)
But you can't use any strings, arrays, or equivalents, to contain the data of the text. You must derive the characters by mathematical means.
So just a list or array of characters or ASCII codes or numbers trivially offset or inverted or shifted does not count. Nor does downloading it from an external resource or taking user input. Nor does starting with a large number which is just each ASCII codes shifted and ORed together, etc.
You can use any programming language, any mathematical functions, math libraries, etc.
The characters can of course be strings as you generate them.
Think of something like generating the digits of π.
The winner shall be the one with the most cleverness and/or elegance. The relevant weightings of cleverness and elegance are up to your peers, for the winner shall be decided by voting. (Finding a loophole in my poor problem statement shall not be regarded as clever d-:)
I think you can get the jist so don't cheat and if I should make it clearer or close some loopholes then please comment.

@xfix: Well why did that not show up in related or when I was looking for something similar )-: Then again there seem to be lots of strings and arrays in the previous question, so maybe mine is different enough?

All the answers I've check so far for the previous question don't pass my (intended) rules though it's true our question titles are very similar I think the "meat" of the questions is pretty different after all.

@xfix: I reworded the title to highlight that I'm looking for something like generating the digits of pi, and specifically not the packing/unpacking type of solutions submitted for the earlier question.

@hippietrail what makes that a programming puzzle (and not a mathematics puzzle)? And the same issues as in the question xfix linked applies, like how to encode letters etc.

@FireFly: Would a "digits of pi" generator then also not be a programming puzzle? I endeavoured to ban entries which merely encode the letters. But if you're asking about how to encode them for output then the answer is in ASCII.

@hippietrail a "shortest code that generates N digits of pi" task would certainly be a programming puzzle, but your question seems to be more about finding a mathematical curiosity than the actual implementation, AFAICT (i.e., locate a sequence in the expansion of π that happens to correspond to the ASCII coding of "Hello, world!" (or parts of it)).

Umm no I wasn't looking for "Hello, world!" within π. I'm looking for something that seems to pull the text out of nowhere due to the programmer's skill with numbers. It's about coming up with a formula or algorithm rather than the mere expressing of the algorithm in a programming language. That's just a necessary step. It would be a mathematical curiosity of course, nothing wrong with that compared to smiley faces and Olympics logos.

http://www.stavros.io/posts/printing-hello-world-using-curve-fitting/

@marinus: Very nice! It still seems to be encoded in a special way in his function but it's definitely in the same vein.

HQ9+
H

If you need more mathematics, H+++++++++++++++++++++++++++++++++++++++++ should suffice.

The +s make it funny but the HQ9+ output doesn't match Hello, world! and is counted as trying to find a loophole outside the spirit of the question.

You must use the official interpreter.

Javascript
String.fromCharCode(72)+(681180).toString(36)+String.fromCharCode(44)+String.fromCharCode(32)+(54903217).toString(36)+String.fromCharCode(33)

It uses a few ASCII codes, but not for most of the text.

It looks like the string is already encoded in the numeric literals, which is what I was trying to avoid, but I admit I don't fully understand it.

It treats lowercase letters as digits in base 36, then converts 681180_base10 to ello_base36 and 54903217_base10 to world_base36.

Ah yes, I've been away from JS for a while and forgot about the base thing.

Brainfuck
-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[->+++++<]>+.------------.--[->++++<]>-.--------.+++.------.--------.-[--->+<]>.

Could you include some explanation of how it works?

It calculates the ASCII codes of Hello, world! and outputs them.

Oh then I assume the calculation must be inverse hyperbolic cotangent of course. And outputs them in groups of three.

Yeah, just like the title says.