So the puzzle is to write a hello world program [1] in your language of choice, where the program's source file as a string has to be a palindrome [2].
To be clear, the output has to be exactly "Hello, World".
Well, with comments it seems trivial (not that I thought of it myself of course [sigh].. hat tip to cobbal [3]).
So new rule: no comments.
I feel kind of bad editing someone else's question to say this, but it will eliminate a lot of non-palindromes that keep popping up, and I'm tired of seeing the same simple mistake over and over.
The following is NOT a palindrome:
()()
The following IS a palindrome:
())(
Brackets, parenthesis, and anything else that must match are a major barrier to palindrome-ing, yes, but that doesn't mean you can ignore them and post non-palindrome answers.
C, C++, Bash, elisp, C#, Perl, sh, Windows shell, Java, Common Lisp, Awk, Ruby, Brainfuck, Funge, Python, Machine Language, HQ9+, Assembly, TCL, J, php, Haskell, io, TeX, APL, Javascript, mIRC Script, Basic, Orc, Fortran, Unlambda, Pseudo-code, Befunge, CFML, Lua, INTERCAL, VBScript, HTML, sed, PostScript, GolfScript, REBOL, SQL
In a language that shall not be named [1]:
++++++++++>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++++++++++++++>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
<.<.<.<.<.<.<.<.<.<.<.<.<.<
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>++++++++++
[1] http://www.muppetlabs.com/~breadbox/bf/;3
- Xavier Ho
I started from Tiny Programs [1] and wrote my own assembly. Sure, maybe it can be reduced further, but I don't know which other ELF header fields I can subvert for use as code while still being portable.
$ wc -c hellolleh 245 hellolleh $ xxd hellolleh 0000000: 7f45 4c46 0101 0100 0000 0000 0000 0000 .ELF............ 0000010: 0200 0300 0100 0000 5000 9331 2c00 0000 ........P..1,... 0000020: 0000 0000 0000 0000 3400 2000 0100 0000 ........4. ..... 0000030: 0000 0000 0000 9331 c040 cd80 f800 0000 .......1.@...... 0000040: 7401 0000 0700 0000 0010 0000 f7d8 ebe6 t............... 0000050: 686f 726c 6468 6f2c 2057 6848 656c 6cb8 horldho, WhHell. 0000060: 0400 0000 bb01 0000 0089 e1ba 0c00 0000 ................ 0000070: cd80 bb00 0000 00e9 baff ffff bae9 0000 ................ 0000080: 0000 bb80 cd00 0000 0cba e189 0000 0001 ................ 0000090: bb00 0000 04b8 6c6c 6548 6857 202c 6f68 ......lleHhW ,oh 00000a0: 646c 726f 68e6 ebd8 f700 0010 0000 0000 dlroh........... 00000b0: 0700 0001 7400 0000 f880 cd40 c031 9300 ....t......@.1.. 00000c0: 0000 0000 0000 0000 0100 2000 3400 0000 .......... .4... 00000d0: 0000 0000 0000 0000 2c31 9300 5000 0000 ........,1..P... 00000e0: 0100 0300 0200 0000 0000 0000 0000 0101 ................ 00000f0: 0146 4c45 7f .FLE. $ file hellolleh hellolleh: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, corrupted section header size $ ./hellolleh Hello, World
(You can use xxd -r
to load this hexdump back into a binary file.)
cheating by comments in a shell script of your choice (bash for me)
echo 'hello world' # 'dlrow olleh' ohce
Edit:
And using the preprocessor in c you can use
#define foo fidne#
#include <stdio.h>
int main() {
printf("hello world\n");
}
#if 0
0 fi#
}
;)"n\dlrow olleh"(ftnirp
{ )(niam tni
>h.oidts< edilcni#
#endif oof enifed#
Edit: updated C code to remove all warnings in gcc (still one in Comeau though)
updated C code to be palindrome (thanks Can Berk Güder)
Edit:
And the simple, elegant, elisp solution
(message "%s" "hello world")'("dlrow olleh" "s%" egassem)
Although this is not a strict palindrome as I had to reverse parens
Pseudocode:
Output "Hello, World".
Ignore the two next lines.
.senil txen owt eht erongI
."dlroW ,olleH" tuptuO
__END__
or =cut
:) - ephemient
In the Machine Language Monitor on an Apple //e, type N300G003N to run this program:
300: A2 0C BD 0B 03 20 ED FD CA D0 F7 60 E4 EC F2 EF D7 A0 AC EF EC EC E5 C8 8C 5E CE CE FE CA 0A 7D FE 2F CE 4E 06 7F 0D AC DF DE 02 30 B0 DB C0 2A :003
Perl:
print + "Hello, World\n";"n\dlroW ,olleH" + tnirp
Haskell. Actually pretty easy :)
main = putStr hw
hw = const "Hello, World" ab
a = ba ; niam = main ; ab = a
ba "dlroW ,olleH" tsnoc = wh
wh rtStup = niam
Or, in a comment by Reid Barton:
main = putStr `id` "Hello, World"
niam = main
"dlroW ,olleH" `di` rtStup = niam
Another variation:
main = const putStr main "Hello, World" where erehw "dlroW ,olleH" niam rtStup tsnoc = niam
main = putStr `id` "Hello, World" ; niam = main ; "dlroW ,olleH" `di` rtStup = niam
- Reid Barton
Python 2.5:
'''dlroW ,olleH' tnirp
'''
print 'Hello, World'''
"""dlrow ,olleH" tnirp;""";print "Hello, world"""
- gnibbler
That should work on most shells (sh, bash and (thanks to Paulius Maruška) even in Windows ;-) ):
echo Hello World || dlroW olleH ohce
proof (the key is the lazy evaluation if echo Hello World
succeeds, which does):
$ echo Hello World || dlroW olleH ohce
Hello World
Another one in sh/bash:
alias dlroW=true saila=true
echo Hello World;dlroW olleH ohce
eurt=alias eurt=World saila
EDIT: My old one (in bash, too) was not correct:
cat <(echo Hello World >&2;2&> dlroW olleH ohce)< tac
is no palindrome since the brackets are the wrong way and it needs a file called tac
in the actual directory.
Here's my answer in TCL:
proc unknown args {puts "Hello World!"}
}"!dlroW olleH" stup{ sgra nwonknu corp
Gotta love a language where the quote rules are really more guidelines than rules. The very fact that line 2 makes no sense causes line 1 to greet the user.
Actually, i think the proc unknown
mechanism in tcl is really helpful in some cases and I miss it in other languages.
: ? . ! ;
is typically part of the language. - David Thornley
puts Hello\ World;#;dlrow \olleH stup
though it makes me feel dirty using a comment. Not as much as voting for that abortion of a solution would though. (Damnit, I'm a Tcl developer! I refuse to endorse ugliness in my creations!) - Donal Fellows
In common lisp (using no comments or syntactic sugar). Prints only "Hello World!" and returns NIL.
(let (tel etouq)
(let (tamrof etouq)
(format t "Hello World!"
"!dlroW olleH" t tamrof)
(quote format)
tel)
(quote let)
tel)
Surprise surprise, Jon Skeet has done that [1] ;-)
[1] http://stackoverflow.com/questions/284797/hello-world-in-less-than-20-bytes/284898#284898Befunge [1]
0"dlroW ,olleH"v<
@_,^ >#:^
^:#> ^,_@
<v"Hello, World"0
[1] http://en.wikipedia.org/wiki/BefungeIn HQ9+ [1],
H
edit:
As the challenge clearly notes, the output has to be exactly "Hello, World" whereas HQ9+ prints "Hello, world!" and so here is a special version of HQ9+ written in C [2] that when compiled will output exactly "Hello, World" using the following command:
./hq9 "" -9qH H one letter palindrome
[1] http://www.cliff.biffle.org/esoterica/hq9plus.htmlI wanted to code a C solution that doesn't use #if
or #ifdef
s because I think of them as just another form of comments.
So! Here is my attempt, completely free of comments, #if
s and #ifdef
s.
I used gcc 4.3.2
, with the -Wall
flag; it compiled without warnings or errors.
#define niam ){printf("Hello, World\n");return 0;}x(( z enifed#
;int(y);
#define x(x)
#include <stdio.h>
#define tni 0)
#define y int y=
int main(niam tni
=y tni y enifed#
)0 int enifed#
>h.oidts< edulcni#
)x(x enifed#
;)y(tni;
#define z ((x};0 nruter;)"n\dlroW ,olleH"(ftnirp{) main enifed#
Or in yet another language that shall not be named [1]:
"!dlroW olleH">:#,_@_,#:>"Hello World!"
Shortest yet (in TeX):
Hello, world\end dne\dlrow ,olleH
Hello/-/olleH
or Hello(-(olleH
- Pool
C++
Not sure if this is considered cheating or not :P
int main() //
{ // }
// ;0 nruter
printf("Hello, World"); // ;)"dlroW, olleH"(ftnirp
return 0; //
} // {
// )(niam tni
And people say this is hard in python (edited, didn't see the "no comments" rule)...
" \"" and print('Hello, world') and " dna )'dlrow ,olleH'(tnirp dna ""\ "
I challenge anyone to do better: this not only is one line, but it returns None so you don't get any extra output if you type it into the Python REPL.
print
as a function. - ephemient
" \"dna enoN;'dlrow olleH'tnirp;enoN dna"and None;print'Hello world';None and"\ "
- Markus Jarderot
Someone had to do it eventually....
PLEASE,1<-#12DO,1SUB#1<-#238DONOTODPUEVIGOD1,TUODAERESAELPDO,1SUB#2<-
#108DON'TONOD61#-<21#BUS1,ODPLEASE,1SUB#3<-#112DON'T'NOD42#-<11
#BUS1,ODO,1SUB#4<-#0DONOT'NESAELP861#-<01#BUS1,ODO,1SUB
#5<-#64PLEASENOTONOD442#-<9#BUS1,ODO,1SUB#6<-
#194DON'TONOD62#-<8#BUS1,ESAELPDO,1
SUB#7<-#48DON'T'NOD84#-<7#BUS
1,ODPLEASE,1SUB#8<-#26DONOT'NOD491#
-<6#BUS1,ODO,1SUB#9<-#244DONOTONESAELP46#-<5#
BUS1,ODO,1SUB#10<-#168PLEASEN'TONOD0#-<4#BUS1,ODO,1SUB#
11<-#24DON'T'NOD211#-<3#BUS1,ESAELPDO,1SUB#12<-#16DONOT'NOD801#
-<2#BUS1,ODPLEASEREADOUT,1DOGIVEUPDOTONOD832#-<1#BUS1,OD21#-<1,ESAELP
Basic (Someone had to do it)
10 PRINT "HELLO WORLD" : GOTO 20 : DNE 02
20 END : 02 OTOG : "DLROW OLLEH" TNIRP 01
Explanation: Basic is an interpreted language. The interpreter doesn't parse the source it doesn't need to. ':' is statement separator like ';' in C-like languages.
In fact this works too, it prints Hello World, but stops with an error.
10 PRINT "HELLO WORLD" : "DLROW OLLEH" TNIRP 01
Here's what I have so far in Java:
//}
;class tni
/*//;"*/{ public static void main(String[]gnirtS) { /*"
+"*/System.out.println(new StringBuilder().toString()+'H'+'e'+'l'+'l'+'o'+','+' '+'W'+'o'+'r'+'l'+'d'); /*"
+"*/} /*"
+"*/String gnirtS = " = String gnirtS/*"+
"*/ }/*"+
"*/ ;)'d'+'l'+'r'+'o'+'W'+' '+','+'o'+'l'+'l'+'e'+'H'+)(gnirtSot.)(redliuBgnirtS wen(nltnirp.tuo.metsyS/*"+
"*/ { )String][gnirtS(niam diov citats cilbup {/*";//*/
int ssalc;
}//
Only one of the comments is in violation of the spirit of the rules: the //}
at the very start. The rest are just to mask newlines; I could take them out if I wrote the main part of the program on one line.
The center of the palindrome is the quotation mark: String gnirtS =
"
I'm pretty sure it's actually a palindrome. What's the easiest way to check?
EDIT: It wasn't quite, but now it is.
Perl, inspired by the awk [1] and php [2] solutions:
BEGIN{print"Hello, World";exit}tixe;"dlroW ,olleH"tnirp{NIGEB
It exits before it discovers that the remainder of the file doesn't make any sense.
[1] http://stackoverflow.com/questions/659752/660085#660085Ruby:
puts %"Hello, World!" || "!dlroW ,olleH"% stup
p %'Hello, World' % 'dlroW ,olleH'% p
- Jonas Elfström
"Hello, World" || "dlroW ,olleH"
This is an even shorter variation on several that we've seen already. The interesting thing about this one is that it works in several languages, depending on your interpretation of the rules (whether quotes are allowed to be printed out or not):
Javascript, as executed in the Spidermonkey interpreter:
$ js
js> "Hello, World" || "dlroW ,olleH"
Hello, World
Ruby:
$ irb
irb(main):001:0> "Hello, World" || "dlroW ,olleH"
=> "Hello, world"
In Ruby,
tcepsni = puts "hello world!" || "!dlrow olleh"
stup = inspect
(argg, there's a newline)
print %"Hello, World!" || "!dlroW ,olleH"% tnirp
- Jonas Elfström
Python 2.x:
"t\";]41:1[";print"\tHello, World..dlorW ,olleHt\"tnirp;"[1:14];"\t"
@Dietrich Epp: 5 characters shorter.
In APL [1] :
'Hello World!',13↓31,'!dlroW olleH'
And within a dynamic function (only in Dyalog APL dialect) :
⍬{'Hello World!',13↓31,'!dlroW olleH'}⍬
Of course, again the brackets make it a mirror image rather than a strict palindrome.
[1] http://www.dyalog.com/Another language that cannot be named [1], albeit in a different sense:
100 108 114 111 87 32 44 111 108*101 72!!!!!!
!!!!!!27 101*801 111 44 23 78 111 411 801 001
[1] http://wwwep.stewartsplace.org.uk/languages/tlwnn/Lua
x=print"Hello, world"=="dlrow ,olleH"tnirp=x
PostScript, no comments, 41 chars:
(Hello, World)= quit tiuq =)dlroW ,olleH(
The interpreter stops parsing after quit
... the rest of it is syntactically ill-formed. Here's a version that runs until the end (135 characters):
[/Hello,!World/ pop 12 string/ pop cvs/ pop
dup/ pop 6 32 put/ pop = pop /tup 23 6 pop /pud
pop /svc pop /gnirts 21 pop /dlroW!,olleH/[
The fact that strings are delimited by nonidentical characters (parens) makes this a bit harder. Ironically, one can get around this by using pop
in the right places; pop
itself is quite coincidentally (and usefully so) a palindrome. ☆^_^☆
pop
is quite a lifesaver, actually. I'm not sure how this would be possible if the operator's name weren't a palindrome. :o
Here's a slightly longer version without pop
(180 chars):
[/dlroW!,olleH/x/tup/x/pud/x/svc/x/gnirts/Hello,!World
12 string cvs dup 6 32 put =/nigeb>>begin/= tup 23 6 pud svc gnirts 21
dlroW!,olleH/string/x/cvs/x/dup/x/put/x/Hello,!World/[
Write in "in your language of choice" leaves a pretty big hole. My language of choice for this problem is a home-brew language consisting of one command. So here is the code calling that one command:
HelloolleH
Of course what that command does is print Hello World.
Using comments:
/**/print"Hello, World!";/*/"!dlroW ,olleH"tnirp/**/
Io [1]:
forward := method
"Hello, world" print
tnirp "dlrow, olleH"
dohtem =: drawrof
[1] http://iolanguage.com/here's my language:
a
is equivelant to white space
b
prints "Hello, world"
so here's the program:
aaaaaaa
aaaaaaa
aaaaaaa
aaabaaa
aaaaaaa
aaaaaaa
aaaaaaa
mIRC Script:
//echo Hello, World | alias dlrow noop poon world saila | dlroW ,olleH ohce//
Javascript:
(alert)('Hello, World') && ('dlroW ,olleH')(trela)
Orc
[1]: "hello world" << "dlrow olleh"
The "<<" runs both the LHS and RHS in parallel, but only returns the value of the LHS, which the interpreter prints. Follow the Orc link to learn more about Orc (there is a "Try Orc" link where you can run this program yourself).
[1] http://orc.csres.utexas.eduHelp. I got this far in C++ (using macros). So I'm posting this as a wiki and welcoming help.
#define x // fidne#
#include <iostream>
int main() { std::cout << "Hello, World\n"; }
#ifdef N
N fedfi#
} ;"n\dlroW ,olleH" << touc::dts { )(niam tni
>maertsoi< edulcni#
#endif // x
Awk:
BEGIN { print "Hello, World"; exit } { tixe ;"dlroW ,olleH" tnirp } NIGEB
/ \/ }{ / {} BEGIN { print "Hello, world"; exit } /\
\/ } tixe ;"dlrow ,olleH" tnirp { NIGEB }{ / {} /\ /
Old one did not work because of the braces. The new one uses regex literals to embed the reversed code.
Plain bash.
echo "Hello World" || "dlroW olleH" oche
Fortran:
!DNE PROGRAM PAL! print *,'Hello World!' ! ! '!dlroW olleH',* tnirp !LAP MARGORP END!
or the slightly shorter:
!DNE print *,"Hello, World"! !"dlroW ,olleH",* tnirp END!
<?php ">?tixe;";echo 1?"\x48ello, World":"dlroW ,olle84x\"?1 ohce;";exit?>" php?<
"dlrow ,olleH";"Hello, World"
';' means pop and discard
In python 2 lines:
tnirp = 'Hello, World' # print tnirp
print tnirp # 'dlroW ,olleH' = print
can be wrote in 3 lines........
Python is really tough. Here's the best I can do.
"hello world"
tnirp, fi = True, __doc__#
if tnirp:print fi
#__cod__ ,eurT = if ,print
"dlrow olleh"
Common Lisp:
(or' "Hello, World" "dlroW ,olleH" 'ro)
Both shortest and simplest one? SBCL + Slime:
"dlroW ,olleH""Hello, World"
Ruby:
;puts 'Hello! World'.tr'!,;q%,',%q;,!'rt.'dlroW !olleH' stup;
I was really hoping to find a way to make good use of the second half (string) rather than having it sit there just like if I had added a comment... But so far I've only got it fixing the exclamation into a comma...
Unlambda:
`?d`?c`?d`?c`?d`?c`?d``v````````````.H.e.l.l.o.,. .W.o.r.l.di`d
```````````````
d`id.l.r.o.W. .,.o.l.l.e.H.````````````v``d?`c?`d?`c?`d?`c?`d?`
Here it is in CFML [1], without using comments:
<cfsetting enablecfoutputonly="true"/>
<cfoutput>Hello, World</cfoutput>
>tuptuofc/<dlroW ,olleH>tuptuofc<
>/"eurt"=ylnotuptuofcelbane gnittesfc<
Or, an extended version that would still work inserted into almost any page, even if global debugging is on:
>/trobafc<<cfcontent reset />
<cfsetting enablecfoutputonly="true" showdebugoutput="false" />
<cfoutput>Hello, World</cfoutput>
>tuptuofc/<dlroW ,olleH>tuptuofc<
>/ "esalf"=tptuogubedwohs "eurt"=ylnotuptuofcelbane gnittesfc<
>/ teser tnetnocfc<<cfabort/>
[1] http://opencfml.org/shell + Perl
perl -e 'print "Hello, World\n"' '"n\dlroW ,olleH" tnirp' e- lrep
vbscript:
msgbox+"Hello, World"+y,00,y+"dlroW ,olleH"+xobgsm
sed, no comments, 51 characters:
;;s/.*\|;s/Hello, World/;q;/dlroW ,olleH/s;|\*./s;;
Give it anything as input: echo SOMETHING | sed -f thisfile.sed
The autocolorcoding looks pretty nice on this one. ☆^_^☆
Representing REBOL [1]:
REBOL [] print "Hello world!" halt tlah "!dlrow olleH" tnirp [] LOBER
[1] http://www.rebol.com/'Hello World!'['!dlroW olleH'
Easy - [
returns the left argument.
It is not strictly a palindrome, but with omiting whitespaces it is :-)
Whitespace code:
H
e
l
l
o
,
.
W
o
r
l
d
.
.
.
.
.
.
d
l
r
o
W
.
,
o
l
l
e
H
More readable format, S-space, T-tab:
.SSSSS
.SSSTSTS
.SSSTTSSTSS
.SSSTTSTTSS
.SSSTTTSSTS
.SSSTTSTTTT
.SSSTSTSTTT
.SSSTSSSSS
.SSSTSSSSS
.SSSTSTTSS
.SSSTTSTTTT
.SSSTTSTTSS
.S
.SSSSTTSSTST
.SSSTSSTSSS
.
.SSS
.T
.SSS
.S
.TST
.
.S
.S
.
.SST
.
.
.
.
If I write a normal hello world in c++ without comments or newlines and append a '/', then I have the first half of a working palindromatic program...
Ah, the #include
causes a small problem
Like this:
#include <iostream>//
int main(void){std::cout<<"Hello, world!"<<std::endl;}/
Well, easy if you allow comments.
Just (pseudo-code for any language):
program-that-prints-hello-world // dlrow-olleh-strnirp-taht-margorp
Of course, if you disallow comments, then it becomes much harder.
Here's a C# version:
class P { static void Main() { System.Console.WriteLine("Hello world"); } } //
} };)"dlrow olleH"(eniLetirW.elosnoC.metsyS { )(niaM diov citats { P ssalc
Just put everything on the second line after // with a space in front.
(println "Hello, World!") ; )"!dlroW ,olleH" nltnirp(
I cheat.
JavaScript (cheating):
alert("Hello world"); // ;)"dlrow olleH"(trela
yet another Haskell solution:
main = putStrLn "Hello World!" -- "!dlroW olleH" nLrtStup = niam
Python:
print "Hello, World" # "dlroW ,olleH" tnirp
HTML no comments :D
Hello, World<p style="display:none;">";enon:yalpsid"=elyts p<dlroW ,olleH
I think somebody should do this!
In PL/SQL:
Begin --
DBMS_OUTPUT.Put_Line('Hello, World'); --
End; --
-- ;dnE
-- ;)'dlroW ,olleH'(eniL_tuP.TUPTOU_SMBD
-- nigeB
Thanks.
Windows PowerShell:
"Hello World" # "dlroW olleH"
Since you allowed any language I want, I can cheat\b\b\b\b\bdefine a new language, in which the empty string translates to the program that prints out "hello world". Since the empty string is a palindrome, I present my solution in this language: "".
Javascript:
alert("Hello, world");)"dlrow , olleH"(trela
I don't have time to test this out, but if I remember correctly, most browsers just stop executing the Javascript when an error occurs.