182
33
Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this.
Challenge
You will have to write a program that when run in two different languages, will output the string:
This program wasn't written in <language program compiled/interpreted in>, it was built for <other language the program can be run in>!
In the output, language names should have official capitalization. eg: CJam, C++
Neither program should take any input from the user.
When run in both languages, output should be to stdout or equivalent.
There should be no output to stderr in either program.
You may use comments in either language.
Two different versions of the same language count as different languages.
If this is done, the program should output the major version number, and if running on two different minor versions, should report the minor version also.
You should not use prebuilt version functions (this includes variables that have already been evaluated at runtime).
Example output:
Perl and Ruby:
Perl:
This program wasn't written in Perl, it was built for Ruby!
Ruby:
This program wasn't written in Ruby, it was built for Perl!
Python and C:
Python:
This program wasn't written in Python, it was built for C!
C:
This program wasn't written in C, it was built for Python!
Python 2 and Python 3:
Python 2:
This program wasn't written in Python 2, it was built for Python 3!
Python 3:
This program wasn't written in Python 3, it was built for Python 2!
Python 2.4 and Python 2.7:
Python 2.4:
This program wasn't written in Python 2.4, it was built for Python 2.7!
Python 2.7:
This program wasn't written in Python 2.7, it was built for Python 2.4!
This is code golf so the shortest code in bytes wins.
2"Two different versions of the same language count as different languages." So tricking like with C pre and past 99 comments is valid? easy ^^ – Zaibis – 2015-09-03T13:54:37.980
1Added it, it feels paradoxical but fits to your rules. – Zaibis – 2015-09-03T14:48:37.210
1No one's doing a Whitespace/Python polyglot? – Not that Charles – 2015-09-04T15:22:49.460
nevermind. Saw the 23 implementation – Not that Charles – 2015-09-04T15:26:03.157
Does relying on the program to be run with a certain interpreter count as input? that is, switching on
argv[0]
? – cat – 2016-10-28T12:10:06.293@cat You should not use prebuilt version functions. looking at
argv[0]
counts as that I guess – Blue – 2016-10-30T17:01:47.637What that thing is for, at all? – Brian Haak – 2018-03-05T16:19:20.347
For the fun of the person answering – Blue – 2018-03-05T16:52:29.857