# Hello World! generator [duplicate]

Often I need a simple Hello World! program to show some basic concepts of a programming language on my travels. As I usually travel only with light luggage I can't to carry a Hello World! program for each language. So a program that generates Hello World! programs in as many languages as possible would be a great help.

Write a program or function that accepts a language as an input and outputs or returns the source code for program or function that accepts no input and outputs (not returns) Hello World!.

# Input

The input defines in which language the Hello World! program should be generated. The input can be a number, a string, or whatever is the easiest for you. The input must only be used to select the language. You are not allowed to use the input as part of the output.

# Output

The output can the return value, or be written to a file or STDOUT (or equivalent). It must full program of function in the language defined by the input. The resulting program/function must write Hello World! to STDOUT (or equivalent for the language). The output doesn't need to be exactly "Hello World!". Everything reasonably recognizable as Hello World! is acceptable. Eg. "HeLLo w0rlD1" would be an acceptable output. Also the resulting Hello World! string can be different for different languages. See bonus points section for more details.

# Scoring

The program should work for as many languages as possible, and be as short as possible. Therefore the score is calculated by number of bytes / (number of supported languages - 1). Eg. an answer with 15 bytes and 3 supported languages would have a score of 7.5.

As usual with code-golf challenges lower scores are better.

# Bonus points

• You can subtract 10 percent from your score if the resulting Hello World! output for all supported languages is the same.
• You can subtract and additional 10 percent from your score if the output for all supported languages is exactly Hello World!

## marked as duplicate by Rod, TuxCrafting, PurkkaKoodari, devRicher, georgeJan 18 '17 at 12:19

• @Rod: I don't think it is a duplicate. The other question asks for polyglot, while my question asks for program, that output an other program. – raznagul Jan 18 '17 at 11:37
• why a bonus for polyglots? – Destructible Lemon Jan 18 '17 at 11:49
• This challenge should be code-challenge, not code-golf, since the scoring is custom. Bonuses are generally discouraged. Also, the criteria of "Everything reasonably recognizable as Hello World!" is quite vague; challenges should have definitive criteria for valid submissions. – PurkkaKoodari Jan 18 '17 at 11:55
• Duplicate asks for a polyglot, your questions asks for a program that outputs that polyglot. I don't think putting a println("..") infront of any of the answers of the other post is any interesting (though, a valid solution). @raznagul – devRicher Jan 18 '17 at 11:57

# PHP, 13 bytes, 9 languages, Score: 1.625*0.9^2 = 1.31625

Hello, World!


Explanation:

Hello, World! outputs Hello, World!. This can be used as input, and produce the same output in at least 9 languages.

Here's a list of languages this works for:

This would give a fairly low score too, in Octave:

disp('print("Hello, World!")')


It prints print("Hello, World!") and should work in Perl, R, Ruby, Julia, Python 2, Python 3, Qbasic, Zsh/ksh, Cheddar among others.

Thanks to Dada for noticing I had capital instead of lower case P.

• I think you can use the 0-byte program in Stuck to generate the program Hello, World! for all 10 languages ;-) – ETHproductions Jan 18 '17 at 21:37
• Haha :) Can't get a much lower score than that :) – Stewie Griffin Jan 18 '17 at 21:43