Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 13 down vote accepted
print("Hello World!")

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

share|improve this answer
1  
It also works in R and Julia (and surely in many other languages). – Sven Hohenstein Feb 19 '13 at 7:20
    
works in PHP too – jdstankosky Mar 8 '13 at 14:39
    
This print() syntax is also valid in Transact-SQL. pastebin.com/is2mqRJC – manatwork Mar 9 '13 at 16:03
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
1  
works in lua too – mniip Dec 31 '13 at 1:54
'Hello World!'

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

share|improve this answer
    
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

Score of 0.84

H

Works in H9+ and HQ9+.

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

share|improve this answer

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
share|improve this answer
3  
My child is proud of your submission. Here. Have a cookie. +1 – VTCAKAVSMoACE Feb 2 at 23:23

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

e###
"Hello, World!"
e###alert "Hello, World!"
share|improve this answer

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

share|improve this answer
    
Also works in ESMin, Japt, Teascript, O, etc. – Mama Fun Roll Feb 3 at 6:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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