text:
Write program in your favorite language in another language

The determined Real Programmer can write Fortran programs in any language.

from Real Programmers Don't Use Pascal
Your task is to write program in your programming language of choice, but you are allowed to use only another language. That is, throw away all coding conventions from one language and replace them with coding conventions from other language. The more the better. Make your program look as if it was written in another language.
For example, Python fan who hates Java could write following Python program in Java:
void my_function()                                                             {
    int i = 9                                                                  ;
    while(i>0)                                                                 {
        System.out.println("Hello!")                                           ;
        i = i - 1                                                              ;}}

Pascal enthusiast forced to use C could write this:
#define begin {
#define end }
#define then
#define writeln(str) puts(str)

if (i == 10) then
begin
    writeln("I hate C");
end

You have to write complete program. The program desn't have to do anything useful.
Good Luck. This is a popularity contest so the code with the most votes wins!

@m.buettner create your file with the extension .litcoffee. It might help.

A little long (and previously-written; and not self-contained) for an answer, but: Postscript scanner in Postscript in C.

I'd like to clarify that program needs to be correct only in language it't written in (in case of my examples, Java and C), not in language it pretends to be written in. However if it's correct in both, the better!

@el.pescado Indeed, your Pascal program would compile with the unnecessary brackets in the if statement, but not with the the double == (and obviously not without declaring the variable i.) You might want to edit your question instead of posting as comment. Up to you. Nice question, by the way.

I don't think you (or the majority of the answers) understand the point of the quote. It's not that a Real Programmer writes code that looks lexically like Fortran even though he's writing in Pascal or LISP: it's that he applies a Fortran way of thinking even when writing in Pascal or LISP; e.g. "As all Real Programmers know, the only useful data structure is the Array.". Great answers would be procedural code in Prolog, functional code in C, object-oriented code in Pascal.

I hope someone's gonna do a Lisp dialect in, well, anything but another Lisp dialect...

I thought real programmers only coded in assembly and machine language (binary) ...

I had an assistant prof at Univ (around '87) who was totally into Pascal, and created exactly these #defines in C.

@itsjeyd Greenspun's Tenth Rule Of Programming: "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of CommonLisp."

@JoshuaTaylor Funny you should mention that - I literally just discovered that quote via http://paulgraham.com/avg.html ... :)

@itsjeyd Of course, what's interesting about this problem, is that writing making code in another language work in (Common) Lisp actually isn't too difficult, because it's easy enough to customize the reader, the syntax for symbols is already quite inclusie, and it's easy to wrap things in macros. For instance, in this answer that I wrote, some C/Java style psuedo-code integrates seamlessly in Lisp.

@PeterTaylor yeah, I tried to do this now...

Somebody do Nimrod/PHP...

@PeterTaylor, I think mine matches the quote, if not the intent of the question...

How about Objective-C and... oh, wait..

@PeterTaylor You are 100% right - the quote is not about the look of the program, it's about the thinking that goes into it. It goes both ways, too - my FORTRAN teacher scolded me once for using nested loops to print 2D arrays. She said, literally, that I shouldn't expect to pass her class if I continue writing Pascal programs in FORTRAN :-)

there are languages which easily allow to express any way of thinking. (LISP family, for example)

C in C++
#include <stdio.h>

int main(int argc, char** argv)
{
        printf("Hello world!\n");
        return 0;
}

I see what you did there;)

Well, that's a cheap trick, seeing as C++ is 'backwards compatible' with C.

Might as well wedge in Objective C in there if you can too! (I've never programmed in it, but I think it is backward compatible?)

@AlexM. I think it would be more in the spirit of the question if this was a longer (procedural) example which would clearly benefit from using some classes and which uses other C idioms where some STL goodness would be much more reasonable (say char* instead of std::string).

@m.buettner That would invalidate the cheap trick. It was the point of the answer after all. You are welcome to post a longer (procedural) example which would clearly benefit from using some classes and which uses other C idioms where some STL goodness would be much more reasonable (say char* instead of std::string) though, I agree it would be good and I'd upvote it for sure :)

@AlexM. fair enough, but I think I've spent enough time on this question ^^

This answer wants me to try and post the reverse: set up horrible macros to emulate RAII, define structs with a bunch of function pointers in them to emulate virtual functions, and such

Valid in C, C++, Objective-C, and Objective-C++! What a wonderfully polyglot answer.

@Hurkyl What's stopping you?

@m.buettner: What makes it C++ is the char** argv.  No C programmer would mis-associate the **.  That's a C++ style due to Stroustrup AFAIK.

C++ is not backward-compatible with C

@BenJackson Psh, real C programmers use char *argv[]!

@BenJackson: I don't think you can reasonably claim that this is "due to Stroustrup"; more like, it's down to common sense (regardless of the internal parse tree, which is highly irrelevant). And, please, for the love of god, don't give me that overrated multiple-declarations argument again. I've heard it enough and it's still entirely unconvincing. :-)

@LightnessRacesinOrbit: So you're also a fan of the "goes to zero" operator while ( x --> 0 )?

@BenJackson: Not at all. Why do you say that? It's a bit of a strawman to suggest I want to deliberately go against all the parse groups...

Same thing can be done for Groovy and Java.

@el.pescado I C what you did there.

x86 assembly in GNU C
No, I didn't just use the asm keyword, since the question established this is for real programmers... this should run fine on ARM.
(Just to prove the point, I didn't "write" the assembly at all - it's the output produced by GCC Clang (503.0.38) for the commented code at the top, blindly translated into macros.)
This only works in 32-bit mode. That's fine since real programmers code to the word size anyway.
#include <stdio.h>
#include <stdint.h>
/*
int fac(int x) {
    if (x < 1) return 1; else return x * fac(x - 1);
}

int fib(int x) {
    if (x < 2) return x; else return fib(x - 1) + fib(x - 2);
}

int main(void) {
    int a = fib(10), b = fac(10);
    printf("%d %d\n", a, b);
    return 0;
}
*/

typedef union REG {
    intptr_t i; int _i; void * v; union REG * r;
} REG;

#define LPAREN (
#define RPAREN )
#define MACRO(N) ); N##_MACRO LPAREN

#define push MACRO(PUSH)
#define pop  MACRO(POP)
#define mov  MACRO(MOV)
#define sub  MACRO(SUB)
#define add  MACRO(ADD)
#define imul MACRO(IMUL)
#define cmp  MACRO(CMP)
#define jge  MACRO(JGE)
#define jmp  MACRO(JMP)
#define call MACRO(CALL)
#define ret  MACRO(RET) _
#define label MACRO(LABEL)

#define NO_OP(X)

#define PUSH_MACRO(VAL) *(esp -= 4) = (REG)(VAL)
#define POP_MACRO(DST) (DST) = (typeof(DST))(esp->i); esp += 4
#define MOV_MACRO(VAL, DST) (DST) = (typeof(DST))((REG)VAL).i;
#define SUB_MACRO(VAL, DST) CMP_MACRO(VAL, DST); \
    (DST) = (typeof(DST))(((REG)DST).i - ((REG)VAL).i)
#define ADD_MACRO(VAL, DST) DST = (typeof(DST))(((REG)DST).i + ((REG)VAL).i); \
    ZF = ((REG)DST).i == 0; OF = 0; SF = ((REG)DST).i < 0
#define IMUL_MACRO(VAL, DST) DST = (typeof(DST))(((REG)DST).i * ((REG)VAL).i); \
    ZF = ((REG)DST).i == 0; OF = 0; SF = ((REG)DST).i < 0
#define CMP_MACRO(L, R) CMP_MACRO_(((REG)L).i, ((REG)R).i)
#define CMP_MACRO_(L, R) (OF = 0, ZF = L == R, SF = (R - L) < 0)
#define JGE_MACRO(TGT) if (SF == OF) { goto TGT; } else {}
#define JMP_MACRO(TGT) goto TGT;
#define CALL_MACRO(PROC) CALL_MACRO_(PROC, __COUNTER__)
#define CALL_MACRO_(PROC, CTR) PUSH_MACRO(CTR - STARTIP); \
    goto PROC; case CTR - STARTIP:
#define RET_MACRO(_) eip = esp->i; esp += 4; if (eip) { continue; } else { goto *finalreturn; }
#define LABEL_MACRO(NAME) NAME

#define MY_ASM(X) do { const int STARTIP = __COUNTER__; \
    switch(eip) { case 0: MY_ASM_1 X } } while (1);
#define MY_ASM_1(X) MY_ASM_2(NO_OP LPAREN 0 X RPAREN;)
#define MY_ASM_2(X) X

#define CAT(L, R) _CAT(L, R)
#define _CAT(L, R) L##R

#define callASM(F) callASM_(F, CAT(_TMP_, __COUNTER__))
#define callASM_(F, LABEL) (({ PUSH_MACRO(0); stackbase = esp; finalreturn = &&LABEL; \
    goto F; LABEL:; }), (intptr_t)eax)

const int STACKSIZE = 4096;
REG callstack[STACKSIZE], * stackbase;
REG * eax, * ecx, * edx, * ebx, * esi, * edi, * esp, * ebp;
int SF, ZF, OF, eip; void * finalreturn;

int main(void) {
    eax = ecx = edx = ebx = esi = edi = esp = ebp = &callstack[STACKSIZE - 1];
    eip = 0;
    finalreturn = &&TOP; TOP:

    PUSH_MACRO(10);
    int a = callASM(_fac);
    PUSH_MACRO(10);
    int b = callASM(_fib);

    printf("%d %d\n", a, b);
    return 0;

    MY_ASM((
    label _fac:                                   // @fac
        push ebp
        mov esp, ebp
        sub 24, esp
        mov 8[ebp], eax
        mov eax, (-8)[ebp]
        cmp 1, (-8)[ebp]
        jge LBB0_2
        mov 1, (-4)[ebp]
        jmp LBB0_3
    label LBB0_2:
        mov (-8)[ebp], eax
        mov (-8)[ebp], ecx
        sub 1, ecx
        mov ecx, *esp
        mov eax, (-12)[ebp]         // 4-byte Spill
        call _fac
        mov (-12)[ebp], ecx         // 4-byte Reload
        imul eax, ecx
        mov ecx, (-4)[ebp]
    label LBB0_3:
        mov (-4)[ebp], eax
        add 24, esp
        pop ebp
        ret

    label _fib:                                   // @fib
        push ebp
        mov esp, ebp
        sub 24, esp
        mov 8[ebp], eax
        mov eax, (-8)[ebp]
        cmp 2, (-8)[ebp]
        jge LBB1_2
        mov (-8)[ebp], eax
        mov eax, (-4)[ebp]
        jmp LBB1_3
    label LBB1_2:
        mov (-8)[ebp], eax
        sub 1, eax
        mov eax, *esp
        call _fib
        mov (-8)[ebp], ecx
        sub 2, ecx
        mov ecx, *esp
        mov eax, (-12)[ebp]         // 4-byte Spill
        call _fib
        mov (-12)[ebp], ecx         // 4-byte Reload
        add eax, ecx
        mov ecx, (-4)[ebp]
    label LBB1_3:
        mov (-4)[ebp], eax
        add 24, esp
        pop ebp
        ret
    ))
}

Just look at all those casts. Casts mean I'm a realer programmer than the compiler, right?

+1, that's... twisted. ;)  I really like how you handled call, in particular.

Wow. That's a great piece of work.

I had an assembler for the C64 that worked sort of like this.  It added BASIC keywords for all the 6510 instructions and I remember you wrapped for pass=1:3...next around it.  Executing it in the BASIC interpreter assembled it.

This is pure poetry.

This is tough man, the compiler sure is amazed.

Very tough and clever abuse of C's pseudo-macros. I certainly couldn't do something that complex... ;) And this should be the winner, by the way

English in C
#include <stdio.h>
#define This
#define program     int main() {
#define aims
#define to
#define output      printf(
#define some
#define example
#define text(a)     #a
#define the
#define screen      "\n");
#define it
#define also
#define will
#define calculate   ;int a =
#define result
#define of
#define and
#define print       ; printf("%d\n", a);
#define seriously   return 0; }

This program aims to output some example text (Hello) to the screen;
it also will calculate the result of 3 + 4 and print the result; seriously

Any ideas to eliminate the ;?

Seriously, you guys.

why define the twice?

better safe than sorry ;-)

Now make it a haiku.

You can remove semicolons in screen; and result;by prepending;to macrositandseriously` respectively. link

@Zereges: I meant 'Any ideas to replace the semicolons with full stops?'.

Can you #define . ;

Since the dot is used for structure access, that could be used. For example, change the definition of This to #define This struct s { int i; } dummy;, the definition of screen to "\n"); dummy, the definition of it to i;, the definition of result to dummy, the definition of of to i,, and the definition of seriously to i; return 0; }, and replace the semicolons by full stops. If I didn't miss something, that should work.

I think the brilliant Lennart Augustsson has already won this twice.
First, here's an example of his "weekend hack" implementation of BASIC as a Haskell Monadic DSL, from 2009:
import BASIC

main = runBASIC' $ do

    10 LET I =: 1
    20 LET S =: 0
    30 LET S =: S + 1/I
    40 LET I =: I + 1
    50 IF I <> 100000000 THEN 30
    60 PRINT "Almost infinity is"
    70 PRINT S
    80 END

It works by overloading the number type. The line numbers are really functions that accept arguments. The rest of the line is arguments to the function. The function returns a representation of the Abstract Syntax Tree for the BASIC interpreter to go to work on.
I also recommend you check out Augustsson's entry to the 2006 International Obfuscated C Contest, in which he managed to squeeze into 4k:

A bytecode interpreter, written in a subset of C (which he calls Obfuscated C).
An Obfuscated C -> bytecode compiler, written in bytecode.

They can share the same file because the bytecode is placed inside C comments.
It's a few years since I followed Augustsson's work, so there may well be other brilliant things he's come up with since then....

It's Augustsson, not Augustssen.

@HansLundmark Thanks. Fixed it.

Brainfuck in JavaScript
Javascript is a difficult language ! Let us use Brainfuck, a more understandable language :o)
eval(

//write your easy code below

"++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."

//end of easy code

.replace(/\]/g,'}')
.replace(/\[/g,'while(a[i]){')
.replace(/\+/g,'a[i]++;')
.replace(/-/g,'a[i]--;')
.replace(/>/g,'i++;')
.replace(/</g,'i--;')
.replace(/\./g,'o+=String.fromCharCode(a[i]);')
.replace(/,/g,'a[i]=u.charCodeAt(j++);')
.replace(/^/,'var a=new Array(1000).join(\'0\').split(\'\'),i=500,o=\'\',u=prompt(\'Enter input if needed\'),j=0;')
.replace(/$/,'alert(o)')
)

I guess I wrote a brainfuck interpreter in javascript.
The example above simply ouputs Hello World! and ignore the input (no , symbol).
But that works with inputs too ! For example, try ,+>,+>,+>,+<<<.>.>.>. and type golf in the dialog. It will ouputs the next characters in ASCII table : hpmg
EDIT : Short explanation for people who don't know brainfuck.
Imagine an infinite array of integers a initialized to zero everywhere, a pointer on one element of this array i, and a user input u.
Brainfuck is really easy to learn but difficult to write :

+ increments to current value : a[i]++
- decrements it : a[i]--
> makes to pointer points the next element : i++
< the previous : i--
[ and ] define a loop which breaks when current value is zero : while (a[i]) { ... }
. print the current element : String.fromCharCode(a[i])
, sets the current element with user input : u.charCodeAt(...)

+1 for the humour in stating that brainfuck is more understandable than JavaScript.

Are you sure that the Brainfuck characters inside of the replace statements don't affect the program?

@fra This file isn't a brainfuck program, it's a javascript program that contains a brainfuck program that's converted to javascript at runtime.

For some reason I thought these were supposed to be polyglots. My bad.

I wanted to make it a polyglot too but the , for the separation of the arguments in replace function is a serious issue.

Actually, this is a bad implementation of a Brainfuck interpreter. You should do a[i]-=(a[1]-1)&255; instead of a[i]--. Even a[i]-- should be --a[i] for performance reasons.

Well, --i faster than i-- ? Seems false since years : http://jsperf.com/decrementgolf.

How can 4 instructions be faster than 3? And it's possible that some browsers are optimized to increase the speed of a--, but --a is faster. Try this: console.time('--a');for(var a=1e3;--a;);console.timeEnd('--a');console.time('a--');for(var a=1e3;a--;);console.timeEnd('a--');. On Opera 12.16 on Windows 8 x64 with 3.14gb of free ram out of 4gb, in a Core2Quar 2.44GHz overclocked to 2.628.75MHz, the --a is faster more than half the times.

This not only is very creative submission to the contest, but also explains brainfuck syntax very clearly. +10 if I could!

@Michael Your own link shows --i being faster than i-- for several browsers (including the one I’m currently using).

The difference between a-- and --a only matters if something is done with the result of the expression. In this brainfuck interpreter it is not, if I see right.

PHP and Javascript
This is a polyglot:
You can run this code in both languages:
if("\0"=='\0')
{
    function printf(){
        $b=Array();
        $a=$b['slice']['call'](arguments);
        $a=$a['join']('');
        console.log($a);
        return $a.length;
    };

    function strtoupper($s){return $s['toUpperCase']();}

    function count($a){return $a['length'];}
}

printf('this is cool!');

$c=Array('a','b','c','d');

for($i=0,$l=count($c);$i<$l;++$i)printf("\n",strtoupper($c[$i]));

The trick here is that Javascript uses escape sequences in strings starting with ' and ".
On the other hand, PHP only uses escape sequences in strings starting with " and <<<.
Then, we declare the function printf, which is similar to print but outputs a formated string in PHP.
PHP requires that vars start with $, while Javascript simply allows.

Nobody's using Array(…) in JS, and it's clearly array(…) in PHP. […] would be far better ;) !

I don't care if people use Array() in JS or not: I care that I have a TRUE polyglot. I'm making one of the worst JS crimes with this code but all I want is that it runs and does the exact same thing in both, but looking like JS and PHP at the same time.

And btw, [...] is invalid in PHP <5.4.0, which is bad....... If I throw this into PHP 4, 5 or Javascript, I expect it to work, instead of giving syntax errors everywhere.

If you want your code to look like JS, you must use […], which seems pretty standard in PHP, and therefore is OK for your goal. And by the way, PHP < 5.4? Time to update, guy…

Compatibility is more important than "looks". And Array is the RIGHT name of the Array object's constructor. Basicly, using [] is the same as Array(). I don't see anything bad with it. But I have one simple question: Works? (btw, I have to use php 5.3.28 at work.)

@IsmaelMiguel aww, my workplace makes me use PHP 5.2.17...

@Tortoise I have no other choice... We have a managed VPS (which means that we pay to the providers to manage it) and we can't decide that freely which version we want. I would prefer 5.5, but as long as it isn't PHP4, I'm happy with it!

Brainfuck in JS
[][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[
!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[
+!+[]]]]][([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(
![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!
![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+
[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]
]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[
]+!+[]+!+[]+!+[]]]]+([][[]]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+[]+!+[]]]]+(!!
[]+[])[+[[+[]]]]+(!![]+[])[+[[+!+[]]]]+([][[]]+[])[+[[+[]]]]+([][(![]+[])[+[[
+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!
![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+
[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[
[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!!
[]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+[])[+[[!+[]+!+[]+!+[]+!+[]
+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]((![]+[])[+[[+!+[]]]]+(![]+[])[+[[!+[]+!+
[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]+(!![]+[])[+[[+[]]]
]+([][(![]+[])[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[
+[[!+[]+!+[]]]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[
+[[+!+[]]]]]+[])[+[[+!+[]]]+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+[+!+[]]+([][(![]+[]
)[+[[+[]]]]+([][[]]+[])[+[[!+[]+!+[]+!+[]+!+[]+!+[]]]]+(![]+[])[+[[!+[]+!+[]]
]]+(!![]+[])[+[[+[]]]]+(!![]+[])[+[[!+[]+!+[]+!+[]]]]+(!![]+[])[+[[+!+[]]]]]+
[])[+[[+!+[]]]+[[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]]])()

I don't see any brainfuck here. Not even a single char in ><,.-

@Michael: Who said it isn't a program that makes an infinite loop?

is this JSF*ck?

Removing the ending (), this results in function (){ alert(1) }, and then the ending () executes the function and gives you a nice informative alert.

How on Earth does it do that?

Weird. Looks like (![]+[])[+[]] gives the first 'f' of false, then it gets u of undefined.

Oo. Somebody finally did this. I spent some time trying to figure out how to write a JS program using only the characters + but never could quite figure it out. I need to analyze this when I have time...

! is necessary, sadly.

This is one of the 2005 IOCCC winners, a C program that, except by that bunch of defines, looks like a java program:
/*
 * Sun's Java is often touted as being "portable", even though my code won't
 * suddenly become uber-portable if it's in Java. Truth is, Java's one of
 * the most ugly, slow, and straitjacketed languages ever. It's popular
 * mainly because people hear the word "portable" and go "ewww".
 *
 * This program, then, is dedicated to bringing about the death of Java. We
 * good coders have been oppressed for too long by the lame language
 * decisions of pointy-haired bosses and academics who should know better.
 * It's time we stand up against this junk, and bring back the fun in
 * programming! Viva La Revolution!
 */

#define aSet c
#define BufferedReader(x)1
#define byte Y[I][_^1]?do(:):_&1?do(.):do(`):8;++y;}
#define class int N=0,_,O=328,l=192,y=4,Y[80][64]={0},I;struct
#define do(c)a(#c "\b")
#define err c,c
#define getAllStrings(x));q()
#define if(x)b(#x)
#define IOException
#define line c
#define main(a)b(char*x){write(1,"\033[",2),null}main()
#define new
#define null a(x);}a(char*x){write(1,x,strlen(x));try;try;try;try;
#define out c,c
#define println(x)c
#define private int d(int
#define public short c;}c;typedef int BufferedReader;char*F="JF>:>FB;;BII";
#define return {return
#define static f(x){N=(N+x)%6,y--?f(0),f(1),f(4),f(1):++Y[(I=O+N[F]-66)
#define String
#define System c
#define this if(D):1,O=I,I/=16,l<_/32?if(B):l>_/32?if(A):2,l=_,_/=16,byte
#define throws
#define toArray(x)c
#define try for(;--c.c;)
#define void /16][(_=l+N[6+F]-66)/16]?O/=16,l/=32,O<I/16?if(C):O>I/16?this
#define while(k)if(2J),if(7;21H),f(0),f(4),f(4),if(H),/*

import java.io.*;
import java.util.*;

/**
 * A lame Java program.
 * @author  J. Random Worker
 */
class LameJavaApp
{

    /** The infamous Long-Winded Signature From Hell. */
    public static void main(String[] args)
        throws IOException
    {
        /* Don't get me started on this. */
        BufferedReader reader =
            new BufferedReader(new FileReader(args[0]));

        /* What, this long incantation just to print a string? */
        System.err.println("Hello world!");

        /* At least this is sane. */
        String line;
        while ((line = reader.readLine()) != null)
            System.out.println(line.length());
    }

    /**
     * Method with a needlessly long name.
     * @param   aSet        a set (!)
     */
    private String[] getAllStrings(Set<String> aSet)
    {
        /*
         * This dance is needed even in J2SE 5, which has type
         * templates. It was worse before that.
         */
        return aSet.toArray(new String[0]);
    }

}

Verbosity at its finest.

C++ in C
OK, so you are a C++ programmer, but are forced to use C? No problem, you just have to write some supplementary headers missing in C. For example, here's a valid Hello World program in C:
In the supplementary header file iostream, write:
#include <stdio.h>

#define using volatile int
#define namespace message
#define std = 0
#define message(x) printf("%s\n",x)
#define cout 0
#define endl 0

In file string, write
#define string

In file helloworld.c (your actual C code), write
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string message("Hello world");
  cout << message << endl;
  return 0;
}

And when compiling helloworld.c with a C compiler, instruct the compiler to also look for <...> header files wherever you stored the files iostream and string, for example, if you are compiling with gcc and put the files iostream and string in the current directory, compile with
gcc helloworld.c -o helloworld -I.

Note: The volatile in header iostream is there to enable a warning-free compile even at maximum warning level (a read from a volatile variable is considered to have an effect).

This is a bit of code trolling, isn't it.

Well, the program does exactly what it appears to do, doesn't it?

So much funnier and more impressive this way around than C in C++.

What kind of compiler warns if you don't use volatile here, and what kind of warning?

@KyleStrand But the "C in C++" one is more in tune with the quote in the question. Real programmers program in C, even if they have a C++ compiler.

@MrLister Fair enough.

@R.MartinhoFernandes: Any compiler that warns about statements without effect. Which is exactly the warning you get with gcc at maximal warning level. This is because after macro expansion, the "output" statement reads 0 << message << 0; which means shift left the number 0 by the number of bits given in message, shift the resulting value by 0 bits, and then ignore the result. Which does nothing, except reading the variabe message, which, however, has no effect unless the variable message is volatile.

CQL - Caffeinated Query Language
(or "SQL on Caffeine")
This may have been somewhat overly ambitious. Here is an attempt to write SQL(ish) declarative code in CoffeeScript. This requires the ECMAScript 6 Proxy feature. You can test it in node with --harmony-proxies.
Let's set up a template for defining proxies. (Taken from Benvie's comment on this issue)
forward = (->
  _slice  = Array.prototype.slice
  _bind   = Function.prototype.bind
  _apply  = Function.prototype.apply
  _hasOwn = Object.prototype.hasOwnProperty

  Forwarder = (target) ->
    @target = target
    this

  Forwarder.prototype =
    getOwnPropertyNames: -> Object.getOwnPropertyNames(@target)
    keys: -> Object.keys(@target)
    enumerate: ->
      i = 0
      keys = []
      for value of @target
        keys[i++] = value
      keys
    getPropertyDescriptor: (key) ->
      o = @target;
      while o
        desc = Object.getOwnPropertyDescriptor o, key
        if desc
          desc.configurable = true;
          return desc;

        o = Object.getPrototypeOf o
    getOwnPropertyDescriptor: (key) ->
      desc = Object.getOwnPropertyDescriptor @target, key
      if desc
        desc.configurable = true
      desc
    defineProperty: (key, desc) -> Object.defineProperty @target, key, desc
    get: (receiver, key) -> @target[key]
    set: (receiver, key, value) ->
      @target[key] = value;
      true
    has: (key) -> key of @target
    hasOwn: (key) -> _hasOwn.call @target, key
    delete: (key) ->
      delete @target[key]
      true
    apply: (receiver, args) -> _apply.call @target, receiver, args
    construct: (args) -> new (_bind.apply @target, [null].concat args);

  forward = (target, overrides) ->
    handler = new Forwarder target;
    for k of Object overrides
      handler[k] = overrides[k]

    if typeof target is 'function'
      return Proxy.createFunction handler,
                                  -> handler.apply this, _slice.call arguments,
                                  -> handler.construct _slice.call arguments
    else
      return Proxy.create handler, Object.getPrototypeOf Object target

  forward
)();

Now define a proxy object and some suspicious global variables and functions:
sql = forward {
  tables: {}

  finalize: ->
    if typeof @activeRows isnt 'function'
      @result = []
      for row in @activeRows
        @result.push (val for val, i in row when @activeTable.columns[i] in @activeColumns)
    delete @activeRows
    delete @activeColumns
    delete @activeTable

  run: (q) ->
    q.call(this)
    @finalize()
    result = @result
    delete @result
    if typeof result isnt 'function' then console.log result
    return result
}, {
  get: (o,name) ->
    if name of @target
      return @target[name];
    (args...) -> {
      name
      args
    }
}

int = Number
varchar = (l) -> String

TABLE = (x) -> x
INTO = (x) -> x
CREATE = (tableData) ->
  name = tableData.name
  table =
    columns: []
  column = tableData.args[0]
  table[column.name] = []
  table.columns.push(column.name)
  while column = column.args[1]
    table[column.name] = []
    table.columns.push(column.name)

  sql.tables[name] = table

  sql.result = "Created table '#{name}'"

INSERT = (table) -> sql.activeTable = sql.tables[table().name]
VALUES = (rows...) ->
  for row in rows
    for val, i in row
      column = sql.activeTable.columns[i]
      sql.activeTable[column].push val

  sql.result = "Inserted #{rows.length} rows"

FROM = (table) ->
  sql.activeTable = sql.tables[table().name]
SELECT = (columns...) ->
  sql.activeColumns = []
  for col in columns
    if typeof col is 'function'
      col = col()

    sql.activeColumns.push col.name

  sql.activeRows = []
  for val in sql.activeTable[sql.activeTable.columns[0]]
    sql.activeRows.push []

  for col in sql.activeTable.columns
    for val, i in sql.activeTable[col]
      sql.activeRows[i].push val

IN = (list) -> { op: 'in', list }
WHERE = (column) ->
  i = sql.activeTable.columns.indexOf(column.name)
  if column.args[0].op is 'in'
    list = column.args[0].list
    sql.activeRows = (row for row in sql.activeRows when row[i] in list)
  else
    console.log 'Not supported!'

ASC = 'asc'
DESC = 'desc'
BY = (x) -> x
ORDER = (column) ->
  i = sql.activeTable.columns.indexOf(column.name)
  order = if column.args[0] is sql.ASC then 1 else -1
  sql.activeRows.sort (a,b) ->
    if a[i] < b[i]
      return -order
    else if a[i] > b[i]
      return order
    else
      return 0

Well that was quite a lot of setup! But now we can do the following (input/output in a console style):
> sql.run ->
    CREATE TABLE @books(
      @title varchar(255),
      @author varchar(255),
      @year int
    );

Create Table 'books'

> sql.run ->
    INSERT INTO @books
    VALUES ['The C++ Programming Language', 'Bjarne Stroustrup', 1985],
           ['Effective C++', 'Scott Meyers', 1992],
           ['Exceptional C++', 'Herb Sutter', 2000],
           ['Effective STL', 'Scott Meyers', 2001];

Inserted 4 rows

> sql.run ->
    SELECT @title, @year FROM @books
    WHERE @author IN ['Bjarne Stroustrup', 'Scott Meyers']
    ORDER BY @year DESC;

[ [ 'Effective STL', 2001 ],
  [ 'Effective C++', 1992 ],
  [ 'The C++ Programming Language', 1985 ] ]

It's not an actual polyglot, but that's not really the point. I know that @ is used for variables in SQL, but I need all the @s for column and table names because I haven't found a way to proxy the global object (and I wouldn't be surprised if it's really not possible - and for a good reason).
I also changed some parentheses into brackets (in particular after VALUES and IN). Unfortunately, what I couldn't figure out at all is a way to allow normal conditionals like year > 2000, because they would evaluate to a boolean right away.
Still this looks a lot like SQL and is definitely more declarative than imperative/functional/object-oriented so it should qualify nicely for the question. I'm actually thinking if I polished the code a bit and supported a few more features, this could be a useful CoffeeScript module.
Anyway, this was fun! :)
For those not too familiar with CoffeeScript, the SQL queries compile to the following JavaScript:
sql.run(function() {
  return CREATE(
    TABLE(
      this.books(
        this.title(varchar(255),
        this.author(varchar(255),
        this.year(int)))
      )
    )
  );
});

sql.run(function() {
  INSERT(INTO(this.books));
  return VALUES([...], ['Effective C++', 'Scott Meyers', 1992], [...], [...]);
});

sql.run(function() {
  SELECT(this.title, this.year(FROM(this.books)));
  WHERE(this.author(IN(['Bjarne Stroustrup', 'Scott Meyers'])));
  return ORDER(BY(this.year(thisESC)));
});

That is quite a lot of setup, but does look good. I am not a CoffeeScript programmer, but it does look great. The @ in SQL is used for session variables.

I decided to make the keywords global now. Now there are only @s for column and table names.

Now it looks a lot like SQL! You did a nice work with this one!

I don’t care much for coffee, but this is awesome.

This is the coolest thing I've ever seen. Is it on git?

@tac thanks, but no I just hacked it together for this challenge. Funny coincidence: redoing this in a clean way and putting it on GitHub was on my list of potential/long-term coding projects until I removed it just this morning.

Visual Basic 6 (in JavaScript)
'; Main sub-routine \
'; function Main() { ' \
Sub Main() '
    ' Do not throw any errors... \
    On Error Resume Next '; MsgBox = alert

    ' Show a message box... \
    MsgBox(1 / 0) '

    ' Show errors again... \
    On Error GoTo 0 '

    ' Show another message box... '
    MsgBox("Hello")
    ' ' } ' \
End Sub '

Main()

It also works in VBScript.

Clever. You don't even need most of the semicolons.

@js1568 Thank you! I've now removed the semi-colons that aren't needed.

F# in C++
Rather unimaginative and nasty abuse of the preprocessor. I thought it'd be fun to alter C++ to look like a completely dissimilar language instead of using a few aliases to make it look like Java or PHP. I'm not really expecting this to garner a ton of upvotes, it's a just-for-fun entry.
#define let int
#define args ( int __, char* args[] ) { int ___
#define println printf(
#define exit "\n" ); return 0; }
#include <stdio.h>

let main args =
    println "F# is better than C++"
    exit

Try it here.
Sadly writing something to STDOUT is about all it can do, although I'm sure if someone threw enough witchcraft at it they could make it do more.

For the last line to work in F#, it would either have to be exit 0 or just 0.

Python and... nobody will guess (edit: dc)
Here is some valid python code, but actually the program is written in a very different language:
# Initialize systems 1 and 2
# frame 1, divergency speed and divergency latency
f1ds, f1dl, z1 = [2,2,0]
# frame 2, divergency speed and divergency latency
f2ds, f2dl, z2 = [4,4,1]

# Set the most relevant value of ax (detected by low-energy collision)
ax = 42.424242

# Initialize list of successive energy states
s = [17.98167, 21.1621, 34.1217218, 57.917182]

# Most common value for nz parameter
# TODO: check if value from the article of A. Einstein is better
nz = 10

if z2>nz or ax in s:
  ax += 6
  f1ds = 8
  f2ds = 16
  z1 = 4
  z2 = 9

f1dl += z1
f2dl += z2

# main loop, iterate over all energy states
# Warning: hit Ctrl-C if nuclear explosion occurs and adjust either z or nz
for k in s:
  z = nz + k
  f1dl = f1ds + f2dl * z - z1 + 3.14
  f2dl = f2ds + f1dl * z - z2 + 10
  if k > 10 or z-2 in s:
    nz += 0xac  # hexadecimal coefficient found in famous article by E. Fermi

The code runs in both languages with no error.
The combination is very crazy; I would be happy to wait one day or two before telling which is the other language; please leave comments for guessing.
edit: The language was the stack-based language from dc. You may see here well-known keywords like for, if, or, in, but only the letters matter! The , which has no meaning in dc is turned to a register because the first time it appears is after the letter s (the same for :).

Unless the code does the same thing in both languages, I suppose a language like Befunge could do the trick.

OK, I edit the code in order to put the language I actually chose.

C++ allows you to write lisp-like code, with the InteLib library:
(L|DEFUN, ISOMORPHIC, (L|TREE1, TREE2),
   (L|COND,
     (L|(L|ATOM, TREE1), (L|ATOM, TREE2)),
     (L|(L|ATOM, TREE2), NIL),
     (L|T, (L|AND,
       (L|ISOMORPHIC, (L|CAR, TREE1),
                      (L|CAR, TREE2)),
       (L|ISOMORPHIC, (L|CDR, TREE1),
                      (L|CDR, TREE2))
 )))).Evaluate();

cf. http://www.informatimago.com/articles/life-saver.html

Welcome! We ask users to flag their posts as Community Wiki when the answer is not their own work. (And give proper attribution, but you already did that, so thank you!)

Original or not, you got my vote :)

C# in Whitespace
Okay, first try at one of these, so let's see how it goes.
using System; //very important

namespace ConsoleApplication1  //namespace: name whatever you want
{
 //start
 class  Program  //class name:  also anything
    {
    //main function
    static void Main(string[] args) {
        for(int i=0;i<10;i++)   writeOutput(i);
    } //end main
    static void writeOutput(int i) { Console.WriteLine(i); }    //display output

    } //class ends here

}  //close namespace:   also very important

//yay!

And in case the formatting went screwy from having to put four spaces at the front of each line, here it is again with . for space and # for tab:
using.System;.//very.important#

namespace.ConsoleApplication1..//namespace:#name.whatever.you.want##
{.
.//start#
.class#Program..//class.name:#also.anything#.
#{
....//main.function#
#static.void.Main(string[].args).{
....#for(int.i=0;i<10;i++)#writeOutput(i);#
#}.//end.main#
#static.void.writeOutput(int#i).{.Console.WriteLine(i);.}#//display.output#

.
.#}.//class.ends.here.##

}..//close.namespace:#also.very.important#.#
.

//yay!

HTML and CSS
Not programming languages, but … this document is valid HTML and CSS:
<!-- p{color:red} /* -->
<!Doctype html>
<title>This is HTML and CSS</title>
<p>Hi!</p>
<!-- */ -->

<!-- p{color:red} /* -->
<!Doctype html>
<title>This is HTML and CSS</title>
<p>Hi!</p>
<!-- */ -->

This works, because HTML comments are allowed in stylesheets for historical reasons. Oh, and every valid HTML document is a valid PHP program too, so this is also PHP. :)

That's quite funny and all but this is not really a polyglot challenge.

Since CSS could be considered turing complete, this may be a valid answer.

HTML and CSS are not programming languages :)

C in Scala
The bridging layer emulates a more romantic era when strings were still null terminated arrays of bytes.
// Scala is a dynamic language
import scala.language.{ dynamics, postfixOps }

val self = this

val argc = args.length
val argv = args.map(_.getBytes)

type char = Array[Byte]
object char extends Dynamic {
  // This program uses expanded memory
  val buffers = new scala.collection.mutable.LinkedHashMap[String, char]

  // Malloc char buffer
  def applyDynamic(name: String)(length: Int) =
    buffers(name) = new Array(length)

  def **(argv: Array[Array[Byte]]) = argv
}

object & extends Dynamic {
  // dereference char pointer
  def selectDynamic(name: String) = char.buffers(name)
}

def printf(format: String, buffers: char*) =
  println(
    (format /: buffers){ case (msg, buffer) =>
      // Read string until \0 terminator
      val value = new String(buffer.takeWhile(0 !=))
      // Replace next %s token
      msg.replaceFirst("%s", value)
    }
  )

def scanf(format: String, buffers: char*) =
  buffers foreach { buffer =>
    val line = Console.readLine()
    // Write string to char* buffer
    line.getBytes(0, line.length, buffer, 0)
    // Remember to always null terminate your strings!
    buffer(line.length) = 0
  }

val PATH_MAX = 4096

implicit class Argumenter(args: Pair[_, _]) {
  def apply[T](f: => T) = f
}

object int {
  // Passthrough
  def main[T](f: => T) = f
  def argc = self.argc
}

// terminates the string after the first character
// investigate switching to "xor eax, eax" instead of having a hardcoded 0
// might save 3 bytes and valuable CPU time with this trick
val initialize = (_: char)(1) = 0

def exit(value: Int) = sys.exit(value)

// ---HOMEWORK-ASSIGNMENT-START---

int main(int argc, char **argv) {
  if (argc != 0) {
    printf("This program does not take parameters!");
    exit(1);
  }

  // I've copy pasted this code from somewhere
  // Code reuse is essential if we want to be DRY
  char first(PATH_MAX + 1);
  char last(PATH_MAX + 1);

  printf("Enter your first and last name:\n");
  scanf("%s%s", &first, &last);

  // Still learning references, do I need these here?
  // I've performed benchmarks on printf and I think it's faster this way
  printf("Your full name is %s %s", &first, &last);

  initialize(&first);
  printf("Your signature is %s. %s", &first, &last);

  exit(0);
}

"This program does not take parameters!" fooled ya

sed and APL
My boss wants me to write sed scripts, but I like rather writing APL all the day. Nevertheless, he is very happy with my job because such scripts run perfectly with his version of sed:
i ← g ← 42
a ← d ← 10
s/s←2⊤42/s←2⊤43/g
s/s[01]*1/s⊣1/g
g

You can try it on my new website with this permalink. It is a compiled to javascript version of GNU APL. Final release will be later with official release of GNU APL, v. 1.3 but you can perfectly use it for your permalinks if you enjoy GNU APL.

C in Haskell
import Foreign.C.String
import Foreign.C.Types
import Foreign.Marshal.Array
import Foreign.Ptr
import System.Environment
import System.Exit

-- The meat of the program

cmain :: (CInt, Ptr (Ptr CChar)) -> IO CInt
cmain(argc, argv) = do {
    putStr("hello, world\n");
    return 0;
}

-- Of course, the above function doesn't do anything unless we write a wrapper
-- around it.  This could have been done more simply, using higher-level library
-- functions, but where's the fun in that?

main :: IO ()
main = do {
    args <- getArgs;
    argPtrs <- sequence [do {
        argPtr <- mallocArray0(length(arg)) :: IO (Ptr CChar);
        pokeArray0(0)(argPtr)(map(castCharToCChar)(arg));
        return argPtr;
    } | arg <- args ];
    argv <- mallocArray(length(argPtrs)) :: IO (Ptr (Ptr CChar));
    pokeArray(argv)(argPtrs);

    exitCode <- cmain(fromIntegral(length(args)),argv);

    if (exitCode == 0) then do {
        exitWith(ExitSuccess);
    } else do {
        exitWith(ExitFailure(fromIntegral(exitCode)));
    };
}

Of course, since cmain doesn't do anything with argc or argv, the argument-marshaling code has no effect, and since cmain always returns 0, the "else" branch of the "if" statement is dead. But the "if" statement doesn't do anything anyway.
All of the braces and semicolons are unnecessary, as are most of the parentheses and some of the do keywords. The "if" statement could have been written as if exitCode == 0 then exitWith ExitSuccess else exitWith (ExitFailure (fromIntegral exitCode)).

C++ in Forth
: #include ; : <iostream> ; : { ; : } ; : int ; : using ;
: namespace ; : std; ; : main() ; : cout ; : << ;
: "Hello,  ; : world!\n"; S" Hello, world!" type ; : return ; : 0; ;

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, world!\n";
}

Not the most flexible solution, but it works if written exactly as shown.

Haskell in Java
("vanilla" Java 7, not Java 8) (Yes, I know that boxing ruins performance; and even trying to use higher order functions gets crazy verbose :D)
Java has very rigid syntax, so instead of changing syntax I tried to make code semantically more similar to Haskell style.
Edit — added partial function application.
import java.util.Iterator;

interface Function1<A, B> {
    A call(B arg);
}

interface Function2<A, B, C> {
    A call(B arg1, C arg2);
}

class Reduce<A> implements Function2<A, Function2<A, A, A>, Iterable<A>> {

    @Override
    public A call(Function2<A, A, A> arg1, Iterable<A> arg2) {
        final Iterator<A> i = arg2.iterator();
        A r = i.next();
        while (i.hasNext())
            r = arg1.call(r, i.next());
        return r;
    }
}

class Range implements Iterable<Integer> {

    private final int min;
    private final int max;

    public Range(int min, int max) {
        this.min = min;
        this.max = max;
    }

    @Override
    public Iterator<Integer> iterator() {
        return new Iterator<Integer>() {
            int i = min;

            @Override
            public boolean hasNext() {
                return i <= max;
            }

            @Override
            public Integer next() {
                return i++;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
}

public class Main {

    public static <A, B, C> Function1<A, C> applyPartial(final Function2<A, B, C> f, final B arg2) {
        return new Function1<A, C>() {
            @Override
            public A call(C arg) {
                return f.call(arg2, arg);
            }
        };
    }

    public static void main(String[] args) {

        final Function1<Integer, Iterable<Integer>> product = applyPartial(new Reduce<Integer>(), new Function2<Integer, Integer, Integer>() {
            @Override
            public Integer call(Integer arg1, Integer arg2) {
                return arg1 * arg2;
            }
        });

        final Function1<Integer, Integer> fact = new Function1<Integer, Integer>() {

            @Override
            public Integer call(Integer arg) {
                return product.call(new Range(1, arg));
            }
        };

        final Integer x = fact.call(6);

        System.out.println(x.toString());
    }
}

(Yes, all that this madness does is computing 6!)

COBOL in AWK
In the spirit of the quote. Pure, unadulterated AWK, as it may be written by a COBOL programmer.
The task is to count the records on a file. This early development version is counting itself for testing. The correct file will be hard-coded later when released from Unit Testing...
If I could get the syntax highlighting to do phosphorescent-green on black, it would be great...
Even got the column-numbers correct on this one, that's seven blanks at the start of each line (never done that in awk before) and breaking the long print statements at column 72.
   BEGIN {
       PERFORM_000_INITIALISATION()
       PERFORM_100_OPEN_FILES()
       PERFORM_200_PROCESS_FILE()
       PERFORM_300_CLOSE_FILES()
       PERFORM_400_SHOW_THE_COUNTS()
       exit
   }
   function PERFORM_000_INITIALISATION() {
       INPUT_FILE_NAME = "COBOL.AWK"
       RECORD_COUNT = 0
   }
   function PERFORM_100_OPEN_FILES() {
   }
   function PERFORM_200_PROCESS_FILE() {
       PERFORM_210_PRIMING_READ()
       PERFORM_220_PROCESS_INPUT_UNTIL_END()
   }
   function PERFORM_300_CLOSE_FILES() {
   }
   function PERFORM_400_SHOW_THE_COUNTS() {
       print "COBOL.AWK: NUMBER OF RECORDS READ IS " RECORD_COUNT
   }
   function PERFORM_210_PRIMING_READ() {
       PERFORM_900_READ_THE_FILE()
       if ( FILE_STATUS < 0 ) {
           print "COBOL.AWK ERR0001: INVALID FILE, HALTING, FILE N" \
                 "AME IS: " INPUT_FILE_NAME
           exit
           }
       if ( FILE_STATUS == 0 ) {
           print "COBOL.AWK ERR0002: NO RECORDS ON INPUT, HALTING," \
                 "FILE NAME IS: " INPUT_FILE_NAME
           exit
           }
   }
   function PERFORM_220_PROCESS_INPUT_UNTIL_END() {
       while ( FILE_STATUS != 0 ) {
           INPUT_RECORD = $0
           RECORD_COUNT = RECORD_COUNT + 1
           PERFORM_900_READ_THE_FILE()
           }
   }
   function PERFORM_900_READ_THE_FILE() {
       FILE_STATUS = getline < INPUT_FILE_NAME
   }

SML in Java
I still have some ancient code around from when I started learning Java and tried to use it in a functional style. Slightly cleaned up:
/**
 * Genericised ML-style list.
 */
public class FunctionalList<T>
{
    private final T head;
    private final FunctionalList<T> tail;

    public FunctionalList(T x, FunctionalList<T> xs) {
        this.head = x;
        this.tail = xs;
    }

    public static <T> FunctionalList<T> cons(T x, FunctionalList<T> xs) {
        return new FunctionalList<T>(x, xs);
    }

    public static <T> T hd(FunctionalList<T> l) {
        return l.head;
    }

    public static <T> FunctionalList<T> tl(FunctionalList<T> l) {
        return l.tail;
    }

    public static int length(FunctionalList<?> l) {
        return len(l, 0);
    }

    private static int len(FunctionalList<?> l, int n) {
        return l == null ? n : len(tl(l), n + 1);
    }

    public static <T> FunctionalList<T> rev(FunctionalList<T> l) {
        return rev(l, null);
    }

    private static <T> FunctionalList<T> rev(FunctionalList<T> a, FunctionalList<T> b) {
        return a == null ? b : rev(tl(a), cons(hd(a), b));
    }

    public static <T> FunctionalList<T> append(FunctionalList<T> a, FunctionalList<T> b) {
        return a == null ? b : cons(hd(a), append(tl(a), b));
    }
}

Java in Perl
May count as rule breaking, but I don't care. Obviously, it's intended to look like Java program. It prints 20 Fibonacci numbers, in case it isn't obvious.

 Requires Inline::Java module to be installed.

use Inline Java => <<'JAVA';
/**
 * @author  Konrad Borowski <x.fix@o2.pl>
 * @version 0.1.0
 */
class Fibonacci
{
    /**
     * Responsible for storing the number before last generated number.
     */
    private long beforeLastNumber = 0;

    /**
     * Responsible for storing the last generated number.
     */
    private long lastNumber = 1;

    /**
     * Receives the next Fibonacci number.
     *
     * @return long integer that is the next Fibonacci number
      */
    public long next()
    {
        long temponaryLastNumber = lastNumber;
        lastNumber = beforeLastNumber + lastNumber;
        beforeLastNumber = temponaryLastNumber;
        return temponaryLastNumber;
    }

    /**
     * Outputs the Fibonacci number to standard output.
     */
    public void printFibonacci()
    {
        System.out.println(next());
    }

    /**
     * Outputs the Fibonacci number to standard output given number of
     * times.
     *
     * @param times number of times to print fibonacci number
     */
    public void printFibonacciTimes(int times)
    {
        int i;
        for (i = 0; i < times; i++) {
            printFibonacci();
        }
    }

    /**
     * Constructor for Fibonacci object. Does nothing.
     */
    public Fibonacci()
    {
        // Do nothing.
    }
}
JAVA

###
 # The executable class that shows 20 Fibonacci numbers.
 ##
package OutputFibonacci
{
    ###
     # Shows 20 Fibonacci numbers. This method is public,
     # static, and returns void.
     ##
    sub main()
    {
        # In Perl, -> is object method separator, not a dot. This is stupid.
        new Fibonacci()->printFibonacciTimes(20);
    }
}

# Perl doesn't automatically call main method.
OutputFibonacci::main();

Brainfuck (or anything else) in Racket
Racket's flexible module and macro system allows it to implement module support for entirely new languages, both domain-specific and general-purpose. There is out of the box support for both Datalog and Algol 60, so the following are both valid Racket programs:
#lang datalog
edge(a, b). edge(b, c). edge(c, d). edge(d, a).
path(X, Y) :- edge(X, Y).
path(X, Y) :- edge(X, Z), path(Z, Y).
path(X, Y)?

#lang algol60
begin
  integer procedure SIGMA(x, i, n);
    value n;
    integer x, i, n;
  begin
    integer sum;
    sum := 0;
    for i := 1 step 1 until n do
      sum := sum + x;
    SIGMA := sum;
  end;
  integer q;
  printnln(SIGMA(q*2-1, q, 7));
end

You can also add support for other languages: e.g. see Danny Yoo's description of how to implement support for Brainfuck, which permits Racket programs such as:
#lang planet dyoo/bf
++++++[>++++++++++++<-]>.
>++++++++++[>++++++++++<-]>+.
+++++++..+++.>++++[>+++++++++++<-]>.
<+++[>----<-]>.<<<<<+++[>+++++<-]>.
>>.+++.------.--------.>>+.

And since the support is added at the compiled module level, it's possible to link modules written in different languages or embed a snippet of one language inside a module written in another.

J and... nobody will guess (edit: dc)
This is my second entry; here is a piece of valid J code, which returns 1:
10 o. 1 r. 2 i. 4 [ ( 0:`1: @. (2&|)) ] 8 #: *:@+: 42

I am waiting one or two day before telling which is the other language running the very same piece of code with no error. Just leave comments for trying to guess.
edit: The other language is the stack-based language from the very ancient Unix calculator dc.

It runs without errors in GolfScript, BF, HQ9+, ...

OK, I wasn't aware that such many languages could do it. I edit the code in order to put the language I actually chose.

@ברוכאל it runs without errors in those languages because those languages don't have errors, or don't have errors applicable to this code. Eg. Brainfuck ignores all characters that are not in .,+-<>[] so your program is equivalent to ...[.]+ in brainfuck which is a valid but pointless program. AFAIK a brainfuck program can only be invalid by having mismatched [].

@immibis. This is false. dc is an old calculator and I can assure that changing one thing in my codes would raise an error. I spent much time on some parts of the code to figure out some tricky way of putting the letters in the right order. My piece of code Postscript/dc is quite extreme: no error but changing anything will make it faulty. dc has nothing to do with "those languages"; dc is about 20 or 30 years older than "those languages"; it is generally installed on any Linux distribution. Please, browse a little if you haven't heard about it.

@ברוכאל you misunderstood - I was talking about brainfuck, HQ9+, golfscript, etc. - not dc.

@immibis. Ah OK, sorry. In this case, I agree.

dc running a PostScript file
dc can run the following piece of code with no error:
10 10 10 10 10 42 32 10 10
stop % first send a stop
0 0 srand rand
le pop pop 3.14 sin
lt 2 3 lt and pop
le 2 10 le xor
pop pop pop 1 0 0
<< /sox 2 >> [ exch begin sox end ] aload
3.14 floor

ML/(Strict) Haskell in Java
This is from an actual real project. It makes use of persistent immutable data structures and uses recursion even when not necessary. Actually, it's more like Kore (the language the project implements) in Java, but the style is basically the same as ML. But the philosophy of Kore is that the author shouldn't format his code, so none of the Java code is formatted either (it's autoformatted by eclipse).
drop n elements from a list:
  public static <T> List<T> drop(List<T> l, Integer n) {
    return n == 0 ? l : drop(l.cons().tail, n - 1);
  }

In ML/Haskell, where you'd pattern match to extract the head and tail, here you say list.cons().x and list.cons().tail.
insert an element in a list:
  public static <T> List<T> insert(List<T> l, Integer i, T x) {
    if (i == 0)
      return cons(x, l);
    return cons(l.cons().x, insert(l.cons().tail, i - 1, x));
  }

List is defined literally how the algebraic datatype would be defined. Here is a version with the eclipse-generated boilerplate removed:
public final class List<T> {

  public static final class Nil<T> {
  }

  public static final class Cons<T> {
    public final T x;
    public final List<T> tail;

    public Cons(T x, List<T> tail) {
      if (x == null)
        throw new RuntimeException("null head");
      if (tail == null)
        throw new RuntimeException("null tail");
      this.x = x;
      this.tail = tail;
    }
  }

  private final Nil<T> nil;
  private final Cons<T> cons;

  private List(Nil<T> nil, Cons<T> cons) {
    this.nil = nil;
    this.cons = cons;
  }

  public boolean isEmpty() {
    return nil != null;
  }

  public Nil<T> nil() {
    if (nil == null)
      throw new RuntimeException("not nil");
    return nil;
  }

  public Cons<T> cons() {
    if (cons == null)
      throw new RuntimeException("not cons");
    return cons;
  }

  public static <T> List<T> cons(Cons<T> cons) {
    if (cons == null)
      throw new RuntimeException("constructor received null");
    return new List<T>(null, cons);
  }

  public static <T> List<T> nil(Nil<T> nil) {
    if (nil == null)
      throw new RuntimeException("constructor received null");
    return new List<T>(nil, null);
  }
}

Here is a map data structure implemented in terms of a trie:
public final class Map<K, V> {
  private final Tree<Character, Optional<Pair<K, V>>> tree;
  // keys are sorted in reverse order so entrySet can use cons instead of append
  private final Comparer<Pair<Character, Tree<Character, Optional<Pair<K, V>>>>> comparer =
      new PairLeftComparer<Character, Tree<Character, Optional<Pair<K, V>>>>(
          new ReverseComparer<Character>(new CharacterComparer()));

  private Map(Tree<Character, Optional<Pair<K, V>>> tree) {
    this.tree = tree;
  }

  public static <K, V> Map<K, V> empty() {
    return new Map<K, V>(new Tree<Character, Optional<Pair<K, V>>>(
        OptionalUtils.<Pair<K, V>> nothing(),
        ListUtils
            .<Pair<Character, Tree<Character, Optional<Pair<K, V>>>>> nil()));
  }

  public Optional<V> get(K k) {
    Tree<Character, Optional<Pair<K, V>>> t = tree;
    for (char c : k.toString().toCharArray()) {
      Tree<Character, Optional<Pair<K, V>>> t2 = getEdge(t, c);
      if (t2 == null)
        return nothing();
      t = t2;
    }
    if (t.v.isNothing())
      return nothing();
    return some(t.v.some().x.y);
  }

  public Map<K, V> put(K k, V v) {
    return new Map<K, V>(put(tree, k.toString(), v, k));
  }

  private Tree<Character, Optional<Pair<K, V>>> put(
      Tree<Character, Optional<Pair<K, V>>> t, String s, V v, K k) {
    if (s.equals(""))
      return new Tree<Character, Optional<Pair<K, V>>>(some(Pair.pair(k, v)),
          t.edges);
    char c = s.charAt(0);
    Tree<Character, Optional<Pair<K, V>>> t2 = getEdge(t, c);
    if (t2 == null)
      return new Tree<Character, Optional<Pair<K, V>>>(
          t.v,
          sort(
              cons(
                  pair(
                      c,
                      put(new Tree<Character, Optional<Pair<K, V>>>(
                          OptionalUtils.<Pair<K, V>> nothing(),
                          ListUtils
                              .<Pair<Character, Tree<Character, Optional<Pair<K, V>>>>> nil()),
                          s.substring(1), v, k)), t.edges), comparer));
    return new Tree<Character, Optional<Pair<K, V>>>(t.v, sort(
        replace(pair(c, put(t2, s.substring(1), v, k)), t.edges), comparer));
  }

  private List<Pair<Character, Tree<Character, Optional<Pair<K, V>>>>> replace(
      Pair<Character, Tree<Character, Optional<Pair<K, V>>>> edge,
      List<Pair<Character, Tree<Character, Optional<Pair<K, V>>>>> edges) {
    if (edges.cons().x.x.equals(edge.x))
      return cons(edge, edges.cons().tail);
    return cons(edges.cons().x, replace(edge, edges.cons().tail));
  }

  // I consider this O(1). There are a constant of 2^16 values of
  // char. Either way it's unusual to have a large amount of
  // edges since only ASCII chars are typically used.
  private Tree<Character, Optional<Pair<K, V>>> getEdge(
      Tree<Character, Optional<Pair<K, V>>> t, char c) {
    for (Pair<Character, Tree<Character, Optional<Pair<K, V>>>> p : iter(t.edges))
      if (p.x.equals(c))
        return p.y;
    return null;
  }

  public Map<K, V> delete(K k) {
    return new Map<K, V>(delete(tree, k.toString()).x);
  }

  private Pair<Tree<Character, Optional<Pair<K, V>>>, Boolean> delete(
      Tree<Character, Optional<Pair<K, V>>> t, String k) {
    if (k.equals(""))
      return pair(
          new Tree<Character, Optional<Pair<K, V>>>(
              OptionalUtils.<Pair<K, V>> nothing(), t.edges), t.edges.isEmpty());
    char c = k.charAt(0);
    Tree<Character, Optional<Pair<K, V>>> t2 = getEdge(t, c);
    if (t2 == null)
      return pair(t, false);
    Pair<Tree<Character, Optional<Pair<K, V>>>, Boolean> p =
        delete(t2, k.substring(1));
    List<Pair<Character, Tree<Character, Optional<Pair<K, V>>>>> edges = nil();
    for (Pair<Character, Tree<Character, Optional<Pair<K, V>>>> e : iter(t.edges))
      if (!e.x.equals(c))
        edges = cons(e, edges);
    if (!p.y)
      return pair(
          new Tree<Character, Optional<Pair<K, V>>>(t.v, cons(pair(c, p.x),
              edges)), false);
    boolean oneEdge = t.edges.cons().tail.isEmpty();
    return pair(new Tree<Character, Optional<Pair<K, V>>>(t.v, edges), oneEdge
        && t.v.isNothing());

  }

  public static class Entry<K, V> {
    public Entry(K k, V v) {
      this.k = k;
      this.v = v;
    }

    public final K k;
    public final V v;

  }

  public List<Entry<K, V>> entrySet() {
    return entrySet(ListUtils.<Entry<K, V>> nil(), tree);
  }

  private List<Entry<K, V>> entrySet(List<Entry<K, V>> l,
      Tree<Character, Optional<Pair<K, V>>> t) {
    if (!t.v.isNothing()) {
      Pair<K, V> p = t.v.some().x;
      l = cons(new Entry<K, V>(p.x, p.y), l);
    }
    for (Pair<Character, Tree<Character, Optional<Pair<K, V>>>> e : iter(t.edges))
      l = entrySet(l, e.y);
    return l;
  }
}

The types start to take up as much space as the code. For example, in put, the method has 302 characters of types and 343 characters of code (not counting space/newlines).

BASIC in Ruby
Implemented this long ago. The source is on GitHub. Inspired by a similar thing in Scala
Setup
#!/usr/bin/env ruby

if caller.empty? && ARGV.length > 0
  $file = ARGV[0]
else
  $file = caller.last.split(':').first
end

require 'pp'

class String
  def %(other)
    self + other.to_s
  end
end

class RBaysick
  @@variables = {}
  @@code = []
  @@line = 0

  def initialize(contents)
    $DONT_RUN = true # To avoid endless loops.

    contents.gsub!(/( |\()'([^\W]+)/, '\1:\2 ')

    contents.gsub!(/(^| |\()(:[^\W]+)/, '\1GET(\2)')

    contents.gsub!(/ IF (.*) THEN (.*)/, ' IF { \1 }.THEN { GOTO \2 }')
    contents.gsub!(/LET *\(([^ ]+) *:= *(.*)\)/, 'LET(\1) { \2 }')
    contents.gsub!(/(LET|INPUT)(\(| )GET\(/, '\1\2(')
    contents.gsub!(/ \(/, '(')

    contents.gsub!(/^(\d+) (.*)$/, 'line(\1) { \2 }')

#    contents.gsub!(/(\)|\}|[A-Z]) ([A-Z]+)/, '\1.\2')

    contents.gsub!(/ END /, ' __END ')
    contents.gsub!(/^RUN/, '__RUN')

    puts contents if $DEBUG
    eval contents
  end

  def __RUN
    while @@line > -1
      puts "#{@@line}: #{@@code[@@line].inspect}" if $DEBUG
      unless @@code[@@line].nil?
        @@increment = true
        @@code[@@line].call
        next unless @@increment
      end
      @@line += 1
    end
  end

  class If < Struct.new(:value)
    def THEN
      yield if value
    end
  end

  def method_missing(name, *args)
    puts "Missing: #{name.to_s}(#{args.map(&:inspect).join(', ')})" if $DEBUG
  end

  def variables
    @@variables
  end

  def line(line, &block)
    @@code[line] = block
  end

  def add(line, cmd, *args)
    puts "DEBUG2: #{cmd.to_s}(#{args.map(&:inspect).join(', ')})" if $DEBUG
    @@code[line] = send(cmd, *args)
  end

  def IF
    ::RBaysick::If.new(yield)
  end

  def PRINT(str)
    puts "PRINT(#{str.inspect})" if $DEBUG
    puts str
    true
  end

  def LET(name, &block)
    puts "LET(#{name.inspect}, #{block.inspect})" if $DEBUG
    @@variables[name] = block.call
  end

  def GET(name)
    puts "GET(#{name.inspect}) #=> #{@@variables[name].inspect}" if $DEBUG
    @@variables[name]
  end

  def INPUT(name)
    puts "INPUT(#{name.inspect})" if $DEBUG
    LET(name) { $stdin.gets.chomp.to_i }
  end

  def ABS(val)
    puts "ABS(#{val.inspect}) #=> #{val.abs.inspect}" if $DEBUG
    val.abs
  end

  def GOTO(line)
    @@increment = false
    @@line = line
  end

  def __END
    exit
  end
end

RBaysick.new(open($file).read) unless $DONT_RUN || ($0 != __FILE__)

BASIC code
#!./rbaysick.rb

10 PRINT "Welcome to Baysick Lunar Lander v0.0.1"
20 LET ('dist := 100)
30 LET ('v := 1)
40 LET ('fuel := 1000)
50 LET ('mass := 1000)

60 PRINT "You are a in control of a lunar lander."
70 PRINT "You are drifting towards the surface of the moon."
80 PRINT "Each turn you must decide how much fuel to burn."
90 PRINT "To accelerate enter a positive number, to decelerate a negative"

100 PRINT "Distance " % 'dist % "km, " % "Velocity " % 'v % "km/s, " % "Fuel " % 'fuel
110 INPUT 'burn
120 IF ABS('burn) <= 'fuel THEN 150
130 PRINT "You don't have that much fuel"
140 GOTO 100
150 LET ('v := 'v + 'burn * 10 / ('fuel + 'mass))
160 LET ('fuel := 'fuel - ABS('burn))
170 LET ('dist := 'dist - 'v)
180 IF 'dist > 0 THEN 100
190 PRINT "You have hit the surface"
200 IF 'v < 3 THEN 240
210 PRINT "Hit surface too fast (" % 'v % ")km/s"
220 PRINT "You Crashed!"
230 GOTO 250
240 PRINT "Well done"

250 END

RUN

Haskell in C++ templates
I made this FizzBuzz in C++ templates a few months ago on a lark. It is pretty much an implementation of the following Haskell code, all in C++ templates. In fact, even the integer arithmetic is reimplemented at the type level --- notice that none of the templates use int parameters!
The Haskell code:
import Control.Monad

m `divides` n = (n `mod` m == 0)

toFizzBuzz n
    | 15 `divides` n = "FizzBuzz"
    |  5 `divides` n = "Buzz"
    |  3 `divides` n = "Fizz"
    |      otherwise = show n

main = mapM_ putStrLn $ take 100 $ map toFizzBuzz [1..]

and the C++ template metaprogramming version:
//
//  Lazy compile-time fizzbuzz computed by C++ templates,
//  without conditionals or the use of machine arithmetic.
//
//         -- Matt Noonan (mnoonan@grammatech.com)

#include <iostream>

using namespace std;

//
//  The natural numbers: Nat = Zero | Succ Nat
//

template <typename n>
struct Succ
{
  typedef Succ eval;
  static const unsigned int toInt = 1 + n::toInt;
  static void print(ostream & o) { o << toInt; }
};

struct Zero
{
  typedef Zero eval;
  static const unsigned int toInt = 0;
  static void print(ostream & o) { o << toInt; }
};

//
//  Arithmetic operators
//    Plus Zero n = n
//    Plus Succ(n) m = Plus n Succ(m)
//    Times Zero n = Zero
//    Times Succ(n) m = Plus m (Times n m)
//

template <typename a, typename b>
struct Plus
{
  typedef typename Plus<typename a::eval,
                        typename b::eval>::eval eval;
};

template <typename M>
struct Plus <Zero, M>
{ typedef typename M::eval eval; };

template <typename N, typename M>
struct Plus <Succ<N>, M>
{ typedef typename Plus<N, Succ<M> >::eval eval; };

template <typename a, typename b>
struct Times
{
  typedef typename Times<typename a::eval,
                         typename b::eval>::eval eval;
};

template <typename M>
struct Times <Zero, M>
{ typedef Zero::eval eval; };

template <typename N, typename M>
struct Times <Succ<N>, M>
{ typedef typename Plus<M,
                        typename Times<N,M>::eval
                        >::eval eval; };

//
//  Lists
//

struct Nil
{
  typedef Nil eval;
  static void print(ostream & o) { }
};

template <typename x, typename xs>
struct Cons
{
  typedef Cons eval;
  static void print(ostream & o) {
    x::eval::print(o); o << endl; xs::eval::print(o);
  }
};

//
//  Take the first n elements of a list
//

template <typename, typename> struct Take;

template <typename _> struct Take<Zero,_>
{ typedef Nil eval; };

template <typename n, typename x, typename xs>
struct Take<Succ<n>, Cons<x,xs> >
{
  typedef Cons<x, Take<n, xs> > eval;
};

template <typename a, typename b>
struct Take
{
  typedef typename Take<typename a::eval,
                        typename b::eval>::eval eval;
};

//
//  Iterate f x0 makes the infinite list
//  x0, f(x0), f(f(x0)), ...
//

template <template<typename> class f, typename x0> struct Iterate
{
  typedef Cons<x0, Iterate<f, f<x0> > > eval;
};

//
//  Map a function over a list
//

template <template<typename> class a, typename b> struct Map
{ typedef typename Map<a,
                       typename b::eval>::eval eval;
};

template <template<typename> class f>
struct Map<f, Nil>
{ typedef Nil eval; };

template <template<typename> class f, typename x, typename xs>
struct Map<f, Cons<x,xs> >
{
  typedef Cons<f<x>, Map<f,xs> > eval;
};

//
//  Some useful things for making fizzes and buzzes
//

struct Fizz
{ static void print(ostream & o) { o << "Fizz"; } };

struct Buzz
{ static void print(ostream & o) { o << "Buzz"; } };

struct FizzBuzz
{ static void print(ostream & o) { o << "FizzBuzz"; } };

//
//  Some useful numbers
//

typedef Succ<Zero> One;
typedef Succ<One> Two;
typedef Succ<Two> Three;
typedef Plus<Two, Three> Five;
typedef Times<Two, Five> Ten;
typedef Times<Three, Five> Fifteen;
typedef Times<Ten, Ten> OneHundred;

//
//  Booleans
//

struct True {};
struct False {};

//
//  If/then/else
//

template <typename p, typename t, typename f>
struct If
{
  typedef typename If<typename p::eval, t, f>::eval eval;
  static void print(ostream & o) { eval::print(o); }
};

template <typename t, typename _>
struct If<True, t, _>
{
  typedef t eval;
};

template <typename _, typename f>
struct If<False, _, f>
{ typedef f eval; };

//
//  Testing if x divides y
//

template <typename a, typename b, typename c>
struct _Divides
{
  typedef typename _Divides<typename a::eval,
                            typename b::eval,
                            typename c::eval>::eval eval;
};

template <typename _, typename __>
struct _Divides<_, __, Zero> { typedef False eval; };

template <typename a>
struct _Divides<a, Zero, Zero> { typedef True eval; };

template <typename a, typename b>
struct _Divides<a, Zero, b>
{
  typedef typename _Divides<a, a, b>::eval eval;
};

template <typename _, typename n, typename m>
struct _Divides<_, Succ<n>, Succ<m> >
{
  typedef typename _Divides<_, n, m>::eval eval;
};

template <typename a, typename b>
struct Divides
{
  typedef typename _Divides<a, a, b>::eval eval;
};

//
//  "Otherwise" sugar
//

template <typename a>
struct Otherwise
{
  typedef typename a::eval eval;
  static void print(ostream & o) { a::eval::print(o); }
};

//
//  Convert a number to fizzes, buzzes as appropriate
//

template <typename n>
struct toFizzBuzz
{
  typedef typename
    If< Divides<Fifteen, n>, FizzBuzz,
    If< Divides<   Five, n>,     Buzz,
    If< Divides<  Three, n>,     Fizz,
    Otherwise<                   n
    > > > >::eval eval;
};

int main(void)
{
  // Make all of the natural numbers
  typedef Iterate<Succ, One> Naturals;

  // Apply fizzbuzz rules to every natural number
  typedef Map<toFizzBuzz, Naturals> FizzBuzzedNaturals;

  // Print out the first hundred fizzbuzzed numbers
  Take<OneHundred, FizzBuzzedNaturals>::eval::print(cout);

  return 0;
}

Ruby in JavaScript
Number.prototype.times = function(f){
  for (var i=this; --i;) f()
}
end = 0
function do(s) {return new Function(s)}

//;# Ruby starts here:
(5).times(do("alert('hi!'); end"))

Isn't this ruby in javascript? Not the other way around?

Asp in PHP
fskdfkz

Well I know, not very useful.

ALGOL in C
Steve Bourne already won this contest by writing the original sh in ALGOL in C.
#define IF      if(
#define THEN    ){
#define ELSE    } else {
#define ELIF    } else if (
#define FI      ;}

#define BEGIN   {
#define END     }
#define SWITCH  switch(
#define IN      ){
#define ENDSW   }
#define FOR     for(
#define WHILE   while(
#define DO      ){
#define OD      ;}
#define REP     do{
#define PER     }while(
#define DONE    );
#define LOOP    for(;;){
#define POOL    }

and
LOCAL VOID      gsort(from,to)
        STRING          from[], to[];
{
        INT             k, m, n;
        REG INT         i, j;

        IF (n=to-from)<=1 THEN return FI

        FOR j=1; j<=n; j*=2 DONE

        FOR m=2*j-1; m/=2;
        DO  k=n-m;
            FOR j=0; j=0; i-=m
                DO  REG STRING *fromi; fromi = &from[i];
                    IF cf(fromi[m],fromi[0])>0
                    THEN break;
                    ELSE STRING s; s=fromi[m]; fromi[m]=fromi[0]; fromi[0]=s;
                    FI
                OD
            OD
        OD
}

An operating system where all of the C is also valid Ruby: https://github.com/duckinator/corundum
To run as Ruby: ruby src/kernel.rb
To compile and run the operating system: make qemu
Output of both is Hello, world!\n

Commodore 64 Basic, BBC Basic etc.
Cheeky entry:
10 PRINT "HELLO WORLD"
20 GOTO 10
RUN

I did think about including Spectrum since you can type GOTO, but it renders GO TO, so technically not the same.

HTML in PHP
First thing that came to my mind was apparently stolen by @toscho . But i'm not giving up yet,
<?php
echo "<title>This is HTML in PHP</title>";
echo "<p>Now Beat This!!!</p>";
echo "<br>";
?>

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


text:
Find the odd character out in a pattern
Input
The first line will be a certain string repeated any amount of times. For example, it could be abcabcabcabc, [];[];[];, etc. It may be cut off; for example: 1231231231. Always find the shortest string; for example, if the line is 22222, then the string is 2, not 22 or 22222 or anything else. The string will always be repeated at least 2 full times.
All subsequent lines will be that pattern offset by any number. For example, it could be:
abcabcabc
cabcabcab
bcabcabca

(offset by 1), or it could be:
abcdefabcdefabcdefabc
cdefabcdefabcdefabcde
efabcdefabcdefabcdefa

(offset by 4).
One of the characters in the input will be wrong. (It is guaranteed not to be on the first line.) For example, in this input:
a=1a=1a=1
=1a=1a=1a
1a=11=1a=
a=1a=1a=1
=1a=1a=1a

the 1 on line 3 is the odd one out.
Output
You must output the (zero-based, starting from the top left) coordinates of the odd one out. For example, in the above input, the corresponding output is 4,2. You may also output 4 2, or "4""2", or even [[4],[2]], or any other format, as long as you can tell what the output is supposed to be.
Test cases
Input:
codegolfcodegolfco
egolfcodegolfcodeg
lfcodegolfcodegoff
odegolfcodegolfcod
golfcodegolfcodego
fcodegolfcodegolfc

Output: 16,2
Input:
][[][][[][][[][][[][][[
[][][[][][[][][[][][[][
[][[][][[][][[][][[][][
[[][][[]]][[][][[][][[]

Output: 8,3
Input:
...
. .
...

Output: 1,1
Input:
ababa
babab
ababb
babab

Output: 4,2
Go!

What characters can be contained in the string? Printable ASCII? ASCII? Unicode?

@Dennis Just printable ASCII (that can basically be assumed for any challenge involving strings; otherwise we would have to specify that for almost every challenge :P)

I guessed so. I'm thinking about an approach that would require an unused char, so I thought I'd ask.

Should we check case like this: abc/cab/abc - and output 0 2 here?

@VadimR No, since only one character will be wrong.

Bash Perl, 231 229 218 178 164 166 138 106 74 bytes
/^(((.*).*)\2+)\3$/;$_.=$1x2;$.--,die$+[1]if/^(.*)(.)(.*)
.*\1(?!\2).\3/

The script requires using the -n switch, which accounts for two of the bytes.
The idea of appending two copies of all full repetitions of the pattern has been taken from MT0's answer.
In contrast to all other answers, this approach attempts to extract the pattern of the current input line in each iteration; it will fail on the line containing the odd character (and use the pattern of the previous line instead). This is done to include the pattern extraction in the loop, which manages to save a few bytes.
Ungolfed version
#!/usr/bin/perl -n

# The `-n' switch makes Perl execute the entire script once for each input line, just like
# wrapping `while(<>){…}' around the script would do.

/^(((.*).*)\2+)\3$/;

# This regular expression matches if `((.*).*)' - accessible via the backreference `\2' -
# is repeated at least once, followed by a single repetition of `\3" - zero or more of the
# leftmost characters of `\2' - followed by the end of line. This means `\1' will contain
# all full repetitions of the pattern. Even in the next loop, the contents of `\1' will be
# available in the variable `$1'.

$_.=$1x2;

# Append two copies of `$1' to the current line. For the line, containing the odd
# character, the regular expression will not have matched and the pattern of the previous
# line will get appended.
#
# Since the pattern is repeated at least two full times, the partial pattern repetition at
# the end of the previous line will be shorter than the string before it. This means that
# the entire line will the shorter than 1.5 times the full repetitions of the pattern,
# making the two copies of the full repetitions of the pattern at least three times as
# long as the input lines.

$.-- , die $+[1] if

# If the regular expression below matches, do the following:
#
#   1. Decrement the variable `$.', which contains the input line number.
#
#      This is done to obtain zero-based coordinates.
#
#   2. Print `$+[1]' - the position of the last character of the first subpattern of the
#      regular expression - plus some additional information to STDERR and exit.
#
#      Notably, `die' prints the (decremented) current line number.

/^(.*)(.)(.*)
.*\1(?!\2).\3/;

# `(.*)(.)(.*)', enclosed by `^' and a newline, divides the current input line into three
# parts, which will be accesible via the backreferences `\1' to `\3'. Note that `\2'
# contains a single character.
#
# `.*\1(?!\2).\3' matches the current input line, except for the single character between
# `\1' and `\3' which has to be different from that in `\2', at any position of the line
# containing the pattern repetitions. Since this line is at least thrice as long as
# `\1(?!\2).\3', it will be matched regardless of by how many characters the line has been
# rotated.

Example
For the test case
codegolfcodegolfco
egolfcodegolfcodeg
lfcodegolfcodegoff
odegolfcodegolfcod
golfcodegolfcodego
fcodegolfcodegolfc

the output of the golfed version is
16 at script.pl line 1, <> line 2.

meaning that the odd character has the coordinates 16,2.
This blatantly abuses takes advantage of the liberal output format.
Just before exiting, the contents of some of Perl's special variables are:
$_  = lfcodegolfcodegoff\ncodegolfcodegolfcodegolfcodegolf
$1  = lfcodegolfcodego
$2  = f
$3  = f

($n contains the match of the subpattern accessible via the backreference \n.)

Clever catching of the reply unit. It can be optimized by one byte: ^((.*?)(.*?))(?=\1+\2$)

I switched to the language the popular kids are using. Can probably be golfed down further; this is my first Perl script in over a decade...

...and you're over a decade late if you think perl is what the popular kids are using

this answer isn't getting the love it deserves. looks to me like the winner @Doorknob

Perl, 212 191 181 168 bytes
$_=<>;/^(((.*?)(.*?))\2+)\3$/;$x=$1x4;while(<>){chop;$x=~/\Q$_\E/&&next;for$i(0..y///c-1){for$r(split//,$x){$b=$_;$b=~s/(.{$i})./$1$r/;$x=~/\Q$b\E/&&die$i,$",$.-1,$/}}}

This version uses an optimized trick for catching the reply unit, learned in Dennis' answer.
Optimization by using the property that all lines have equal lengths.
Line end is also needed for the last line, otherwise chomp instead of chop should be used.
Optimizations of ardnew's comment added.

Old version, 212 bytes:
$_=<>;chop;/^(.+?)\1+(??{".{0,".(-1+length$1).'}'})$/;$;=$1;while(<>){$x=$;x length;chop;$x=~/\Q$_\E/&&next;for$i(0..-1+length$_){for$r(split//,$;){$b=$_;$b=~s/(.{$i})./$1$r/;$x=~/\Q$b\E/&&exit print$i,$",$.-1}}}

Ungolfed version:
$_ = <>;  # read first line
/^(((.*?)(.*?))\2+)\3$/;
# The repeat unit \2 consists of \3 and \4,
# and the start part \2 can be added at the end (as partial or even full unit).
$x = $1 x 4; # $x is long enough to cover each following line

# Old version:
# /^(.+?)\1+(??{ ".{0," . (-1 + length $1) . '}' })$/;
# $a = $1; # $a is the repeat unit.
# The unit is caught by a non-greedy pattern (.+?) that is
# repeated at least once: \1+
# The remaining characters must be less than the unit length.
# The unit length is known at run-time, therefore a "postponed"
# regular expression is used for the remainder.

# process the following lines until the error is found
while (<>) {
    # old version:
    # $x = $a x length;
    # $x contains the repeated string unit, by at least one unit longer
    # than the string in the current line
    chop; # remove line end of current line
    $x =~ /\Q$_\E/ && next;
          # go to next line, if current string is a substring of the repeated units;
          # \Q...\E prevents the interpretation of special characters
    # now each string position $x is checked, if it contains the wrong character:
    for $i (0 .. y///c - 1) {  # y///c yields the length of $_
        for $r (split //, $x) { #/ (old version uses $a)
            # replace the character at position $i with a
            # character from the repeat unit
            $b = $_;
            $b =~ s/(.{$i})./$1$r/;
            $x =~ /\Q$b\E/
               && die $i, $", $. - 1, $/;
               # $" sets a space and the newline is added by $/;
               # the newline prevents "die" from outputting line numbers
        }
    }
}

Great solution and comments, I need to learn more regex ;)

the first chop is unnecessary- should be removed. the final exit print can be replaced with die (add ,$/ to hide the extra stuff (if required)). also length$_ can be replaced with y///c

@ardnew: Many thanks, I have removed the first chop, because $ matches before the newline at the end of the string. Hiding the extra stuff of die via the added newline seems necessary to me. Also y///c is much shorter than length$_ and one byte shorter than length without the unnecessary $_.

@ardnew: I had forgotten about die's verbosity. It even includes prints the line number! I'll use that in my next update.

C, 187 bytes
Limitations.

Don't use input strings longer than 98 characters :)

Golfed version
char s[99],z[99],*k,p,i,I,o,a;c(){for(i=0;k[i]==s[(i+o)%p];i++);return k[i];}main(){for(gets(k=s);c(p++););for(;!(o=o>p&&printf("%d,%d\n",I,a))&&gets(k=z);a++)while(o++<p&&c())I=I<i?i:I;}

Ungolfed version
char s[99],z[99],*k,p,i,I,o,a;

c()
{
    for(i=0
       ;k[i]==s[(i+o)%p]
       ;i++)
       ;
    return k[i];
}

main()
{
    for(gets(k=s);c(p++);)
         ;
    for(;!(o=o>p&&printf("%d,%d\n",I,a)) && gets(k=z);a++)
           while(o++ < p && c())
            I=I<i?i:I;
}

Python, 303 292
r=raw_input
R=range
s=r()
l=len(s)
m=1
g=s[:[all((lambda x:x[1:]==x[:-1])(s[n::k])for n in R(k))for k in R(1,l)].index(True)+1]*l*2
while 1:
 t=r()
 z=[map(lambda p:p[0]==p[1],zip(t,g[n:l+n]))for n in R(l)]
 any(all(y)for y in z)or exit("%d,%d"%(max(map(lambda b:b.index(False),z)),m))
 m+=1

Input goes through stdin. I'll explain it if there's any demand, but it doesn't look like I'm going to win anyway.

Perl, 157 154
Edit: -3 thanks to ardnew' suggestion.
<>=~/^(((.*?).*?)\2+)\3$/;$p=$2;$n=$+[1];while(<>){s/.{$n}/$&$&/;/(\Q$p\E)+/g;$s=$p;1while/./g*$s=~/\G\Q$&/g;print$n>--($m=pos)?$m:$m-$n,$",$.-1,$/if pos}

It took me some time (on and off, of course, not 5 days ;-) ), and idea about algorithm was initially elusive (though I felt it was there), but finally (and suddenly) it became all clear.
If string length is multiple of pattern length, and even if the string doesn't start with the beginning of the pattern, concatenating string with itself will produce pattern in place of concatenation (imagine infinite repetition of a word on circular ribbon - the place of welding is not important). So, the idea is to trim the line to multiple unit length and concatenate original to it. The result, even for the string containing the wrong character, is guaranteed to match to pattern at least once. From there on it's easy to find position of offending character.
First line is shamelessly borrowed from Heiko Oberdiek's answer :-)
<>=~/^(((.*?).*?)\2+)\3$/;      # Read first line, find the repeating unit
$p=$2;                          # and length of whole number of units.
$n=$+[1];                       # Store as $p and $n.
while(<>){                      # Repeat for each line.
    s/.{$n}/$&$&/;              # Extract first $n chars and
                                # append original line to them.
    /(\Q$p\E)+/g;               # Match until failure (not necessarily from the
                                # beginning - doesn't matter).
    $s=$p;                      # This is just to reset global match position
                                # for $s (which is $p) - we could do without $s,
                                # $p.=''; but it's one char longer.
                                # From here, whole pattern doesn't match -
    1while/./g*$s=~/\G\Q$&/g;   # check by single char.
                                # Extract next char (if possible), match to
                                # appropriate position in a pattern (position
                                # maintained by \G assertion and g modifier).
                                # We either exhaust the string (then pos is
                                # undefined and this was not the string we're
                                # looking for) or find offending char position.

    print$n>--($m=pos)?$m:$m-$n,$",$.-1,$/if pos
}

nice work. i think you can replace /.{$n}/;$_=$&.$_; with s/.{$n}/$&$&/;

JavaScript (ES6) - 147 133 136 Characters
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Expects the string to be tested to be in the variable s and outputs the result to the console.
var repetitionRE = /^(((.*).*)\2+)\3\n/;
                                        // Regular expression to find repeating sequence
                                        // without any trailing sub-string of the sequence.
var sequence = repetitionRE.exec(s)[1]; // Find the sequence string.
s.split('\n')                           // Split the input into an array.
 .map(
   ( row, index ) =>                    // Anonymous function using ES6 arrow syntax
   {
     var testStr = row + '᛫'+ sequence + sequence;
                                        // Concatenate the current row, a character which won't
                                        // appear in the input and two copies of the repetitions
                                        // of the sequence from the first line.
     var match = /^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(testStr);
                                        // Left of the ᛫ finds sub-matches for a single
                                        // character and the sub-strings before and after.
                                        // Right of the ᛫ looks for any number of characters
                                        // then the before and after sub-matches with a
                                        // different character between.
      if ( match )
       console.log( match[1].length, index );
                                        // Output the index of the non-matching character
                                        // and the row.
   }
 );

Test Case 1
s="codegolfcodegolfco\negolfcodegolfcodeg\nlfcodegolfcodegoff\nodegolfcodegolfcod\ngolfcodegolfcodego\nfcodegolfcodegolfc"
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Outputs
16 2

Test Case 2
s="][[][][[][][[][][[][][[\n[][][[][][[][][[][][[][\n[][[][][[][][[][][[][][\n[[][][[]]][[][][[][][[]"
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Outputs
8 3

Test Case 3
s="...\n. .\n..."
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Outputs
1 1

Test Case 4
s="ababa\nbabab\nababb\nbabab"
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Outputs
4 2

Test Case 5
s="xyxy\nyyxy"
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Outputs
0 1

Test Case 6
s="ababaababa\nababaaaaba"
s.split('\n').map((x,i)=>(v=/^(.*)(.)(.*)᛫.*\1(?!\2).\3/.exec(x+'᛫'+(a=/^(((.*).*)\2+)\3\n/.exec(s)[1])+a))&&console.log(v[1].length,i))

Outputs
6 1

Sadly, this approach fails if, e.g., s="xyxy\nyyxy". For the second line, match[4] will be yy; it should be just y.

Re-worked and shortened by 14 characters.

Very nice! I had tried the very same second regex at some point, but I appended the minimal pattern twice instead of the maximal one (and, thus, failed miserable). One minor issue: The first regex will report abab ast the pattern of ababaababa; you need to use ^…$.

/^…\n/ works or /^…$/m

It may not need the leading ^ (at least it doesn't for any of the 6 test case I've listed - but there is probably a counter example where it does so I've left it in).

source: Stack Exchange

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

sort: votes