# Write a “hello world” program that can be compiled/interpreted as two different languages simultaneously [duplicate]

Rules:

1. Your program must print "hello world" when executed

2. Your program must be interpretable or compilable into 2 or more languages

3. Your program must require no input or arguments

4. Languages with identical syntax are too easy, and will be shunned. We all know you can write echo hello world in Bash and Batch, so let's make it more interesting.

• Really close and not a dupe. (This does a subset of that challenge.) – user85052 Aug 30 '19 at 4:10
• Welcome to Programming Puzzles and Code Golf! I marked your challenge as duplicate of this challenge, which is almost identical with just a different scoring algorithm. Additionally, "identical syntax" is not an observable or objective requirement, and needs to be more clearly defined or removed to make this challenge valid by the rules of this site. In the future, I recommend using the Sandbox to get some reviews – HyperNeutrino Aug 30 '19 at 4:29
• before posting the challenge to the main site. Please ping me here or in chat if you edit this question such that it is not a duplicate and has no unobservable requirements so I can revert the duplicate mark (if I hammer more than once); alternatively, if the challenge is significantly different enough to not be a duplicate, consider rewriting it into Sandbox. – HyperNeutrino Aug 30 '19 at 4:30
• @HyperNeutrino Thanks for the feedback. I will copy this over to the sandbox and see where it goes. – BLuFeNiX Aug 30 '19 at 23:46
• I have posted a modified version of my question here: codegolf.meta.stackexchange.com/a/18038/88942 – BLuFeNiX Aug 31 '19 at 0:57

## Ruby and Foo, 17 bytes

puts"hello world"


Foo prints everything in the quotes, and Ruby uses a built-in function to output to stdout.

Python 2.7 and Bash, 45 bytes

x="hello world"
''''echo \$x;exit #'''
print x


Adding 1 byte can make it Python 3 compatible as well -- print(x)

Explanation by line:

1. Variable assignment valid in both languages
2. Python comment ''' with an extra ' will be interpreted as 0-length string concatenation in bash, followed by echo and exit. The #''' closes the python comment block, but is preceded by a bash comment, so it will be ignored
3. Python print (bash will exit before getting here, so it won't complain)