Suppose you have 2 languages,
B. A string
s is a semiquine in
B if it satisfies the following conditions:
sis a quine in language
sis a polyglot in
- The output of running
Bprogram is a different string
s', which is a quine in
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).
- 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.