Produce a text file that prints "Hello World!" in as many programming languages as possible when compiled/interpreted, while also being as short as possible.

The score for your submission is calculated as C / 2 ^ ((L - 1) / 4), where "C" is the length of the text file in characters and "L" is the number of languages that the program is valid in. Lowest score wins, of course.

  • 1
    This question is similar to this other one, but in this case, you can share "Hello World" among some languages if you wish. – Joe Z. Feb 15 '13 at 18:52
  • Does it have to be a whole program or just a valid command? – ASCIIThenANSI May 17 '15 at 14:45
up vote 16 down vote accepted
print("Hello World!")

Works in at least Julia, Perl, PHP, Python2, Python3, Qbasic, R, Ruby ...

  • 1
    It also works in R and Julia (and surely in many other languages). – Sven Hohenstein Feb 19 '13 at 7:20
  • 2
    @jdstankosky, that exact code not works in PHP. pastebin.com/9x6HactK – manatwork Mar 9 '13 at 16:17
  • 1
    Kind of forcing the limits, but we can say it works in JavaScript too, as some command line interpreters provide print() function for outputting. pastebin.com/6fXtgFER – manatwork Mar 9 '13 at 18:14
  • 2
    works in lua too – mniip Dec 31 '13 at 1:54
  • 1
    @gnibbler, doesn't work in PHP without the opening tags. – Tyzoid Dec 31 '13 at 3:10

JavaScript ES6, Oration, Vitsy, Minkolang score = 71.94703045766462

121 / 2^(3/4). Fun fact? I'm not trying to win, just to add as many languages as possible.

222 //X>"!dlroW olleH"Z 
shush=0
alert("Hello World!")
sorry=`
listen
capture Hello World!`
$$$
=` >###      .O$r"!"rXr<`

What Vitsy sees

"Well, I'm a 1D language, so... for now, only the first line counts."

222 //X>"!dlroW ,olleH"Z
222                      push three twos
    //                   divide twice
      X>                 drop the result and carry on
        "!dlroW ,olleH"Z standard Hello, World! program

Thanks for the cookie, Vitsy :3

What JavaScript ES6 sees

222 //X>"!dlroW ,olleH"Z

"Let's see... You put the number 222 and then put something in a comment. Alright, sure, I'll roll with that."

shush=0

"You made a variable. Noted."

alert("Hello, World!")

"Ah, I see where you're going with this. I'll display that."

sorry=`
listen
capture Hello, World!`

"Oo! A multiline string! Now we're talking, ES6 rulez, ES5 drools!"

(EOF)

"Well, I'm done. Peace out."

What Oration sees

222 //X>"!dlroW ,olleH"Z

"This wasn't on my notes...! Best not do anything."

shush=0
alert("Hello, World!")
sorry=`

"Oh, here's some extra notes."

listen

"Listen..."

capture Hello, World!`

"...Hello, World!"

(EOF)

"thinks Nothing more! Great, I'm done here. breathes deeply"

Minkolang explanation

(Too lazy to create narrative. Might do later, the code took a while.) Irrelevant code replaced with # or omitted. Also, added comments C ... C.

222 ###>"!dlroW olleH"# 
$$$  C this separates layers C
###>### #####.O$r"!"rXr<`

Layer 1, pt 1

222 ###>"!dlroW olleH"# 
222                      C push three 2s C
   _                     C space; fall to the next layer C

Layer 2, pt 1

###>### #####.O$r"!"rXr<`
   >                       C go this way C
       _                   C fall to the next (first) layer C

Layer 1, pt 2

222 ###>"!dlroW olleH"# 
       >"!dlroW olleH"   C go right and push those characters in that order C
                       _ C fall to the next layer C

Layer 2, pt 2

###>### #####.O$r"!"rXr<`
                       <  C starts here, going left C
                      r   C reverse stack C
                     X    C pop n (n = 2), and pop top n items on stack (2, 2) C
                    r     C reverse stack C
                 "!"      C push exclamation mark (for some reason, it's chopped off C
                r         C reverse stack C
              $O          C output stack as characters C
             .            C terminate program C
  • 4
    My child is proud of your submission. Here. Have a cookie. +1 – Addison Crump Feb 2 '16 at 23:23

Score of 0.84

H

Works in H9+ and HQ9+.

1 / 2 ^ ((2 - 1) / 4) = 0.84

  • 1
    You forgot: HQ9++, HI9+, FISHQ9+, CHIQRSX9+. – user75200 Oct 27 '17 at 17:36
  • @user75200 I'm guessing those weren't as popular back in 2013 – Timtech Oct 28 '17 at 2:51
'Hello World!'

Runs in several scripting languages, including PHP, GolfScript, APL, ...

  • Also AppleScript and Javascript :) – tomsmeding Feb 21 '13 at 19:03
  • Won't Javascript include the quotes? – Joe Z. Feb 22 '13 at 4:18
  • This works in PowerShell too. – Iszi Nov 22 '13 at 20:51
  • 1
    Works in all derivatives of H9+ except for FISHQ9+ too – Tornado547 Nov 28 '17 at 20:36

CoffeeScript and CJam, 46/2^((2-1)/4)=38.68

e###
"Hello, World!"
e###alert "Hello, World!"

ES8, Japt, TeaScript, C#, C++, C, ESMin, score: ~8.8

main=_=>"Hello World!"();

ES8, TeaScript and Japt see "Hello World!".

  • It won't work in Hello due to extra characters. – user75200 Oct 26 '17 at 7:03
  • I'm pretty sure a lot of these (HQ9, Hello, and variants) don't count because they're not "real" programming languages. – KSmarts Nov 2 '17 at 14:47
  • Yes they're. They're real languages. But they may or mayn't work. And Hello++ discards non-h characters. Hello++++ discards all not part of "Hello world!" – user75200 Nov 4 '17 at 18:36
  • According to PPCG standards, they're not. – KSmarts Nov 5 '17 at 23:03
  • And there's no HQ9. – user75200 Nov 12 '17 at 10:47

TI-BASIC and Pyth, 13/2^((2-1)/4)=10.93

"Hello World!

Note: Non-competing answer, as Pyth was created after this challenge was posted

  • Also works in ESMin, Japt, Teascript, O, etc. – Mama Fun Roll Feb 3 '16 at 6:29
  • Feel free to write in any language you desire, it matters not when it was made. – user75200 Oct 29 '17 at 17:54

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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