-3
\$\begingroup\$

This question already has an answer here:

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.

I'll add my example as an answer.

\$\endgroup\$

marked as duplicate by Embodiment of Ignorance, HyperNeutrino code-golf Aug 30 at 4:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    \$\begingroup\$ Really close and not a dupe. (This does a subset of that challenge.) \$\endgroup\$ – A _ Aug 30 at 4:10
  • 1
    \$\begingroup\$ 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 \$\endgroup\$ – HyperNeutrino Aug 30 at 4:29
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – HyperNeutrino Aug 30 at 4:30
  • \$\begingroup\$ @HyperNeutrino Thanks for the feedback. I will copy this over to the sandbox and see where it goes. \$\endgroup\$ – BLuFeNiX Aug 30 at 23:46
  • \$\begingroup\$ I have posted a modified version of my question here: codegolf.meta.stackexchange.com/a/18038/88942 \$\endgroup\$ – BLuFeNiX Aug 31 at 0:57
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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)
\$\endgroup\$

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