Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
3 years, 9 months ago
This question already has answers here:
3 years ago.
Your program must print "hello world" when executed
Your program must be interpretable or compilable into 2 or more languages
Your program must require no input or arguments
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.
Aug 30, 2019 at 4:03
Ruby and Foo, 17 bytes
Foo prints everything in the quotes, and Ruby uses a built-in function to output to stdout.
Aug 30, 2019 at 4:21
Python 2.7 and Bash, 45 bytes
''''echo $x;exit #'''
Adding 1 byte can make it Python 3 compatible as well --
Explanation by line:
Variable assignment valid in both languages
''' 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
Python print (bash will exit before getting here, so it won't complain)
Aug 30, 2019 at 4:07
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only