text:
ASCII Art Generator
Your goal is to write a program / script which "converts" real images into ascii art.
General:
Your program will get a path to a image file over stdin or as parameter (whatever you prefer). The format will be jpeg.
It should "convert" it to ascii art and save it to the harddrive.
The image will be in grayscale. You don't have to check if the input file exists or the file is a valid image.
You can use any utf-8 character in your outputfile.
Rules:

You must be able to recognize the output image.
Your program must recognize the path on stdin or parameters
The content of the original image must be read from the drive (you get only the path
to the file)
No user interaction (except giving the parameters at startup) allowed
Must terminate without any error message
The output must be written to the harddrive (output  name is up to you)
Only turing complete languages allowed.
If you require any special language version for your program you have to add it to your answer. Otherwise the newest stable version will be used (e.g. python = python 3.3)

Bonus points:

-10 Points for every additional image format your program can convert (please write down which formats can be recognized)
-25 Points if your program can change the output size (width / height parameters at startup in characters)
-100 Points if you don't use any Image Processing libraries (e.g. PIL, ImageMagic, GD...)
-50 Points if your program source looks like ascii art itself ;)

Formula to calculate your points:
points = floor(programSize (in Bytes) * avgRuntimeOnTestInput (in seconds) - BonusPoints)
How your program will be tested:
All programs will run on a new virtual machine running Debian x64 (current version) with 512MB memory, 2x3,4Ghz CPU.
The time will be calculated on an average of three pictures per format with different size and content (every program will be use the same files).
Please write your programcall into your answer so i can check it (and if required the needed compile parameters).
Example program call (with bonus parameters):
python ascii.py -file /home/chill0r/test/MyPicture.jpeg -width 1000 -height 750 -out /home/chill0r/test/MyPictureAscii.txt
I'll check the answers every few days and post a 'low score' (high score doesn't really fit on code golf...). (Meaning you don't have to calculate your points on your own)

First, I've only been here for a week and already seen multiple ASCII challenges. This one is even more general than the last two. Second, if I have the fastest code, and someone else has the shortest code, who wins? I suggest removing the "fastest-code" tag or the "code-golf" tag - probably remove the former judging by your scoring system. Then, put a spin on your question that makes it unique from other ASCII challenges.

I have removed [tag:fastest-code] since it is obvious from the question that this is a code-golf challenge.

"You must be able to recognize the output image." - isn't this too subjective? I thought to post this question too but couldn't come up with a way to enforce this objectively.

One objective approach to "able to recognize" I have been able to think of is for poster to hire people on something like Mechanical Turk to see if they recognize the image. But that creates a problem if poster wanders off distracted by something shiny and new answers are still coming in. So I thought of one better: poster writes a test harness that rasterizes the ASCII images and algorithmically evaluates them for similarity to the original image, and posts the source for the tester in the question. Then at least you have a verifiable authority.

Bonus points are listed with negative values, but they are subtracted in the score formula, that makes them to penalties?

changed tag to code-challenge since the scoring depends on both code size and runtime

I don't think a comparison of execution times is particularly worthwhile. The amount of computation involved in unpacking a JPEG image is far, far greater than the computation needed to convert the image into ASCII art. I also don't really like the idea of having to write software to run on a computer system that I have no access to. I really wish you'd discussed this question in the sandbox before posting it here.

@squeamish ossifrage In fact there already exists a question in the sandbox that is very similar to, but better-written than, this. I want to close this as duplicate, but technically the one in the sandbox isn't posted...

@GrantMiller I appreciate that you're aiming to improve the site via your edits, but it is usually recommended to only edit around 5 posts in a short period of time, as to not flood the home page with questions from 2014. Please continue editing, but also refrain from making mass edits in a short amount of time. Thanks!

Mathematica
asciiPhoto[image_,rastersize_:125,shades_:3] scans the image according to the raster size (default=125), quantizes it into up to 7 shades (3 by default), then replaces the shading with ASCII characters of varying darkness.   Hints about relative darkness found here.  The characters are stored in shades; for some reason, 2 of them disappeared in the cut and paste to SE.
asciiPhoto[image_,rastersize_:125,shades_:3]:=
Module[{chars,gray},
chars={{},{"M"," "},{"","/"," "},{"P","o","/"," "},{"W","o","/",""," "},
{"","b","o","/",""," "},{"","M","b","o","/",""," "},};
gray=ImageData[ColorQuantize[Rasterize[image,RasterSize->rastersize+1,
ImageSize->rastersize],shades]];
GraphicsGrid[gray/.Thread[Union@Flatten[gray,1]->chars[[shades]]],ImageSize->500]]

Examples
Render the merganser with a raster size of 35 in 4 shades; compare it to a raster size of 85 with 5 shades.

{asciiPhoto[merganzer, 35, 4], asciiPhoto[merganzer, 85, 5]}

Raster size of 125 in 2 shades; same raster size with 7 shades.
{asciiPhoto[merganzer, 125, 2], asciiPhoto[merganzer, 125, 7]}

Let's not forget Greta.

Very nice. The only observation isn't programming related: Let Greta go. :)

@belisarius, It seems I just can't get Greta out of my mind.

Well, it's a shared weak point

I invite you to spend a few pennies by downvotng this one

Happy to oblige.

I was just starting to golf this, but I doubt I could beat your solution. I leave my input here just in case you can use some ideas: n = 128; i = ColorConvert[ExampleData[{"TestImage", "Lena"}], "Grayscale"]; n1 = ImageDimensions[i]/n; ip = Rescale[    Mean[Flatten[#]] & /@ (ImageData /@        Flatten[ImagePartition[i, n1]])]; ch1 = CharacterRange["a",     FromCharacterCode[ToCharacterCode["a"] + 500]]; chars = Style[#, FontFamily -> "Monospaced"] & /@ ch1;

cc = Rescale[    Mean[Flatten[#]] & /@ (ImageData /@ (ImagePad[#, {{1, 0}, {0,               0}} (16 - ImageDimensions@#),            White] & /@ (Rasterize[#, RasterSize -> 15] & /@ chars)))]; f = Nearest[cc]; ct = Thread[Rule[cc, ch1]]; p1 = Partition[f[#, 1][[1]] & /@ ip /. ct, n]; Rasterize[  Style[StringJoin @@ (StringInsert[#, "\n", -1] & /@ (StringJoin @@@         p1)), "Monospaced", LineSpacing -> {0, 8}]]

Please remember it isn't golfed at all

The result is quite nice

@belisarius, Yes, the result is nice. I still need to explore the code to grasp its logic. BTW, this is a code-challenge question.

Yup. I realized the code-challenge tag too late :)

You call the first one a duck but it's easily recognizable as a specific type of duck, namely a male red-breasted merganser.  But there are some areas (like the side of the face) that are too light in the ASCII art.  I assume those were supposed to be in the two characters that you lost while pasting.

Yes. (about the real name).  I should have been more precise. I live on a lake that mergansers, tufted and common, visit at this time of the year.  You are also correct about the shading issues. I may look into that.

@GlennRanders-Pehrson, I fixed the label and tweaked the code so that all pixels are correctly rendered by shade.

Yes, definitely a red-breasted merganser now.  One upvote for you.


text:
Cross Language Troll
The Setup
Jim the student who attempts to use Stack Overflow to do his homework has asked how to get his program to say "Hello World" in under 100 lines of code, you decide mere mortal trolling is not enough...
The Challenge
You need to provide Jim with a program less than 100 lines long that outputs a satisfactory answer in another language. Bonus points for additional languages.
The Rules
 1. Max 100 lines of code
 2. 10 points for successfully outputting the answer in another language
 3. +1 point for every additional language answer is provided for
 4. Honorable mentions will be given to the most creative, most evil, and most unorthodox answers
 5. Challenge ends 23:59pm GMT 3/14/2014 (results provided a few hours post challenge)
The winner is Michael who converted between six languages first
I also will give an honorable mention for cleverness to McMillin for using one command that works in several languages
I also give an honorable mention to Comintern... I don't actually know if brownies is a language, but I think we can agree it was unorthodox.
I don't think any of the answers qualifies as evil, but for the sake of it everyone who used brainfuckery will be considered recipients.

Welcome to PPCG. We reserve the code-golf tag for challenges strictly scored by least number of bytes/characters. Code-trolling also fails to apply here since the task you have set up is a straightforward polyglot. The only trolling involved is introduced by your backstory. Look at some past code-trolling questions; usually the aim is to do a simple task in a way that embodies/parodies common programming pitfalls, easily missed bugs, abuse of paradigms, non-idiomatic coding, etc. At its best, code-trolling should be about showing your skill by astute parody of the unskilled approach.

My apologies, I thought it fit code-trolling section, I'll be more careful about future tagging.

By another language you mean? A programming language or natural langauge? Also, what about languages that share the same keyword to print (e.g. 'print' in several languages)

Well my intended purpose was from one programming language to another, but also different natural languages would be even more trollish. Shared solutions... since I didn't specify so long as you properly credit that you covered the language I'll count it.

I think you should clarify your rule as programming language. I posted my answer only because I thought it would be funny, I didn't even expect you to consider it a valid answer.

the best answer to this would be a unicode aware hq9 interpreter.

JavaScript to C to PHP to JavaScript to Brainfuck to HQ9+
atob("bWFpbigpe3B1dHMoImVjaG8gXCJjb25zb2xlLmxvZygnKysrKysrWz4rKysrKysrKysrKys8LV0+LicpO1wiOyIpO30=")

This outputs :

main(){puts("echo \"console.log('++++++[>++++++++++++<-]>.');\";");}

Which outputs :
echo "console.log('++++++[>++++++++++++<-]>.');";

Which outputs :
console.log('++++++[>++++++++++++<-]>.');

Which outputs :
++++++[>++++++++++++<-]>.

Which outputs :
H

Which outputs :
Hello World!

Bash
echo Bonjour tout le monde

Outputs "Hello World" in a language called French.

Oops... I thought it was a code-trolling question. I just realised this was retagged. Apologies if you think this is not an answer.

French language? Is it a LISP dialect?

C# -> Chef -> German\Brownies
using System;
using System.Text;

namespace Greetings
{
    class Program
    {
        static string[] ingredients = {" vegetable oil "," eggs "," boiling water "," vanilla "," cocoa powder "," flour "," sugar "," baking soda "," salt "};
        static string[] measures = {" tablespoons"," dashes"," heaped tablespoons",""," pinches"};
        static int[] amounts = {154,32,157,127,110,145,164,141,154};
        static int[] units = {0,3,0,1,2,2,2,4,4};
        static int[] steps = {4,7,0,8,2,1,3,5,0,6};

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder("Fudge Brownies.\n\nThis recipe makes an absurd amount of brownies for one person.\n");
            sb.Append("\nPre-heat oven to 175 degrees Celsius.\n\nIngredients.\n");

            for (int i = 0; i < ingredients.Length; i++)
            {
                sb.Append(amounts[i]);
                sb.Append(measures[units[i]]);
                sb.Append(ingredients[i]);
                sb.Append("\n");
            }

            sb.Append("\nMethod.\n");

            for (int i = 0; i < steps.Length; i++)
            {
                sb.Append("Put");
                sb.Append(ingredients[steps[i]]);
                sb.Append("into the mixing bowl.\n");
            }

            sb.Append("Liquefy contents of the mixing bowl.\nPour contents of the mixing bowl into the baking dish.\n");
            sb.Append("\nCooking time: time 40 minutes.\n\nServes 1.");
            Console.WriteLine(sb);
        }
    }
}

The C# code above outputs the Chef code below (which is also a pretty tasty brownie recipe).
Fudge Brownies.

This recipe makes an absurd amount of brownies for one person.

Pre-heat oven to 175 degrees Celsius.

Ingredients.
154 tablespoons vegetable oil
32 eggs
157 tablespoons boiling water
127 dashes vanilla
110 heaped tablespoons cocoa powder
145 heaped tablespoons flour
164 heaped tablespoons sugar
141 pinches baking soda
154 pinches salt

Method.
Put cocoa powder into the mixing bowl.
Put baking soda into the mixing bowl.
Put vegetable oil into the mixing bowl.
Put salt into the mixing bowl.
Put boiling water into the mixing bowl.
Put eggs into the mixing bowl.
Put vanilla into the mixing bowl.
Put flour into the mixing bowl.
Put vegetable oil into the mixing bowl.
Put sugar into the mixing bowl.
Liquefy contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.

Cooking time: time 40 minutes.

Serves 1.

The hardest part was doing the unit conversions on the recipe, and it really does make an absurd amount of brownies, even for a whole bunch of people.  When run through a Chef interpreter, it outputs:
Hallo Welt

Or, "Hello World" in German. I'm not sure if "brownies" technically constitutes a language.  If it does, it probably isn't Turing complete.

Fortran 95 to Batch back to Fortran 95
open(unit=11,file="FOO.BAT")
write(11,"(A)") "@ECHO OFF"
write(11,"(A)") 'ECHO print*, "Hello World!"; end > BAR.F95'
call SYSTEM("FOO.BAT")
call SYSTEM("gfortran BAR.F95 -o BAR.EXE")
call SYSTEM("BAR.EXE")
end

This code produces a file named FOO.BAT, and then executes it automatically. This .BAT file will generate another file named BAR.F95, which is a Fortran code. This code is automatically compiled and executed, finally producing the phrase "Hello World!"

I think you mean Batch, not Bash.

Yep, thanks for the correction.

C++/JavaScript/Python 3
A oneliner:
int main(){puts("alert(\"print(\\\"Hello World!\\\")\")");}

Output is a program in JavaScript that outputs the basic Hello World program in Python 3.

Perl/Ruby/Python(2)/Fortran/SML
print "Hello World";

source: Stack Exchange

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

sort: votes


text:
Minesweeper Solver
We already generated Minesweeper fields, but someone really has to sweep those generated mines before PCG blows up!
Your task is to write a Minesweeper Solver that is compatible with a slightly modified version of the accepted solution of “Working Minesweeper” (actions are separated by spaces to allow for larger fields).
Input: A Minesweeper field, fields separated by spaces. The first line denotes the total number of mines.

x: Untouched
!: Flag
Digit: Number of mines around that field

Example:
10
0 0 1 x x x x x
0 0 2 x x x x x
0 0 2 ! x x x x
0 0 1 2 x x x x
0 0 0 1 x x x x
1 1 0 2 x x x x
x 1 0 2 x x x x
1 1 0 1 x x x x

Output: Your next step in the format action row column (starting at zero)
Valid Actions:

0: Open it
1: Place a flag

Example:
0 1 2

Rules:

You write a complete program that takes a single field as input (either STDIN or command line arguments) and outputs a single action (STDOUT). Therefore, you cannot save states, except for !.
Your choice must follow the best odds for survival. (i.e. if there is a 100% safe move, take it)
This is code-golf; the shortest solution (in UTF-8 bytes) wins

Tests:
These tests serve the purpose of testing for common clear situations; your program must work for every test field.
In:
4
x x x x
1 2 x x
0 1 2 x
0 0 1 x

Out (any of these):
1 1 2
0 0 2
0 1 3

In:
2
x x x
1 ! x
1 1 x

Out (any of these):
0 0 0
0 0 1
0 1 2
0 2 2
1 0 2

In:
10
x x x x x x x x
1 3 3 x x x x x
0 1 ! 3 3 4 x x
0 2 3 ! 2 3 x x
0 1 ! 2 2 ! x x

Out (any of these):
1 1 5
1 0 2

In:
2
x x x
2 3 1
! 1 0

Out (any of these):
0 0 1
1 0 0
1 0 2

Nice! 1) Perhaps for testing someone should write a test harness: given a field, it prints each step taken, and whether the program wins. The program should win on maps without any ambiguity. 2) I wonder if anyone will use the flag action. Seems like it should never be necessary.

For the first test. Why are you able to move to 0 0 2 or 0 1 3. I can't see how either one of the those would be considered safe. (I must not be good enough at minesweeper...)

@FDinoff Imagine a flag standing at 1 2, the two 2s would have 1 mine left. Because the mine for the two 1s at the borders touches the 2s as well there neither can be a mine at 0 2 nor at 1 3.

There are situations where you can predict a move with 100% accuracy if you know the number of mines but otherwise can only guess. Are we provided the total number of mines or should we neglect this case?

@Howard I missed that one. I'll edit in a minute.

Possibly F or P looks better flag than ! :)

Although it can be easily inferred from the examples, it still might be helpful to explicitly note that the board is zero-indexed. Also, does "best chance of survival" apply to the opening move? I haven't done the math yet, but I suspect all positions are not equal.

@JonathanVanMatre It is noted: “(starting at zero)”. It does not apply to the opening move (In fact: The Windows Minesweeper generates the field after the opening move).

@TimWolla That shows how long it has been since I played WinMinesweeper. Last time I used it, you started with a blank field. Sorry I missed the parenthetical...my brain must have said "It's in parens, it's not important." This is why I would be terrible at LISP.  :)

@JonathanVanMatre The field is a blank one, but it is guaranteed your first opening is not a mine, as the mines are placed after the first click :)

Fun fact: There are only a finite number of boards available (at least in the XP version, which is the canonical one in the competitive scene). The board is shifted around as you click the first spot to ensure that you're not clicking a mine, but other than that it's already decided which board you'll use.

Mathematica
Still not golfed. Needs some more work on I/O formats.
t = {{0, 0, 1, x, x, x, x, x}, {0, 0, 2, x, x, x, x, x}, {0, 0, 2, F, x, x, x, x},
     {0, 0, 1, 2, x, x, x, x}, {0, 0, 0, 1, x, x, x, x}, {1, 1, 0, 2, x, x, x, x},
     {x, 1, 0, 2, x, x, x, x}, {1, 1, 0, 1, x, x, x, x}};
(*Sqrt[2] is  1.5*)
c = Sequence; p = Position;
nums = p[t, _?NumberQ];
fx = Nearest[p[t, x]];
flagMinus[flag_] := If[Norm[# - flag] < 1.5, t[[c @@ #]]--] & /@ nums
flagMinus /@ p[t, F];
g@x_List := Tr[q[#] & /@ x]
eqs = MapIndexed[t[[c @@ (nums[[#2]][[1]])]] == g[#1] &, (fx[#, {8, 1.5}] & /@nums)];
vars = Union@Cases[eqs, _q, 4];
s = Solve[Join[eqs, Thread[0 <= vars < 2]], vars, Integers];
res = (Transpose@s)[[All, All, 2]];
i = 1; plays = Select[{i++, #[[1]], Equal @@ #} & /@ res, #[[3]] &];
Flatten /@ ({#[[2]] /. 1 -> F, List @@ vars[[#[[1]]]] - 1} & /@ plays)

(*
{{0, 0, 3}, {F, 1, 3}, {F, 2, 4}, {0, 3, 4}, {0, 4, 4},
 {F, 5, 4}, {F, 6, 0}, {F, 6, 4}, {0, 7, 4}}
*)

Edit: Bonus Track
I made up an interactive playground that calculates bomb probabilities by calculating all possible solutions for a given configuration:

Instructions for testing it without Mathematica installed:

Download http://pastebin.com/asLC47BW and save it as *.CDF
Dowload the free CDF environment from Wolfram Research at
https://www.wolfram.com/cdf-player/ (not a small file)

The slider changes the board dimensions.
This is just a sketchy program, not fully tested, please report any bugs.
I haven't implemented a "total number of available bombs on board" feature. It's assumed infinite.

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


text:
Create a simple 2048 game clone
2048 is an incredibly fun and addictive game in which the goal is to create a tile with 2048 on it.
Here's a short description of the game:

Pressing an arrow key will slide all the blocks in the stage in that direction. For example, if x represents a block, and you pressed the up arrow in this case:
...x
.x..
..x.
xx..

Then the board would become
xxxx
.x..
....
....

Furthermore, the blocks are numbered, starting at 2. If two of the same numbered blocks are moved together, they will merge into the next number. For example, pressing "up" on this board:
.2..
..22
.2..
....

Would create this:
.422
....
....
....

And then after pressing "right," it would become ..44, and therefore pressing right again would create an "8" block, and so on.
Each turn, a new "2" block is created on a random open square. (It's actually not always a "2," but for simplicity let's keep it at that.) If there are no possible moves left (i.e., the board is full and you can't merge anything), the game is lost, and if a 2048 block is created, you win!

Your challenge is to recreate this game, golfed!

For edge-cases, such as pressing "right" on this board:
....
.222
....
....

you must merge the tiles closest to the edge of the arrow key pressed. For example, this would become ..24, because the second and third "2"s are the closest to the right edge.
If the player presses an invalid move (such as "up" on a board like 2.2. / .... / .... / ....), you must ignore the move.
Moves can be accepted in any way, such as clicking, arrow keys, ULRD, etc.
The tiles must all be the same shape—a "1024" tile should be the same size as a "2" tile.
The tiles must be separated in some way. For example, |1024|   2|1024|1024| is a valid example of a row (assuming that the tiles are squares), while 1024   210241024 is not.
You must output "you win" if the player creates a 2048 tile, or "you lose" if there are no valid moves left.
This is code-golf, so the shortest code in bytes will win!

Instead of accepting either rows of single characters (first five examples) and/or separated tiles (last one), why not assign ascending powers of two to individual characters to normalize the output?

@millinon Because it's supposed to be as similar as possible to the actual 2048 game (it would make the title meaningless), and it would remove some of the challenge.

"If there are no possible merges left, the game is lost" Shouldn't there be an "and the board is full" in there somewhere?

does space suffice as a tile separator?

If the starting board is a single 2, no merges are possible. Does that mean the task is to render a 4x4 square with a random 2 inside, and then the message "you lose"?

@Peter s/merge/move/ :-P Edited

@Jan Yes, space is a valid separator.

Funny how all your questons get a ton of votes, but not many answers.

@Doorknob Actually it is always a 2 on a random position (i played it to see how it worked) but it can be a 4 when the random position already contains a 2. At least thats what it seemed to be.

@TheDoc I've been trying to post more interesting and difficult challenges; I'm beginning to feel more and more that challenges you can complete in only 5 minutes or so just aren't as fun.

@Teun Well, for simplicity let's just assume it can only be a 2, since we're still not sure of the exact details (what happens if a 2 appears on a 8? Are there any other factors? Etc)

@Doorknob probably find another cell :P but I agree.. My code is long enough already lol

@TeunPronk The source code says: var value = Math.random() < 0.9 ? 2 : 4;, so on any given new tile there is a 10% chance it will be 4.

Now its your fault I´ve been playing 2048 the whole weekend and today the productivity of our office has dropped to 0.

hmm... will Bash strike back here... hmm...

@Doorknob I'm pretty sure that 2048 doesn't quit upon obtaining a 2048 tile. Many of my friends have gotten a 4096 tile or even higher. So making this as close as possible to the original would remove that restriction.

@Doorknob Do the cells only need to always have the same shape, or does the number of rows (in a text based answer) used by a cell have to equal the number of columns? The currently accepted answer only keeps them constant, but not "square".

@Adám Huh, the challenge claims that the tiles have to be congruent squares but apparently I didn't actually enforce that rule. I guess I can't really invalidate nearly all the answers, so I suppose I have to go with the former.

@Doorknob In that case, you have a new winner ;-)

Does outputting Colored squares count? @RohanRjhunjhunwala offered a no-deadline bounty on this (500 rep) for writing one in S.I.L.O.S, and an extra 250 with GUI. however, S.I.L.O.S only has rectangle/ellipse drawing. I could, however, draw different colored squares though.

APL (Dyalog APL), 153 150 167 156 155 151 bytes
'you ',{2048∊⍵:'win'
(z/∊n)[?+/z←0=∊n←⍵]←2
⎕←4↑¨⍕¨n
1∊(⍉2=⌿n),(2=/n),0=n:∇{⍵≡r←R⍣¯1⎕UCS{4↑⍺⍺t⎕R(1⌽∪¨t←2/¨⍺⍺2*⍳16)⍺⍺⍵~0}¨(R←↓⍉∘⌽⍣⎕)⍵:∇⍵⋄r}n
'lose'}4 4⍴0

Prompts for move; 0=Left, 1=Up 2=Right, 3=Down
Try it online!
Ungolfed, with whitespace
C ← ⎕UCS
'you ', {
    2048 ∊ ⍵: 'win'
    n ← ⍵
    z ← 0 = ∊n
    (z / ∊n)[? +/z] ← 2
    ⎕ ← 4 ↑¨ ⍕¨n
    1 ∊ (⍉ 2 =⌿ n) , (2 =/ n) , 0 = n: ∇ {
        R←↓⍉∘⌽⍣⎕
        r ← R⍣¯1 ⎕UCS {
            t ← 2 /¨ ⍺⍺ 2 * ⍳16
            4 ↑ ⍺⍺ t ⎕R (1 ⌽ ∪¨t) ⍺⍺ ⍵ ~ 0
        }¨ R ⍵
        ⍵ ≡ r: ∇ ⍵
        r
    } n
    'lose'
} 4 4⍴0

Explanation
Blank lines indicate a newline, while blocks of lines belong on a single line

'you ', "you" prepended to the result of the function {...

2048 ∊ ⍵: 'win' if the argument (the board) contains 2048, then return "win"
n ← ⍵ assign the right argument to n (so it may be modified in-place)
z ← 0 = ∊n z gets the Boolean list where flattened z is 0
(z / ∊n) z filters the flattened n (to get only the zeros)
[? +/z] use a random number between 1 and the count of zeros (the sum of the Boolean z) to select which zero-containing position
← 2 gets a 2
⎕ ← output the
4 ↑¨ each extended-to-length-4 (with spaces)
⍕¨n string representation of each number
1 ∊ if any of the following are found;
(⍉2=⌿n) pairwise vertical equalities (transposed to be concatenable)
, or (concatenated to)
(2=/n) pairwise horizontal equalities
, or (concatenated to)
0=n zeros
: then:
∇ call this function on the result of the function {...

R ← R (for Rows of Rotated) is
↓ the split-into-rows
⍉∘⌽⍣⎕ prompt for numeric input, then rotate (literally mirror horizontally, then transpose) the argument (the board) –90° times the inputted number
r ← r (for result) gets
R⍣¯1 the inverse of R (rotate back, then merge rows into matrix) applied to the result of the function ⎕UCS{... (where ⍺⍺ means convert to/from UCS points)

t ← t gets
2 /¨ two of each of
⍺⍺ the characters corresponding to the code points
2 * ⍳16 2¹, 2², 2³,... 2¹⁶
4↑ pad with zeros on the right until length 4
C convert the following UCS characters to code points
t ⎕R (1 ⌽ ∪¨t) regex replace each pair t with the unique characters from the next t on the right
C ⍵~0 the argument (board) without zeros (compacted to the left), then converted to UCS code points

}¨ [end of function] applied to each of
R ⍵ R applied to the argument (the board)
⍵ ≡ r: if the argument (the old board state) is identical to r (new board state), then:
∇⍵ call this function on the unmodified argument (because the user made an invalid move), else
r return r (the new board state)

} n [end of function] applied to n (the new board state), else
'lose' return "lose"

} 4 4 ⍴ 0 [end of function] applied to a 4-by-4 table of zeros (the initial state)

GolfScript, 323 characters
1,16*{16,{1$=!},.,rand=)/()2++\[]*+4/{.['-----']4*'+'*'++'1/*n+:^\{'|''     ':X'|'+4*n++:Y.@{X\`+-5>'|'\+}%'|'+n+Y+Y+^+}%+puts}:P~"wasd":Q{1$.@{Q\?[{zip}{}{-1%zip-1%}{{-1%}%}]=\1$~{0-[{.2$={+)}*}*0...]4<{1|(}%}%\~}:^~=!},:F{0{;'"#{'9.?rand';STDIN.getc()}"'++~.F\?0<}do^[]*.2048?0<.!{'you win'@@}*}{'you lose'@@*0}if}do 4/P;

The keys you have to use are wasd but you can change the constant in the code to whatever keys you like. It gracefully ignores any unknown key or illegal move. Unfortunately you have to press enter after each key.

256 character solution
1,16*{16,{1$=!},.,rand=)/())+\[]*+4/{.{{.9>7*+48+}%n+}%puts}:P~"wasd":Q{1$.@{Q\?[{zip}{}{-1%zip-1%}{{-1%}%}]=\1$~{0-[{.2$={;21+}*}*0...]4<{20%}%}%\~}:^~=!},:F{0{;'"#{'9.?rand';STDIN.getc()}"'++~.F\?0<}do^[]*.10?0<.!{'you win'@@}*}{'you lose'@@*0}if}do 4/P;

Here the output is hexadecimal logarithmic, i.e. 0 stands for ., 1 for 2, 2 for 4, 3 for 8 ... B for 2048. Since we all know hexadecimals and the powers of two this shouldn't be a limitation at all.
Example run (first moves):
0000
0000
0010
0000
w
0011
0000
0000
0000
a
2000
0000
0001
0000
s
0000
0000
0100
2001
d
0000
0000
1001
0021
w
1022
0000
0001
0000
a
1301
0000
1000
0000
s
0000
1000
0000
2301
d
0000
1001
0000
0231

Tiles should be seperated though, but nice job.

@TeunPronk I'm working on it. Unfortunately it breaks the nice power of two score.

+unlimited for being exactly 256 chars

yay...2^7 characters!!

Nice! Didn't know how to do input in golfscript before. Personally I like the 256 char solution more, easier to read. And I would say the tiles are separated because each tile is only 1 character long. there is never any ambiguity.

J - 240 230 216 char
This counts the trailing newline, because you need it to start running the game at the console. Play by typing one of udlr and then hitting Enter. Moves that do nothing to the board are handled properly, but the program will get mad at you if you give it any bad input.
'you ',>lose`win{~$:@".@('o b=:2 t}^:(1-b-:])s ',' b',~1!:1@1:)`w@.((w=:2048 e.,)+(s d-:s u=:l d=:r(&.|:))*s r-:(s=:[:p(2(=/(0,+/^:)@{.,}.),)/@p=:\:=&0)l=:&.|.r=:"1)(o=:[2:1!:2~4<@":"0])b=:2(t=:(?&#{])[:I.0=,)}4 4$0

The readable version and explanation are a little too large to fit comfortably into the post: you can find a writeup at this link.
Usage:
   'you ',>lose`win{~$:@".@('o b=:2 t}^:(1-b-:])s ',' b',~1!:1@1:)`w@.((w=:2048 e.,)+(s d-:s u=:l d=:r(&.|:))*s r-:(s=:[:p(2(=/(0,+/^:)@{.,}.),)/@p=:\:=&0)l=:&.|.r=:"1)(o=:[2:1!:2~4<@":"0])b=:2(t=:(?&#{])[:I.0=,)}4 4$0
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   2|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
r
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   2|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   2|   0|   0|
+----+----+----+----+
u
+----+----+----+----+
|   0|   2|   0|   2|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   2|
+----+----+----+----+
d
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   2|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   2|   0|   4|
+----+----+----+----+
l
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   2|   0|   0|   0|
+----+----+----+----+
|   0|   0|   2|   0|
+----+----+----+----+
|   2|   4|   0|   0|
+----+----+----+----+
d
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   2|   0|   0|
+----+----+----+----+
|   4|   4|   2|   0|
+----+----+----+----+
r
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   2|
+----+----+----+----+
|   0|   0|   0|   2|
+----+----+----+----+
|   0|   0|   8|   2|
+----+----+----+----+
d
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   0|   0|   0|
+----+----+----+----+
|   0|   2|   0|   2|
+----+----+----+----+
|   0|   0|   8|   4|
+----+----+----+----+

Great. Unfortunately the squares size differs when the contents change and that was one requirement stated in the question.

@Howard I'm of the persuasion that making the tiles rigidly squarelike is a lot uglier than letting them be, but there, it's fixed.

Mathematica, 484 chars
Very ugly.
m@l=#//.{{x___,0,a_/;a>0,y___}:>{x,a,0,y},{x___,a_/;a>0,a_,y___}:>{x,2 h@a,0,y}}/.h@a_:>a&;{m@u,m@d,m@r}=Composition[#,m@#2,#]&@@@{{Thread,l},{Reverse,u},{Thread,d}};a=ReplacePart[#,RandomChoice@Position[#,0]->2]&;g=a@ConstantArray[0,{4,4}];EventHandler[Dynamic[GraphicsGrid@Map[Graphics@Text@#&,g,{2}]],(#2<>"ArrowKeyDown":>If[g!=m[#]@g,g=a[m[#]@g];Which[And@@(g==m[#]@g&/@{u,l,r,d}),Print@"you lose",!FreeQ[g,2048],Print@"you win"]])&@@@{{l,"Left"},{r,"Right"},{u,"Up"},{d,"Down"}}]

Controlled by arrow keys.

Ungolfed:
move[Left] = # //. {{x___, 1, a_ /; a > 1, y___} :> {x, a, 1, y},
      {x___, a_ /; a > 1, a_, y___} :> {x, 2 Hold@a, 1, y}} /.
    Hold@a_ :> a &;
move[Up] = Composition[Transpose, move[Left], Transpose];
move[Down] = Composition[Reverse, move[Up], Reverse];
move[Right] = Composition[Transpose, move[Down], Transpose];
addTile = ReplacePart[#, RandomChoice@Position[#, 1] -> 2] &;
keyDown = If[grid != move[#][grid], grid = addTile[move[#][grid]];
    Which[And @@ (grid == move[#][grid] & /@ {Left, Right, Up, Down}),
      status = "Can't move...",
     ! FreeQ[grid, 2048], status = "2048!"]] &;
grid = addTile@ConstantArray[1, {4, 4}];
status = "";
EventHandler[Dynamic[ArrayPlot[Log2@grid/11,
   ColorFunction -> "StarryNightColors",
   ColorFunctionScaling -> False,
   Mesh -> All,
   Epilog -> {MapIndexed[
      Text[Style[#1, "Section"] //. 1 -> "", #2 - {0.5, 0.5}] &,
      Transpose@Reverse@grid, {2}],
     Text[Style[status, "Section"], {2, 2}]}]],
 {"LeftArrowKeyDown" :> keyDown[Left],
  "RightArrowKeyDown" :> keyDown[Right],
  "UpArrowKeyDown" :> keyDown[Up],
  "DownArrowKeyDown" :> keyDown[Down]}]

I like the looks of the ungolfed one!

C (C89 standard), 881 bytes
Use wasd keys to move.
Compiles in GCC and clang by default, unless set to C99 standard (I guess).
Uses termios.h, worked in Linux and MacOS X. Not sure about Windows.
#include<termios.h>
#define R return
#define H while
char t[17],*Q,*W="adws",D,x,y,X;m(x,y){R!D?x+y*4:D==1?3-x+y*4:D==2?y+x*4:y+(3-x)*4;}c(){for(y=0;y<3;++y)for(x=0;x<3;++x){D=t[x+y*4];if(t[x+1+y*4]==D||t[x+4+y*4]==D)x=y=9;}R y>4;}d(){if(strlen(t)==16)R 0;H(t[x=(rand()&15)]);R t[x]=1;}r(x){putchar(x);}b(){y=0;r(10);H(y<21)r(y++%5?45:43);r(10);}f(){for(x=0;x<17;++x)if(X=(t[x]==11))x=32;R x<18;}struct termios z;main(){srand(time(tcgetattr(0,&z)));z.c_lflag&=~ICANON;tcsetattr(0,0,&z);H(f()&&(d()||c())){x=0;H(x<16){if(!(x&3)){b();r('|');}if(y=t[x++])printf("%4u|",1<<y);else printf("    |");}b();r(10);H(!(Q=strchr(W,getchar())));D=Q-W;for(y=0;y<4;++y)for(X=0,x=1;x<4;++x)if(t[m(x,y)]){if(t[m(x,y)]==t[m(X,y)]&&t[m(X,y)]++)t[m(x,y)]=0;X=x;}do{for(y=0;y<4;++y)for(x=0;x<3;++x)if(!t[m(x,y)]&&(X=t[m(x+1,y)])){t[m(x,y)]=X;t[m(x+1,y)]=0;x=y=9;}}H(y>4);}puts(X?"you win":"you lose");}

Broken in some lines:
#include<termios.h>
#define R return
#define H while
char t[17],*Q,*W="adws",D,x,y,X;m(x,y){R!D?x+y*4:D==1?3-x+y*4:D==2?y+x*4:y+(3-x)*4;}
c(){for(y=0;y<3;++y)for(x=0;x<3;++x){D=t[x+y*4];if(t[x+1+y*4]==D||t[x+4+y*4]==D)x=y=9;}R y>4;}
d(){if(strlen(t)==16)R 0;H(t[x=(rand()&15)]);R t[x]=1;}
r(x){putchar(x);}
b(){y=0;r(10);H(y<21)r(y++%5?45:43);r(10);}
f(){for(x=0;x<17;++x)if(X=(t[x]==11))x=32;R x<18;}
struct termios z;
main(){srand(time(tcgetattr(0,&z)));z.c_lflag&=~ICANON;tcsetattr(0,0,&z);
H(f()&&(d()||c())){x=0;H(x<16){if(!(x&3)){b();r('|');}if(y=t[x++])printf("%4u|",1<<y);else printf("    |");}
b();r(10);H(!(Q=strchr(W,getchar())));D=Q-W;for(y=0;y<4;++y)for(X=0,x=1;x<4;++x)
if(t[m(x,y)]){if(t[m(x,y)]==t[m(X,y)]&&t[m(X,y)]++)t[m(x,y)]=0;X=x;}
do{for(y=0;y<4;++y)for(x=0;x<3;++x)if(!t[m(x,y)]&&(X=t[m(x+1,y)]))
{t[m(x,y)]=X;t[m(x+1,y)]=0;x=y=9;}}H(y>4);}puts(X?"you win":"you lose");}

The looks:
+----+----+----+----+
|   8|   4|   8|   2|
+----+----+----+----+
|    |  16|    |    |
+----+----+----+----+
|    |   2|    |    |
+----+----+----+----+
|    |    |    |   2|
+----+----+----+----+

It can be improved for sure.

Delphi XE3 (Waaay to many {whispers} 2.979 bytes -> ungolfed 4.560 bytes)
I like to call this "2048 code the novel"
Used more bytes than I like but it works and it was fun to do.
Im still going to try make it shorter later on.
Game in progress

Golfed
uses System.SysUtils,Windows;type TDir=(dUp,dDown,dLeft,dRight,dInv);const t='_____________________________';er='|      |      |      |      |';nr='| %s | %s | %s | %s |';br='|______|______|______|______|';fn='%d';procedure mycls;var S:String;H:DWORD;CO:_COORD;begin H:=GetStdHandle(STD_OUTPUT_HANDLE);CO.X:=0;CO.Y:=0;SetConsoleCursorPosition(H,CO);S:=StringOfChar(Chr(32),2000);Writeln(S);SetConsoleCursorPosition(H,CO);end;var a:array[1..4,1..4]of integer;c,rx,ry,i,j:int8;m:string;GameOver,gs:boolean;function hz:boolean;var b,q:int8;begin for b:=1to 4do for q:=1to 4do if a[b,q]=0 then exit(true);end;function HM:boolean;var b,q:int8;begin if hz then exit(true);for b:=1to 4do for q:=1to 4do begin c:=a[b,q];if c in [a[b-1,q],a[b+1,q],a[b,q-1],a[b,q+1]] then result:=true;end;end;procedure rn(out n,m:int8);var z:int8;begin z:=0;repeat n:=Random(4)+1;m:=Random(4)+1;z:=z+1;until(a[n,m]=0)and(z>=3);end;function gn(n:integer):string;begin if n=0 then exit('    ');Result:=IntToStr(n).PadLeft(4,' ');end;procedure pm(d:TDir;score:boolean);var b,q,z:int8;begin case d of dUp:for z:=1to 3do for b:=1to 4do for q:=1to 3do begin if score then begin if a[q,b]=a[q+1,b] then begin a[q,b]:=a[q,b]+a[q+1,b];a[q+1,b]:=0;end;end else if a[q,b]=0 then begin a[q,b]:=a[q+1,b];a[q+1,b]:=0;end;end;dDown:for z:=1to 3do for b:=1to 4do for q:=2to 4do begin if score then begin if a[q,b]=a[q-1,b] then begin a[q,b]:=a[q,b]+a[q-1,b];a[q-1,b]:=0;end;end else if a[q,b]=0 then begin a[q-1,b]:=a[q,b];a[q-1,b]:=0;end;end;dLeft:for z:=1to 3do for q:=1to 4do for b:=1to 3do begin if score then begin if a[q,b]=a[q,b+1] then a[q,b]:=a[q,b]+a[q,b+1];a[q,b+1]:=0;end else if a[q,b]=0 then begin a[q,b]:=a[q,b+1];a[q,b+1]:=0;end;end;dRight:for z:=1to 3do for q:=1to 4do for b:=2to 4do begin if score then begin if a[q,b]=a[q,b-1] then begin a[q,b]:=a[q,b]+a[q,b-1];a[q,b-1]:=0;end;end else if a[q,b]=0 then begin a[q,b]:=a[q,b-1];a[q,b-1]:=0;end;end;end;end;function gd(s:string):TDir;begin s:=lowercase(s);if s='u'then exit(dUp);if s='d'then exit(dDown);if s='l'then exit(dLeft);if s='r'then exit(dRight);exit(dInv)end;procedure dg;var z:int8;begin writeln(t);for z:=1to 4do begin writeln(er);Writeln(Format(nr,[gn(a[z,1]),gn(a[z,2]),gn(a[z,3]),gn(a[z,4])]));Writeln(br);end;end;function hw:boolean;var b,q:int8; begin for b:=1to 4do for q:=1to 4do if a[b,q]=2048 then result:=true;end;function dm:boolean;var d:Tdir;begin d:=gd(m);if d=dInv then if not gs then exit(false)else exit(true);pm(d,false);pm(d,true);pm(d,false);exit(true);end;begin gs:=true;m:='';for j:=1to 4do for i:=1to 4do begin a[i,j]:=0;end;rx:=0;ry:=0;rn(rx,ry);a[rx,ry]:=2;repeat if (dm) then begin if hz then begin rn(rx,ry);a[rx,ry]:=2;end;gs:=false;end;mycls;GameOver:=true;if hw then WriteLn('You have won!')else if HM then begin GameOver:=false;dg;writeln('Direction: [U]=up, [D]=Down, [L]=Left, [R]=Right');readln(m);end else WriteLn('Game Over, no more possible moves :('#13#10'Try again next time')until GameOver;readln;end.

Ungolfed
uses
  System.SysUtils,Windows;
type
  TDir=(dUp,dDown,dLeft,dRight,dInv);
const
  t='_____________________________';
  er='|      |      |      |      |';
  nr='| %s | %s | %s | %s |';
  br='|______|______|______|______|';
  fn='%d';
procedure mycls;
var
  S:String;
  H:DWORD;
  CO:_COORD;
begin
  H:=GetStdHandle(STD_OUTPUT_HANDLE);
  CO.X:=0;
  CO.Y:=0;
  SetConsoleCursorPosition(H,CO);
  S:=StringOfChar(Chr(32),2000);
  Writeln(S);
  SetConsoleCursorPosition(H,CO);
end;
var
  a:array[1..4,1..4]of integer;
  c,rx,ry,i,j:int8;
  m:string;
  GameOver,gs:boolean;
function hz:boolean;
var b,q:int8;
begin
  for b:=1to 4do
    for q:=1to 4do
      if a[b,q]=0 then exit(true);
end;
function HM:boolean;
var b,q:int8;
begin
  if hz then exit(true);
  for b:=1to 4do
    for q:=1to 4do
    begin
      c:=a[b,q];
      if c in [a[b-1,q],a[b+1,q],a[b,q-1],a[b,q+1]] then
        result:=true;
    end;
end;
procedure rn(out n,m:int8);
var z:int8;
begin
z:=0;
  repeat
    n:=Random(4)+1;
    m:=Random(4)+1;
    z:=z+1;
  until(a[n,m]=0)and(z>=3);
end;
function gn(n:integer):string;
begin
  if n=0 then exit('    ');
  Result:=IntToStr(n).PadLeft(4,' ');
end;
procedure pm(d:TDir;score:boolean);
var
  b,q,z:int8;
begin
  case d of
    dUp:
      for z:=1to 3do
        for b:=1to 4do
          for q:=1to 3do
          begin
            if score then
            begin
              if a[q,b]=a[q+1,b] then
              begin
                a[q,b]:=a[q,b]+a[q+1,b];a[q+1,b]:=0;
              end;
            end
            else
              if a[q,b]=0 then
              begin
                a[q,b]:=a[q+1,b];a[q+1,b]:=0;
              end;
          end;
    dDown:
      for z:=1to 3do
        for b:=1to 4do
          for q:=2to 4do
          begin
            if score then
            begin
              if a[q,b]=a[q-1,b] then
              begin
                a[q,b]:=a[q,b]+a[q-1,b];a[q-1,b]:=0;
              end;
            end
            else
              if a[q,b]=0 then
              begin
                a[q-1,b]:=a[q,b];
                a[q-1,b]:=0;
              end;
          end;
    dLeft:
      for z:=1to 3do
        for q:=1to 4do
          for b:=1to 3do
          begin
            if score then
            begin
              if a[q,b]=a[q,b+1] then
                a[q,b]:=a[q,b]+a[q,b+1];a[q,b+1]:=0;
            end
            else
              if a[q,b]=0 then
              begin
                a[q,b]:=a[q,b+1];a[q,b+1]:=0;
              end;
          end;
    dRight:
      for z:=1to 3do
        for q:=1to 4do
          for b:=2to 4do
          begin
            if score then
            begin
              if a[q,b]=a[q,b-1] then
              begin
                a[q,b]:=a[q,b]+a[q,b-1];a[q,b-1]:=0;
              end;
            end
            else
              if a[q,b]=0 then
              begin
                a[q,b]:=a[q,b-1];a[q,b-1]:=0;
              end;
          end;
  end;
end;

function gd(s:string):TDir;
begin
  s:=lowercase(s);
  if s='u'then exit(dUp);
  if s='d'then exit(dDown);
  if s='l'then exit(dLeft);
  if s='r'then exit(dRight);
  exit(dInv)
end;
procedure dg;
var z:int8;
begin
  writeln(t);
  for z:=1to 4do
  begin
    writeln(er);
    Writeln(Format(nr,[gn(a[z,1]),gn(a[z,2]),gn(a[z,3]),gn(a[z,4])]));
    Writeln(br);
  end;
end;
function hw:boolean;
var b,q:int8;
begin
  for b:=1to 4do
    for q:=1to 4do
      if a[b,q]=2048 then
        result:=true;
end;
function dm:boolean;
var
  d:Tdir;
begin
  d:=gd(m);
  if d=dInv then if not gs then exit(false)else exit(true);
  pm(d,false);
  pm(d,true);
  pm(d,false);
  exit(true);
end;
begin
    gs:=true;m:='';
    for j:=1to 4do
      for i:=1to 4do
      begin
        a[i,j]:=0;
      end;
   rx:=0;ry:=0;
   rn(rx,ry);
   a[rx,ry]:=2;
  repeat
    if (dm) then
    begin
      if hz then
      begin
        rn(rx,ry);
        a[rx,ry]:=2;
      end;
      gs:=false;
    end;
    mycls;
    GameOver:=true;
    if hw then
      WriteLn('You have won!')
    else if HM then
    begin
      GameOver:=false;
      dg;
      writeln('Direction: [U]=up, [D]=Down, [L]=Left, [R]=Right');
      readln(m);
    end
    else
      WriteLn('Game Over, no more possible moves :('#13#10'Try again next time')
  until GameOver;
  readln;
end.

2.979 bytes?  Is it supposed to be kilobytes?

Some places in the world use commas in numbers the way we use periods, I would not be all that surprised if the reverse was also true.

@undergroundmonorail True, in Europe the number one thousand and twelve comma six is often written as 1.012,6 instead of the American 1,012.6 :)

CodeGolf taught me that you can interchange , and . in numbers!

Keep this in mind when parsing numbers input by users!

Good thing this question doesn't have a leaderboard...

Java: 1346 1269
Edit So although this contest is done, sometimes I can't let go when improvements can be made. This version boasts a leaner, meaner, in-place folding function, the eviction of most boolean types except where it would be more verbose without them, and slightly smaller cells (4x4 instead of 5x5) to cut out a few extra characters there.
So this was a fun one. Thanks for posting! Ungolfed, this was 2856 bytes, golfed I shrunk it to 1346 bytes. Being Java, I'm not going to win, but I wanted to put in a good showing. Figuring out a "general" roll-up function to handle tile joins and moves was fun -- you can of course check out my "progress" by looking through the commits on my github repository for this solution.
Golfed:
import java.util.*;class T{public static void main(String[]a){(new T()).s();}int[][]b=new int[4][4];int d,p,i,j,x,y,v,q,r;boolean I,V;void s(){p();do{d();do{char a=(new Scanner(System.in)).nextLine().charAt(0);y=a=='u'?f(0,1):a=='d'?f(1,1):a=='l'?f(0,0):a=='r'?f(1,0):0;}while(y<1);p();}while((x=n())>0);d();c("you "+(x<0?"win":"lose"));}int h(){for(int[]y:b)for(int x:y)if(x<2)return 1;return 0;}int n(){for(y=0;y<4;y++){for(x=0;x<4;x++){i=b[y][x];if(x<3&&i==b[y][x+1]||y<3&&i==b[y+1][x])return 1;if(i>2047)return -1;}}return h();}int f(int w,int z){I=w>0;V=z>0;for(i=d=0;i<4;i++){p=I?3:0;for(j=1;j<4;){v=V?i:j;x=I?3-v:v;v=V?j:i;y=I?3-v:v;q=V?x:p;r=V?p:y;if(b[y][x]==0||p==(V?y:x))j++;else if(b[r][q]==0){d+=b[r][q]=b[y][x];b[y][x]=0;j++;}else if(b[r][q]==b[y][x]){d+=b[r][q]*=2;b[y][x]=0;p+=I?-1:1;j++;}else p+=I?-1:1;}}return d;}int v(){return(new Random()).nextInt(4);}void p(){if(h()<1)return;do{x=v();y=v();}while(b[x][y]>0);b[x][y]=2;}void c(String a){System.out.println(a);}String l(char n,char m){String s=""+n;for(i=0;i<4;i++){for(j=0;j<4;j++)s+=m;s+=n;}return s;}void d(){c(l('+','-'));String p[]=new String[5];for(int[]y:b){p[0]=p[1]=p[3]=l('|',' ');p[2]="";for(x=0;x<4;)p[2]+=String.format("|%4d",y[x++]);p[2]+="|";p[4]=l('+','-');for(String q:p)c(q);}}}

Ungolfed: (Check my github repository for this project for an updated version, including an assertions-based test for new folding functions)
import java.util.*;
class Twe {
    public static void main(String[] a){
        (new Twe()).start();
    }
    int[][] board=new int[4][4];
    void start(){
        int x;
        placeTwo();
        do{
            drawBoard();
            resolve();
            placeTwo();
        }while((x=notDone())>0);
        drawBoard();
        wrapup(x);
    }
    int hasFree(){
        for(int[]y:board)
            for(int x:y)
                if(x<2)return 1;
        return 0;
    }
    int notDone(){
        int moves,x,y;
        for(moves=y=0;y<4;y++){
            for(x=0;x<4;x++){
                else if(x<3&&board[y][x]==board[y][x+1]||
                        y<3&&board[y][x]==board[y+1][x])moves++;
                if(board[y][x]>2047)return -1;
            }
        }
        return hasFree()+moves;
    }
    void wrapup(int k){
        if(k<0){
            chalk("you win",true);
        }else{
            chalk("you lose",true);
        }
    }
    void resolve(){
        do{
            switch((new Scanner(System.in)).nextLine().charAt(0)){
                case 'u':
                    if (fold(false,true)>0)return;
                    break;
                case 'd':
                    if (fold(true, true)>0)return;
                    break;
                case 'l':
                    if (fold(false,false)>0)return;
                    break;
                case 'r':
                    if (fold(true,false)>0)return;
                    break;
                case 'z':
                    board[0][0]=2048; // instant win;
                    return;
            }
        } while(true);
    }
    // false,true  = up
    // true, true  = down
    // false,false = left
    // true, false = right
    int fold(boolean inv, boolean vert){
        int didMove=0;
        int nextSpot,x,y,v,q,r;
        int[][] nb = new int[4][4];
        for(int i=0;i<4;i++){
            nextSpot=inv?3:0;
            for(int j=0;j<4;j++){
                v=vert?i:j;
                x=inv?3-v:v;
                v=vert?j:i;
                y=inv?3-v:v;
                q=vert?x:nextSpot;
                r=vert?nextSpot:y;
                if(board[y][x]>0){
                    if(nb[r][q]<1){
                        nb[r][q]=board[y][x];
                        didMove+=(inv?-1:1)*(vert?y-r:x-q);
                    }else if(nb[r][q]==board[y][x]){
                        nb[r][q]*=2;
                        nextSpot+=inv?-1:1;
                        didMove++;
                    }else{
                        nextSpot+=inv?-1:1;//suckage
                        q=vert?x:nextSpot;
                        r=vert?nextSpot:y;
                        nb[r][q]=board[y][x];
                        didMove+=(inv?-1:1)*(vert?y-r:x-q);
                    }
                }
            }
        }
        board=nb;
        return didMove;
    }
    int vec(){
        return (new Random()).nextInt(4);
    }
    void placeTwo(){
        if (hasFree()<1) return;
        int x,y;
        do{
            x=vec();y=vec();
        }while(board[x][y]>0);
        board[x][y]=2;
    }
    void chalk(String a, boolean nl){
        System.out.print(a+(nl?"\n":""));
    }
    String fill(char node, char mid){
        String str = ""+node;
        for(int i=0;i<4;i++){
            for(int j=0;j<5;j++)
                str+=mid;
            str+=node;
        }
        return str;
    }
    void drawBoard(){
        chalk(fill('+','-'),true);
        String p[] = new String[6];
        for(int[]y:board){
            p[0]=p[1]=p[3]=p[4]=fill('|',' ');
            p[2]="";
            for(int x=0;x<4;){
                p[2]+=adjust(y[x++]);
            }
            p[2]+="|";
            p[5]=fill('+','-');
            for (String q:p){
                chalk(q,true);
            }
        }
    }
    String adjust(int a){
        return String.format("|%5d",a);
    }
}

Using the program is simple. To build and run:
javac T.java
java T

Press u to fold up, r to fold right, d to fold down, l to fold left. Any other key is ignored, invalid (no result) moves are ignored. Being Java, press enter after each key to flush the line buffer. As required by the rules, if you win the program outputs you win, if you lose the program outputs you lose. New 2's are placed randomly in the open tiles. Merges follow the stated rules. Cells are 4x4 characters, with a border surrounding each cell. Of course, leave me a comment if I've messed something up and I'll be certain to fix it.
Example output:
$ java T
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
u
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   2|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
l
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
u
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   4|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   2|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
l
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   4|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   4|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   2|
|    |    |    |    |
+----+----+----+----+
u
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   8|   2|   0|   2|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
l
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   8|   4|   2|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
l
u
d
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   2|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   8|   4|   2|   0|
|    |    |    |    |
+----+----+----+----+
d
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   2|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   8|   4|   4|   0|
|    |    |    |    |
+----+----+----+----+
l
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   2|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   8|   8|   0|   0|
|    |    |    |    |
+----+----+----+----+
l
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   2|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   2|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|  16|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
d
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   2|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   4|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|  16|   2|   0|   0|
|    |    |    |    |
+----+----+----+----+
d
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   0|   0|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|   4|   2|   0|   0|
|    |    |    |    |
+----+----+----+----+
|    |    |    |    |
|    |    |    |    |
|  16|   4|   0|   0|
|    |    |    |    |
+----+----+----+----+

Lua, 622 616 615 612 592 590 575 bytes
Queries stdin for 1,2,3,4 correlating with left, down, right, up (made for numpad input); crashes if you give it bad input.
Blank squares are printed as '0's.
b={('\0'):rep(16):byte(1,16)}c=1 a=print h=unpack while{}do if c then c=z
e={}for i=1,16 do e[#e+1]=0==b[i]and i or z end _=#e==0 and
a'you lose'b[e[math.random(#e)]]=2 l=('+----'):rep(4)..'+\n'm=l:gsub('-',' ')for
i=1,13,4 do a(l..m..m..m..('+%4d+%4d+%4d+%4d+'):format(h(b,i)))end a(l)end c=z
u,v,w=h({4,1,-4,1,-4,16,4,-1,1,1,4,-4},3*io.read()-2)for i=1,4 do o=-1 for j=2,4
do if 0~=b[u*i+v*j+w]then for k=1-j,o do p=u*i-v*k+w q=p+v r=b[p]if r==0 then
b[p]=b[q]b[q]=r c=1 o=k elseif r==b[q]then _=r==1024 and a'you win'b[p]=r*2
b[q]=0 c=1 o=k-1 break end end end end end end

Example output:
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   2+   0+   0+   0+
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   0+   0+   0+   0+
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   0+   0+   0+   0+
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   0+   0+   0+   0+
+----+----+----+----+

2
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   0+   2+   0+   0+
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   0+   0+   0+   0+
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   0+   0+   0+   0+
+----+----+----+----+
+    +    +    +    +
+    +    +    +    +
+    +    +    +    +
+   2+   0+   0+   0+
+----+----+----+----+

Clojure: 599
run it in a REPL
golfed
(defn i[b](let[f(into[](flatten b))z(seq(keep-indexed #(when(zero? %2)%1)f))]
(cond(some #{2048}f)(pr "you win")(empty? z)(pr "game over"):e(partition 4
(assoc f(rand-nth z)2)))))(def r #(remove zero? %))(loop[b(i (partition 4
(repeat 16 0)))](when((fn[v](doseq[l(for[a v](apply str(map #(format "%5d " %)a)))]
(println l "\n"))v)b)(-> b((apply comp(assoc(into[](repeat 5(fn[v]
(map(fn[n](map #(nth % n)v))[3 2 1 0]))))({"h"4 "k"3 "l"2 "j"1}(read-line))
(partial map(comp #(take 4(concat % [0 0 0 0]))(fn[v]
(r(reduce #(let[l(last %1)](if(= %2 l)(conj(pop %1)(+ l %2) 0)
(conj %1 %2)))[]v)))r)))))i recur)))

ungolfed
(defn insert-2 [board]
  (let [flat (into [] (flatten board))
        zero-indices (seq (keep-indexed
                       #(when (zero? %2) %1)
                       flat))]
    (cond
      (some #{2048} flat) (pr "you win")
      (empty? zero-indices) (pr "game over")
      :else (partition 4 (assoc flat (rand-nth zero-indices) 2)))))

(defn rotate [board]
  (map
    (fn [n]
        (map #(nth % n)
             board))
    [3 2 1 0]))

(defn remove-zeros [row]
 (remove zero? row))

(defn fill [row]
 (take 4 (concat row [0 0 0 0])))

(defn sum-up [acc x]
  (let [l (last acc)]
    (if (= x l)
      (conj (pop acc) (+ l x) 0)
      (conj acc x))))

(defn sum-pairs [v]
  (remove-zeros (reduce sum-up [] v)))

(defn render [v]
  (doseq [line (for [row v]
                 (apply str (map #(format "%5d " %) row)))]
    (println line "\n")) v)

(defn slide [board]
 (map (comp
        fill
        sum-pairs
        remove-zeros
        ) board))

(loop [board (insert-2 (partition 4 (repeat 16 0)))]
  (when (render board)
    (let [input ({"h" 4 "k" 3 "l" 2 "j" 1} (read-line))
          command (apply comp
                         (assoc (into [] (repeat 5 rotate))
                                input slide))] ;; (comp rotate rotate slide rotate rotate)
      (-> board command insert-2 recur))))

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


text:
π Day puzzle for 3/14

Happy π Day. The goal of this question is to calculate the area for a circle of radius 3, where A = πr².
The catch is that you have to use the constant π that is defined in a different language than the one you are programming in. For example, you can write a C program that uses Fortran's MATH::PI, or a Python program that uses Java's java.lang.Math.PI.
Rules:

Your code must use a stored value of π from a different language for the calculation. (i.e. it must be stored in a constant or math library.)
All of the code for your program must fit in a single file. For example, You cannot write one program in C to print π, then another in Java to run the C program. (However, you can write a Java program that writes and compiles a C program by itself.)
You cannot download π from a webpage and claim that your constant came from PHP/ASP/HTML.

Here is an example that runs in Bash, and uses Python's stored math.pi value:
#!/bin/bash
PI=`python -c 'import math; print math.pi'`
bc -l <<< "3 * 3 * $PI"

Output:
28.27433388231

This is a Popularity Contest, so the entry with the most votes after a week wins.
Edit: After one week, the prize goes to DigitalTrauma with 93 points. Thanks for the awesome assembler tip - I did not know that the the FPU stored the constant in hardware. I expected this contest to be about finding funny ways to throw clock cycles away, but that one could actually save a few.
* Image courtesy of: http://xkcd.com/10/

It's the 3rd day of the 14th month?? My calendar must be broken.

You beat me to posting a Pi Day challenge :P

Next year: 3/14/15 at 9:26 and 53sec, i will post a challenge

Ugh. Tau is better. And this.

@bjb I agree, Tau makes more sense, but that doesn't mean we can't have a little fun in mid march. :)

@under Whada you mean? There's National Pig Day!

22/7 is a better pi day.

I'm not sure what Pi day is, but this would have been excellent for Tau/2 day yesterday.

How intriguing. On π day, my reputation was 314.

@tbodt How intriguing.  On π day (and on all other days), a new user starts with a reputation of 314/314.

http://xkcd.com/1292/ (seriously, stop this tau silliness).

Have anyone spotted, that this time it is not only pi day but a pi month?

I really dislike this whole "pi day" thing because it focuses on the complete wrong aspect of pi: its decimal radix form. Pi is important because it is the half period of exp(x*sqrt(-1)) WRT x, so pi day should be at the half periods of the tropical year, i.e. January 1st and July 2nd/3rd.

@TheDoctor Except, you didn't.

C + x86 assembly
Not satisfied with a constant defined in the software of your language?  Why not use a language that can access a constant value of PI right from your FPU hardware:
#include <stdio.h>

int main (int argc, char **argv) {
    double pi;
    __asm__("fldpi" : "=t" (pi));
    printf("%g\n", 3 * 3 * pi);
    return (0);
}

Holy crap, there's an instruction just to load the value of pi.

x86 has instructions for EVERYTHING.

@user2357112 There are 7 instructions just for loading "commonly used constants"

Good choices for the 7 constants, too! I'm always using log_e(2), but not, say, 2.

@TimS. My intuition tells me these FPU transistors would be better used for improving performance of say FDIV (and letting software load such constants from memory), rather than storing all these constants on the FPU.  But I'm not a chip designer - what do I know :)

@TimS. log_e(2) is not equal to log(exp(2)) = 2, but actually is the natural logarithm of 2...

@MathieuRodic yes, but the point is that fld qword [2.0] is a 9 byte instruction, and fldln2 is a two byte instruction. The irony of @TimS.' comment is that there's plenty of constants that would have been more useful, such as -1, or 2.

@fluffy my x86 core is broken: I tried MOV AX, c0ffe; ADD MILK; ADD SUGAR; ADD SUGAR; MOV ecx, c0ffe; MOV ebx,1; MOV eax,4 and my bios speaker laughed at me.....

@GMasucci Your mistake was trying to use the general-purpose MOV instruction on the special coffee registers. You need to use the coffee-specific instructions.

Python, bash, C, J, PHP and Python3
import subprocess

p = subprocess.Popen("""
echo '
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>

int main(int pi) {
    if (pi == 1) printf("%.5f", M_PI);
    if (pi == 2) printf("o. 1");
    if (pi == 3) printf("<?php printf(\\"%%.5f\\", pi()); ?>");
    if (pi == 4) printf("import math; print(\\" %%.5f\\" %% math.pi)");
    return 0;
}
' > gcc -o pi
./pi
./pi J | jc
./pi and PHP | php
./pi and Python 3 | python3
""", shell=True, stdout=subprocess.PIPE)

values_of_pi = map(float, map(str.strip, p.stdout.read().split()))
pi = max(values_of_pi, key=values_of_pi.count)

print pi * 3 * 3

Just to be safe, this program retrieves pi from a few different languages, taking the most agreed upon value. More languages can easily be added for greater reliability.

I just threw up a little in my mouth.

What's J and why are you running your C program with it?

@NoBugs J is another language, and I'm running it (jc is the J console on my computer) with output from my C program (o. 1) to get another value of pi. The arguments aren't important.

echo $long_string > gcc -o pi? I can't believe no one caught this. Also, have you heard of here-docs|here-strings?

This is one of the coolest pieces of code I have ever seen. I am going to frame this and put it on my wall. Possibly with a warning.

PHP/MYSQL
$link = mysqli_connect("localhost", "user", "password", "dbname");
$query = mysqli_query($link, 'SELECT PI() AS pi');
$row = mysqli_fetch_assoc($query);
echo 3*3*$row['pi'];

Very clever. Using a very standard way of interfacing different runtimes. =) +1

Perl/Tk with C, Pascal, Java, JavaScript, LaTeX3, Prolog, Perl, Scheme, Lua, Python, TeX/PGF
The following Perl script displays a windows that lists the values of π and the calculated area. The value of π is taken from different languages
as shown below.

The one-file script:
#!/usr/bin/env perl
use strict;
$^W=1;

use Tk;
use Tk::Font;
use Tk::HList;
use Tk::ItemStyle;
use Tk::PNG;

# Function to calculate the area of the circle with radius 3
sub A ($) {
    use bignum;
    return 9*$_[0];
}

my $title = 'Pi Day';

# Configuration of external program names
my %prg = qw[
    Pascal fpc
    Perl perl
    Prolog swipl
    Scheme guile1
    TeX  tex
    LaTeX latex
];
sub prg ($) {
    my $prg = shift;
    return $prg{$prg} // $prg;
}

# Column headers
my @header = (
    '',
    'Language',
    "\N{U+03C0}",
    "A(3) = A(r) = \N{U+03C0}\N{U+2009}r\N{U+00B2}",
);

my $mw = MainWindow->new(
    -title => $title,
);

# Font setup (larger font)
my $font_size = '22';
my $font = $mw->Font();
$font->configure(-size => $font_size);

# ---------
# Utilities
# ---------

# Run program in backticks, quote arguments if needed and some error checking
sub backticks_pi (@) {
    my @cmd = map{/[ ()$;<>|\x22]/ && length > 1 ? "'$_'" : $_} @_;
    print "[@cmd]\n";
    my $catch = `@cmd`;
    if ($? == -1) {
        warn "Failed to execute: $!\n";
    }
    elsif ($? & 127) {
        warn sprintf "Child died with signal %d!\n", $? & 127;
    }
    elsif ($?) {
        warn sprintf "Child exited with value %d!\n", $? >> 8;
    }
    else {
        return $1 if $catch =~ /^\s*(\d+\.\d+)\s*$/
                  or $catch =~ /\bpi\s*=\s*(\d+\.\d+)/;
    }
    warn "Could not find pi in the output of \"@cmd\"!\n";
    return 0;
}

# Run a program with error checking
sub run_cmd (@) {
    print "[@_]\n";
    system @_;
    if ($? == -1) {
        warn "Failed to execute: $!\n";
    }
    elsif ($? & 127) {
        warn sprintf "Child died with signal %d!\n", $? & 127;
    }
    elsif ($?) {
        warn sprintf "Child exited with value %d!\n", $? >> 8;
    }
    else {
        return $1;
    }
    return undef;
}

# Create a bitmap logo
sub make_logo ($$$@) {
    my $name = shift;
    my $logo = shift;
    my $contents = shift;
    my $file = "piday-logo-$name.tmp";
    if ($contents) {
        open(OUT, '>', $file) or die "!!! Error: Cannot write `$file': $!";
        print OUT $contents;
        close(OUT);
    }
    foreach (@_) {
        run_cmd @$_;
    }
    return $mw->Photo(
        -file => $logo,
    ) if -f $logo;
    return undef;
}

# Call foreign language to calculate pi
sub make_pi ($$@) {
    my $file = shift;
    my $source = shift;
    if ($source) {
        open(OUT, '>', $file) or die "!!! Error: Cannot write `$file': $!";
        print OUT $source;
        close(OUT);
    }
    my $cmd_last = pop;
    foreach (@_) {
        run_cmd @$_;
    }
    return backticks_pi @$cmd_last;
}

# Add result list table
my $h = $mw->HList(
    -header  => 1,
    -columns => scalar @header,
    -width   => 100,
    -height  => 20,
    -font    => $font,
)->pack(
  -expand => 1,
  -fill => 'both',
);

# Add header for the result list table
for (0 .. @header-1) {
    $h->header('create', $_,
        -text => $header[$_],
    );
}

# Exit button
my $quit = $mw->Button(
    -text => 'Quit',
    -command => sub {exit},
    -font => $font,
)->pack;

my @list;
my @cmd;
my $pi;
my $source;
my $img;

# GNU C
# -----

$img = make_logo(
    'C',
    'piday-logo-c.png',
    '',
    [
        prg('wget'),
        '-O', 'piday-logo-c-gccegg.png',
        'http://gcc.gnu.org/img/gccegg-65.png',
    ],
    [
        prg('convert'),
        '-scale', '54x64',
        'piday-logo-c-gccegg.png',
        'piday-logo-c.png',
    ],
);

$source = <<'END_SOURCE';
#define _GNU_SOURCE
#include <math.h>
#include <stdio.h>

#define xstr(s) str(s)
#define str(s) #s

int main() {
  long double pi = M_PI;
  printf("pi=%s", xstr(M_PIl));
  return 0;
}
END_SOURCE

$pi = make_pi(
    'piday-c.c',
    $source,
    [
        prg('gcc'),
        '-o', 'piday-c',
        'piday-c.c',
    ],
    [
        prg('./piday-c')
    ],
);

push @list, {
    language => 'GNU C',
    pi       => $pi,
    image    => $img,
};

# Java
# ----

$img = make_logo(
    'Java',
    'piday-java.png',
    '',
    [
        prg('wget'),
        '-O', 'piday-java.svg',
        'https://upload.wikimedia.org/wikipedia/commons/a/a4/Java_logo_and_wordmark.svg',
    ],
    [
        prg('convert'),
        '-scale', '35x64',
        'piday-java.svg',
        'piday-java.png',
    ],
);

$source = <<'END_SOURCE';
public class PiDayJava {
    public static void main(String args[]) {
        System.out.println(Math.PI);
    }
}
END_SOURCE

$pi = make_pi(
    'PiDayJava.java',
    $source,
    [
        prg('javac'),
        'PiDayJava.java',
    ],
    [
        prg('java'),
        'PiDayJava',
    ],
);
push @list, {
    language => 'Java',
    pi       => $pi,
    image    => $img,
};

# Perl
# ----

# Math/Complex.pm: sub pi () { 4 * CORE::atan2(1, 1) }
@cmd = (prg('Perl'), '-e', 'use Math::Complex; print pi');
$pi = backticks_pi @cmd;

my $img = Tk->findINC('Camel.xpm');
$img = $mw->Photo(
    -file => $img,
);

push @list, {
    language => 'Perl',
    pi => $pi,
    image => $img,
};

# Python
# ------

@cmd = (
    prg('echo'),
    'import math;print math.pi',
    '|',
    prg('python'),
);
$pi = backticks_pi @cmd;

$img = make_logo(
    'python',
    'piday-logo-python.png',
    '',
    [
        prg('wget'),
        '-O',
        'piday-logo-python-master.png',
        'http://www.python.org/static/community_logos/python-logo-master-v3-TM.png',
    ],
    [
        prg('convert'),
        '-crop', '111x111+79+33',
        'piday-logo-python-master.png',
        'piday-logo-python-crop.png'
    ],
    [
        prg('convert'),
        '-scale', '64x64',
        'piday-logo-python-crop.png',
        'piday-logo-python.png',
    ],
);

push @list, {
    language => 'Python',
    pi => $pi,
    image => $img,
};

# TeX
# ---

@cmd = (
    prg('TeX'),
    '\input pgf \pgfmathparse{pi}\message{pi=\pgfmathresult}\end',
);
$pi = backticks_pi @cmd;
my $img = make_logo(
    'tex',
    'piday-logo-tex.png',
    '',
    [
        prg('pdftex'),
        '\mag=4000 \nopagenumbers\font\sc=cmcsc10 \sc pgf\bye'
    ],
    [
        prg('pdfcrop'),
        'texput.pdf',
        'piday-logo-tex.pdf',
    ],
    [
        prg('convert'),
        'piday-logo-tex.pdf',
        'piday-logo-tex.png',
    ]
);
push @list, {
    language => 'TeX/PGF',
    pi => $pi,
    image => $img,
};

# LaTeX3
# ------

my $logo_source = <<'END_LOGO';
\mag=4000
\documentclass{article}
\usepackage{hologo}
\pagestyle{empty}
\begin{document}
\hologo{LaTeX3}
\end{document}
END_LOGO

$img = make_logo(
    'latex3',
    'piday-logo-latex3.png',
    $logo_source,
    [
        prg('pdflatex'),
        'piday-logo-latex3.tmp'
    ],
    [
        prg('pdfcrop'),
        'piday-logo-latex3.pdf',
        'piday-logo-latex3-crop.pdf',
    ],
    [
        prg('convert'),
        'piday-logo-latex3-crop.pdf',
        'piday-logo-latex3.png',
    ]
);
$source = <<'END_LATEX3';
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\msg_term:n { pi=\fp_eval:n { pi } }
\ExplSyntaxOff
\stop
END_LATEX3
$pi = make_pi(
    'piday-latex3.tex',
    $source,
    [
        prg('LaTeX'),
        'piday-latex3.tex',
    ],
);
push @list, {
    language => 'LaTeX3',
    pi => $pi,
    image => $img,
};

print "****************\n";

# Lua
# ---

$img = make_logo(
    'Lua',
    'piday-logo-lua.png',
    '',
    [
        prg('wget'),
        '-O', 'piday-logo-lua.gif',
        'http://www.lua.org/images/lua-logo.gif',
    ],
    [
        prg('convert'),
        '-scale', '64x64', # '50x50',
        'piday-logo-lua.gif',
        'piday-logo-lua.png',
    ],
);

$source = 'print(math.pi)';
$pi = make_pi(
    'piday-lua.lua',
    $source,
    [
        prg('texlua'),
        'piday-lua.lua',
    ]
);
push @list, {
    language => 'Lua',
    pi => $pi,
    image => $img,
};

# JavaScript
# ----------

$img = make_logo(
    'JavaScript',
    'piday-logo-javascript.png',
    '',
    [
        prg('wget'),
        '-O', 'piday-logo-rhino.jpg',
        'https://developer.mozilla.org/@api/deki/files/832/=Rhino.jpg',
    ],
    [
        prg('convert'),
        '-scale', '127x64',
        'piday-logo-rhino.jpg',
        'piday-logo-javascript.png',
    ],
);

$source = 'print(Math.PI)';
$pi = backticks_pi(
    prg('java'),
    '-cp', prg('js.jar'),
    'org.mozilla.javascript.tools.shell.Main',
    '-e', $source,
);
push @list, {
    language => 'JavaScript',
    pi => $pi,
    image => $img,
};

# Scheme
# ------

$img = make_logo(
    'Scheme',
    'piday-logo-scheme.png',
    '',
    [
        prg('wget'),
        '-O', 'piday-logo-lambda.svg',
        'https://upload.wikimedia.org/wikipedia/commons/3/39/Lambda_lc.svg',
    ],
    [
        prg('convert'),
        '-scale', '64x64',
        'piday-logo-lambda.svg',
        'piday-logo-scheme.png',
    ],
);
$source = '(display (* 2 (acos 0)))';
$pi = backticks_pi(
    prg('Scheme'),
    '-c', $source,
);
push @list, {
    language => 'Scheme',
    pi => $pi,
    image => $img,
};

# Prolog
# ------

$img = make_logo(
    'Prolog',
    'piday-logo-prolog.png',
    '',
    [
        prg('wget'),
        '-O', 'piday-logo-swipl.png',
        'http://www.swi-prolog.org/icons/swipl.png',
    ],
    [
        prg('convert'),
        '-scale', '78x64',
        'piday-logo-swipl.png',
        'piday-logo-prolog.png',
    ],
);
$source = ":- format('~15f~n', [pi]).\n";
$pi = make_pi(
    'piday-prolog.pro',
    $source,
    [
        prg('Prolog'),
        '-c', 'piday-prolog.pro',
    ]
);
push @list, {
    language => 'Prolog',
    pi => $pi,
    image => $img,
};

# Pascal
# ------

$img = make_logo(
    'Pascal',
    'piday-logo-pascal.gif',
    '',
    [
        prg('wget'),
        '-O', 'piday-logo-pascal.gif',
        'http://www.freepascal.org/pic/logo.gif',
    ]
);
$source = <<'END_PASCAL';
program piday_pascal;

uses sysutils, math;

begin
  writeln(format('%.16f', [pi]));
end.
END_PASCAL
$pi = make_pi(
    'piday-pascal.pas',
    $source,
    [
        prg('Pascal'),
        'piday-pascal.pas',
    ],
    [
        prg('./piday-pascal'),
    ]
);
push @list, {
    language => 'Pascal',
    pi => $pi,
    image => $img,
};

# Sort and fill the table rows
@list = sort {
    my $diff = (length $b->{'pi'} <=> length $a->{'pi'});
    return $diff if $diff;
    return "\L$a->{'language'}\E" cmp "\L$b->{'language'}\E";
} @list;

foreach my $x (@list) {
    my $e = $h->addchild("");
    my $col = 0;
    if ($x->{'image'}) {
        $h->itemCreate($e, $col++,
            -itemtype => 'image',
            -image => $x->{'image'},
        );
    }
    else {
        $col++;
    }
    $h->itemCreate($e, $col++,
        -itemtype => 'text',
        -text => $x->{'language'},
    );
    $h->itemCreate($e, $col++,
        -itemtype => 'text',
        -text => $x->{'pi'},
    );
    $h->itemCreate($e, $col++,
        -itemtype => 'text',
        -text => A $x->{'pi'},
    );
}

MainLoop;

__END__

Languages
The following list shows the languages and the code that is used to get π.

GNU C: GNU extensions are used to get a higher precision of π.
#define _GNU_SOURCE
#include <math.h>
#include <stdio.h>

#define xstr(s) str(s)
#define str(s) #s

int main() {
    long double pi = M_PI;
    printf("pi=%s", xstr(M_PIl));
    return 0;
}

Pascal: Compiled with Free Pascal.
program piday_pascal;

uses sysutils, math;

begin
  writeln(format('%.16f', [pi]));
end.

Java:
public class PiDayJava {
    public static void main(String args[]) {
        System.out.println(Math.PI);
    }
}

JavaScript: Rhino is used for executing JavaScript.
print(Math.PI)

LaTeX3:
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\msg_term:n { pi=\fp_eval:n { pi } }
\ExplSyntaxOff
\stop

Prolog: SWI Prolog is used as Prolog compiler.
:- format('~15f~n', [pi]).

Perl: For fun and completeness.
use Math::Complex;
print pi;

Scheme: The uses Scheme implementation is GNU Guile.
(display (* 2 (acos 0)))

Lua: texlua is used as Lua interpreter.
print(math.pi)

Python:
import math
print math.pi

TeX/PGF: π is taken from its definition of package pgf and plain TeX is used as TeX format:
\input pgf
\pgfmathparse{pi}
\message{pi=\pgfmathresult}
\end

dg
print ((import '/math/pi')*3**2)

How it works:
dg is a language that compiles to CPython bytecode. Conveniently, it's compatible with python libraries. import statements in dg return the object they're importing, so this program basically does this:
print (<PYTHON'S MATH.PI>*3**2)

No, I don't expect any upvotes. :)

Oopsy daisy, I think I upvoted ;)

By the way, this is the first thing I ever did in dg. Someone else used it for a golf question and linked to the same place I linked to in this answer. I read it and thought the language looked neat (despite the fact that I despise the doge meme) but didn't plan on using it until about an hour after learning about it, when I read this question and realized I could abuse it.

5 hours ago, when I posted my first comment, this had but 1 upvote. I think people did take my comment seriously ;)
Or they just used yours.

"All the code must fit in a single line". At least some people can read!

<PYTHON'S MATH.PI> Those repr() strings you get for functions and other objects that don't|can't define their __repr__()s to be valid reconstructions of themselves aren't actually…well…valid. Try __import__('math').pi.

Was going to do the same thing with Scala as it is not Java ;-)

Wow. Much code. So pi.

C++ & Lua 5.2
Nothing says overkill quite like embedding an entire language interpreter to access the pi constant.
#include <lua.hpp>
#include <cmath>
#include <iostream>

#define R 3

int main( void )
{
    lua_State* vm = luaL_newstate();

    luaL_openlibs( vm );
    luaL_dostring( vm, "function get_pi() return math.pi end" );
    lua_getglobal( vm, "get_pi" );
    lua_call( vm, 0, 1 );

    lua_Number PI_ = lua_tonumber( vm, -1 );

    std::cout << PI_ * pow( R, 2 ) << std::endl;

    lua_close( vm );
    return 0;
}

could've just... lua_getglobal("math");lua_getfield(-1,"pi");

@mniip I realized that after I posted. It's early in the morning and my brain isn't fully operational yet, but this way works just as well so I left it alone.

bash + PHP + bc
A fairly simple one-liner:
echo "scale=14;3*3*`php -r 'echo pi();'`"|bc

Output:
28.274333882308

"All the code must fit in a single line". At least some people can read!

@Floris: Hate to break it to you, but the question says file, not line.

@dennis - apparently I am not "some people"... :-/

MATLAB + Java (21 bytes)
Not sure if MATLAB is cheating, but here we go
java.lang.Math.PI*3^2

Output: Format Short
28.2743

Output: Format Long
28.2743338823081

Formatting type does not affect the value that is stored, it only impacts how it is printed out into the console

MATLAB.. -shudders-

@theGreenCabbage haha, not sure if that is a good shudder or a bad one :) In my experience it has made writing simple things quickly very easy. Of course there are better alternatives, but if there is not a lot of time, MATLAB does the trick.

Bash, Node, Ruby, Python
#!/bin/bash

node -pe 'Math.PI' \
| ruby -e 'puts ARGF.read.to_f * 3' \
| python -c 'import sys; print(float(sys.stdin.read()) * 3)'

perl
perl -ne '/M_PI\s*([\d.]*)/&&print $1*3*3' < /usr/include/math.h

+1, even though it doesn't actually work in OS X (math.h includes other files from architecture/*/math.h depending on the target platform)

Well it doesn't work on Windows either, but I'm not going for portability here :)

JavaScript/PHP
Has to be saved as a *.php file and called in a browser from some server which interprets PHP.
<script type="text/javascript">
    alert(3*3*<?php echo M_PI;?>);
</script>

Could be golfed by using short tags and substituting 3*3 with 9 (is this allowed?):
<script type="text/javascript">
    alert(9*<?=M_PI?>);
</script>

pi() has the same length as M_PI, so there's no winner.

"is this allowed"  - sure, it's not code golf but popularity contest.

This will not run neither in php nor javascript though.

Yeah, it needs some <script> tags and a .php extension.

I edited it although I think it was understandable enough...

@Cthulhu "Has to be saved as a *.php file and called in a browser from some server which interprets PHP." Using pure .html or .php or .whatever files won't work, you need apache or something like that.

Powershell + MS SQL Server
Here is one for Powershell and SQL server (from 2005 up)
add-pssnapin sqlserverprovidersnapin100
add-pssnapin sqlservercmdletsnapin100
$pi=Invoke-Sqlcmd -query "select PI() as sql"
$pi.sql *3*3

and here as a single liner:
add-pssnapin sqlserverprovidersnapin100;add-pssnapin sqlservercmdletsnapin100;(Invoke-Sqlcmd -query "select PI() as sql").sql*3*3

Will post some more later on:)

Emacs Lisp: writing, compiling, and running C
(with-temp-buffer
  (with-temp-file"/#rad.c"(insert"#include<math.h>\n#include<stdio.h>\nint main(void){printf(\"%f\",M_PI*3*3);}"))
  (shell-command"gcc /#rad.c -o /#rad && /#rad"(current-buffer))(string-to-number(buffer-string)))

ungolfed
(with-temp-buffer
  (with-temp-file "/#rad.c"
    (insert"
#include<math.h>
#include<stdio.h>
int main(void){
  printf(\"%f\",M_PI*3*3);
}"))
  (shell-command "gcc /#rad.c -o /#rad && /#rad"
         (current-buffer))
  (string-to-number(buffer-string)))

bonus:
You could triple language this one by running emacs in batch using -eval and surrounding the expression in (print). This would result in Bash running lisp which writes compiles and runs C reads the output and prints it out to your shell in bash.

For this question, I created my own language,called Digits. The syntax consists of p, a constant representing pi, and digits. When run, it returns all of the digits (and p) multiplied together. Here is my interpreter and code, written in Python:
def interpret(kode):
    out=1.0
    for i in kode:
        if(i=='p'):
            out*=3.14159265
        else:
            out*=int(i)
    return out
print(interpret("p33"))

Looks to me more like a function in Python than a language, but it works.

@hosch250 The python interpreter itself is a (set of) function written in C (in the case of CPython) so this answer is very valid. Quite clever I would say.

bc + dc + bash (30 chars for the golfers)
Here's a golfy little one:
$ dc<<<"3d*`bc -l<<<'a(1)*4'`*p"
28.27433388230813914596
$

bc -l<<<'a(1)*4' produces pi (it is stored as a constant in the bc math lib for the a() (arctan) function.
dc<<<"3d*pi*p" pushes 3 to the stack, duplicates the value on the top of the stack (3) and multiples, then pushes pi to the stack and multiples, then prints the top of the stack.

OCaml + awk
Nobody likes OCaml?

Use OCaml to compute Pi
awk to calculate Pi*r2

Here it is:
ocaml <<< "4.0 *. atan 1.0;;" | awk '/float/{printf("%.12f", 3*3*$NF)}'

The answer is:
28.274333882308

VimScript + Python
:py import math
:ec pyeval("math.py")*3*3

result:
28.274334

C++/C
#include <math.h>
#include <iostream>

int main(int argc, char** argv) {
    std::cout << 3*3*M_PI << std::endl;
    return 0;
}

Welcome to the site! But I think the question is looking for a program that actually calls a function or compiles a program in another language, not one that merely will compile in more than one language.

@JonathanVanMatre: I think in this case he meant that he uses constant from C header in C++. std::cout was never a valid C syntax.

Ah, good call there.

Very simple, uses bash to access the C math library:
bc -l <<< "3 * 3 * `grep -w M_PI /usr/include/math.h | awk '{ print $4 }'`"

Since Fortran does not actually have an intrinsic value for pi (which is was OP seems to indicate with the statement "Fortran's MATH::PI"), I had to write one for C. I opted, rather than actually defining it, that I'd just determine it using some fast algorithm:
#include <math.h>
double pi_eval(){
    double a = 1.0;
    double b = 1.0/sqrt(2.0);
    double t = 0.25;
    double x = 1.0;
    double y;
    int i;

    for(i=0; i<4; i++){
        y = a;
        a = 0.5*(a+b);
        b = sqrt(b*y);
        t -= x*(y-a)*(y-a);
        x *= 2.0;
    }
    return (a+b)*(a+b)/(4.0*t);
}

(saved as pi_calc.c) Which is then used in area_calc.f90:
program area_calc
   use, intrinsic :: iso_c_binding
   implicit none

   interface
     function pi_eval() bind(c)
       use, intrinsic :: iso_c_binding
       real(c_double) :: pi_eval
     end function pi_eval
   end interface
   real(c_double) :: pi, area

   pi = pi_eval()
   print *,"area=",3.0*3.0*pi

end program area_calc

This outputs the required
 area=   28.2743338823081

One compiles this using
gcc -c pi_calc.c
gfortran -o area pi_calc.o area_calc.f90

R & C++
Requires the inline and Rcpp packages in R.
get.pi <- inline::cxxfunction(plugin="Rcpp", includes="#include <cmath>", body="return wrap(M_PI);")

get.pi() * 3 ^ 2

cxxfunction creates, compiles and links a C++ function behind the scenes. Yes, there is quite a lot of code generation happening, and return wrap(M_PI); is C++ code (along with the #include part).

Java + JavaScript
class Pi {
    public static void main(String... args) throws Throwable {
        System.out.println((double) new javax.script.ScriptEngineManager()
                .getEngineByName("JavaScript").eval("Math.PI")
                * Math.pow(3, 2));
    }
}

28.274333882308138

You beat me to it. :(

Julia using Python
julia> using PyCall
julia> @pyimport math
julia> math.pi*3^2
28.274333882308138

That was fun, I'd never used PyCall before.  The interface is super easy to use.

R + grep + awk + dc
echo pi | R --no-save --quiet | grep -v '^>' | awk '{print $2}' | dc -e '?3 3 **p'

Output:
28.274337

Using Lua's π in Java
This program uses the library LuaJ to evaluate Lua in Java and get π. It also squares the area with Lua.
Enjoy!
    ScriptEngineManager sem = new ScriptEngineManager();
    ScriptEngine se = sem.getEngineByName("luaj");
    se.eval("pi = math.pi");
    double pi = (double) se.get("pi");

    int r = 3;

    se.eval("radius = "+r);
    se.eval("rsquared = math.pow(radius, 2)");
    int rsquared = (int) se.get("rsquared");

    double area = pi * rsquared;
    System.out.println("For a circle with a diameter of "+r+", the area is "+area+".");

The output:
For a circle with a diameter of 3, the area is 28.274333882308138.

Ok I'll bite...
AWK + PHP
$ awk -v PI=`php -r 'echo pi();'` 'BEGIN{print 3*3*PI}'

PHP + AWK
$ php -r "echo 3*3*`awk 'BEGIN{printf 4*atan2(1,1)}'`;"

BASH + PHP
$ PI=$(php -r 'echo pi();');C=$((${PI/\./}*3*3));echo ${C:0:2}.${C:2}

nJoy!

Ruby + Python + C++ + Batch (if you want to include it)
Oh, this took much longer than I wanted it to. As far as I know this will only work on Windows, though if you edit the rm command it may work on Linux.
Here's what it does:

Ruby creates pi.cpp
Ruby runs batch code to compile pi.cpp using MinGW or GCC
Ruby runs pi.exe
Pi.exe runs Python code to find pi
Python saves pi to pi.txt
Ruby reads pi.txt, does the math to find the area, and prints it

Comment out the last line to see the remnants of the process.
p = "\\\"import math; import subprocess; f = open('pi.txt', 'w'); print(math.pi, file=f)\\\""

c = '''#include <iostream>
#include <cstdlib>

int main()
{
    system("python -c '''+p+'''");
    return(0);
}'''

command2 = "g++ pi.cpp -o pi.exe"
command3 = "pi.exe"
command4 = "rm pi.cpp && rm pi.exe && rm pi.txt"

File.open("pi.cpp", "w+") do |file|
    file.puts c
end

system(command2)
system(command3)

my_very_own_pi = ''

File.open("pi.txt", "r") do |file|
    my_very_own_pi = file.gets
end

puts "The answer is: #{(3**2)*(my_very_own_pi.to_f())}"

system(command4)

Jython + Java
This should work in Jython. I'm not sure, as I have no way to test it ATM.
from java.lang import Math
print Math.PI * 3 ** 2

Jython can access the Java libraries, so I can just import the Math class from java.lang and use its PI constant to calculate the area of the circle.
Golfed:
import java.lang.Math.PI;print PI*3*3

Or, if I'm allowed to code in 3^2:
import java.lang.Math.PI;print PI*9

bash (PI from perl,python,c)
Maybe if we combine everything we've got, we get a more accurate result? :)
#!/bin/bash
exec >&>(bc -l|tail -n1)
perl <<EOF
use Math::Trig;
print pi
EOF
echo -n +
python <<EOF
import sys
from math import pi
sys.stdout.write(str(pi))
EOF
echo -n +
cat > pi.c <<EOF
#include <math.h>
main(){printf("%.16f",M_PI);}
EOF
gcc pi.c -o pi &>/dev/null
./pi
rm -f pi pi.c
echo ";"
echo "(last/3)*3.^2"

Ruby+Python
puts `python -c "from math import pi; print pi"`.to_f * 3**2

HTML + PHP
<html><body>
value of area of circle is <br>
<?php echo 3*3*M_PI; ?>
</body></html>

Confused whether it satisfy the 3rd rule. but since M_PI is already used so it should count.

ACTIONSCRIPT3 + javascript(using parse.com)
Parse.CFunction('getPi',{},function(returned){trace(3*3*returned.result)});

parse class link https://github.com/camdagr8/AS3-Parse-Class/blob/master/com/illumifi/Parse.as
with code:
public static function CFunction(className:String, params:Object = null, success:Function = null, error:Function = null) {
            var url:String = Parse.api + "functions/" + className;
            Parse.Call(url, URLRequestMethod.POST, params, null, success, error);
        }

parse main.js:
Parse.Cloud.define("getPi", function(request, response) {
  response.success(Math.PI);
});

result:
28.274333882308138

Mathematica + R
Needs["RLink`"]
InstallR[]
 = REvaluate["pi"][[1]];
R = 3;
 R^2

bash + html + APL
 echo '<html><body><p>○3*2</p></body></html>' | w3m -dump -T text/html | apl -f -

Obligatory GolfScript+Ruby answer :)
"#{Math::PI*9}"

Java & JavaScript
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class Main {
    public static void main(String[] args) {
        ScriptEngineManager mgr = new ScriptEngineManager();
        ScriptEngine engine = mgr.getEngineByName("JavaScript");
        try {
            System.out.println((double)engine.eval("Math.PI") * 3 * 3);
        } catch (ScriptException e) {
            e.printStackTrace();
        }
    }
}

C# and VB.NET
This one creates a VB.NET assembly on the fly (using Microsoft CodeDom) to get the value of Pi. No need to invoke shells, external interpreters, or any of those other tricks. You get two languages, not just in a single process, but in a single thread!
using System;
using System.CodeDom.Compiler;
using System.Reflection;
using System.Text;
using Microsoft.VisualBasic;

namespace PiDay2014CSharpConsole
{
    public class AreaCalculator
    {
        private double Pi()
        {
            StringBuilder vb = new StringBuilder();
            vb.AppendLine("Public Class PiDay");
            vb.AppendLine("    Public Function VbPi() As Double");
            vb.AppendLine("        Return System.Math.PI");
            vb.AppendLine("    End Function");
            vb.AppendLine("End Class");
            CompilerParameters cp = new CompilerParameters();
            cp.GenerateExecutable = false;
            cp.GenerateInMemory = true;
            cp.ReferencedAssemblies.Add("System.dll");
            CodeDomProvider provider = new VBCodeProvider();
            CompilerResults cr = provider.CompileAssemblyFromSource(cp, vb.ToString());
            var piDay = cr.CompiledAssembly.CreateInstance("PiDay");
            Type t = piDay.GetType();
            object result = t.InvokeMember("VbPi",
               BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,
               null, piDay, null);
            return (double)result;
        }

        public double CalculateArea(double radius)
        {
            return Pi() * radius * radius;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            AreaCalculator calc = new AreaCalculator();
            Console.Out.WriteLine("{0}", calc.CalculateArea(3.0));
            Console.In.ReadLine();
        }
    }
}

Output:
28.2743338823081

Ruby+Python
require 'bigdecimal'
require 'bigdecimal/util'
File.open("pi.py", 'w') {|f| f.write("import math\nfrom decimal import *\ngetcontext().prec = 100\nprint Decimal(math.pi)") }
puts %x(python pi.py).to_d*3*3
%x(rm pi.py)

result:
0.28274333882308138043981671216897666454315185546875E2

Python and Java?  Please specify the language in your title as #Language#

ASP.net / JS
alert(3*3*<%Response.Write(Math.PI)%>)

Matlab & Python
[~, pi] = system('python -c "import math; print(math.pi)"');
area = str2num(pi) * 3^2;
disp(area)

Output:
28.274333882308138

Groovy + Java  (Someone had to do it... :) )
println java.lang.Math.PI * 3 * 3

HTML + JAVASCRIPT
<label>Price 1</label><input type="text" class="price" /><br/>
<label>Price 1</label><input type="text" class="price" /><br/>
<label>Total</label><input type="text" id="total" /><br/>
<script>
var $prices=$('.price').keyup(calcTotal);
function calcTotal(){
  var tot=Math.PI;
  $prices.each(function(){
      tot*=$(this).val() | 0;
    });
   $('#total').val( tot);
}
</script>

Umm, jQuery isn't a "language." You're using JavaScript's Math.PI from... JavaScript?

x86 Assembly Language
NASM syntax
global _start

section .data
val: dq 3.0

section .text

_start:

fldpi
fld qword [val]
fmul st0,st0
fmul st1,st0