10
Suppose you have 2 languages, A
and B
. A string s
is a semiquine in A
and B
if it satisfies the following conditions:
s
is a quine in languageA
.s
is a polyglot inA
andB
.- The output of running
s
as aB
program is a different strings'
, which is a quine inB
.
The goal of this challenge is to write a semiquine in two distinct languages. This is code-golf, so shortest code wins, with earliest answer used as a tiebreaker.
Rules for Quines
Only true quines are accepted. That is, you need to print the entire source code verbatim to STDOUT, without:
- reading your source code, directly or indirectly.
- relying on a REPL environment which just simply evaluates and prints every expression you feed it.
- relying on language features which just print out the source in certain cases.
- using error messages or STDERR to write all or part of the quine. (You may write things to STDERR or produce warnings/non-fatal errors as long as STDOUT is a valid quine and the error messages are not part of it.)
Furthermore, your source code must not consist purely of literals (whether they be string literals, numeric literals, etc.) and/or NOPs. For example, `12
is a polyglot in Jelly and Pyth, but in Jelly it is a NOP and a numeric literal, so it is not valid.
Any non-suppressible output (such as copyright notices, startup/shutdown messages, or a trailing line feed) may be ignored in the output for the sake of the validity of the quine.
Rules for Polyglots
The two languages used must be distinctly different. In particular:
- They must not be different versions of the same language (e.g. Python 2 vs. Python 3).
- They must not be different dialects of the same language (e.g. Pascal vs. Delphi).
- One language may not be a subset of the other one (e.g. C vs. C++1).
- One language may not be a trivial derivative of the other (e.g. Matlab vs. Octave2, brainfuck vs boolfuck vs TinyBF vs ShadyAsFuck vs all the other trivial brainfuck derivatives).
Miscellaneous Rules
- You may not accept input from STDIN (or any other source). If your chosen language must take input, then either the input must be empty (empty string, piped from
/dev/null
, etc.), or the output of the program must not depend on the input. - For this challenge, you must write a complete program. Requiring additional code to run the solution is not allowed (such as assigning and calling a lambda function defined in the solution).
1: Yes I know that C is not really a subset of C++. It's close enough to be considered one for the purpose of polyglots, though, so I'm counting it for this challenge.
2: Like point 1 above, though Octave is technically not 100% compatible with Matlab, it was designed to be compatible, and is close enough that allowing a Matlab/Octave polyglot would trivialize the challenge.
Are ESMin's copy blocks allowed? – lirtosiast – 2016-02-08T21:51:53.460
@ThomasKwa I'm not familiar with ESMin, so could you give me a quick rundown? – Mego – 2016-02-08T21:53:56.053
There's a command to start a copy block, which gets the source code of everything past it. I think other JS golfing languages might have one too. – lirtosiast – 2016-02-08T21:55:07.573
@ThomasKwa That would not be allowed under the first rule in the quine rules (no reading the source code, directly or indirectly). – Mego – 2016-02-08T21:56:10.837
Can we abuse interpreter quirks which aid in making a quine? – Downgoat – 2016-02-08T23:03:41.237
1@Downgoat So long as it doesn't break any other rules, absolutely. Abusing quirks is kind of the goal of this site :) – Mego – 2016-02-08T23:04:53.673
@ThomasKwa ESMin can't do this one anyway :P – Mama Fun Roll – 2016-02-09T04:16:04.533