Introduction
A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_)
. Running it outputs _='_=%r;print(end=_%%_)';print(end=_%_)
, therefore it is a valid quine. An error quine is similar to a regular quine, however it must output to STDERR. In Python (for example), this could be achieved by replacing both instances of print
in the above code with exit
. A polyglot is a program that is valid in multiple languages.
Challenge
Write two full programs in two programming languages of your choice. The first one should be a quine, and the second an error quine. When concatenated (in any order, you can pick), it should form a Hello, World! program in a third programming language.
Example
Say you have a language A
* in which a valid quine is 123
, and another language B
* where abc
is an error quine. Then, 123abc
(or abc123
) should be a valid Hello, World! program in language C
*. If this is the case, your answer should look similar to the following:
A, B, C, score 3
A, 3 bytes - Quine
123
B, 3 bytes - Error quine
abc
C, 6 bytes - Hello, World!
123abc
Explanation (optional)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sem mi, dignissim a odio vehicula, tincidunt ultrices tellus. Etiam luctus scelerisque urna, ac sodales nisl rhoncus at. Cras ac accumsan velit. Integer eget mi nec diam suscipit pretium a ac massa. Praesent at enim nec nisl molestie aliquet nec sed lorem. Duis iaculis condimentum dui at ullamcorper. Fusce molestie iaculis dolor. Cras vel metus dictum, aliquam quam sit amet, gravida tortor. Praesent maximus quam porttitor, vulputate magna eu, rhoncus nunc. Sed accumsan dui ut sapien semper finibus. Nulla eget dictum justo.
Scoring
Your score is the arithmetic mean of the lengths of the two quines (i.e. half the length of the Hello, World! program).
Rules
- All three programming languages used must be different.
- The Hello, World! program should output exactly
Hello, World!
. A trailing newline is allowed. - Standard loopholes are forbidden, except for storing information in the file name; if done so in either one of the quines, it will add <length of file name> bytes to the length of both that program and the Hello, World! program, therefore adding half of <length of file name> to your score. If done in the Hello, World! program, it adds the same amount to your score and bytecount for it, but not for either one of your quines. Note that, if you're not doing this, the file name will be assumed to be
.code.tio
even if not running on TIO. - The regular quine must output to STDOUT and the error quine must output to STDERR. If STDOUT and STDERR do not exist in your language(s), use the closest equivalent(s). However, the Hello, World! program may output using any of the standard I/O methods. Also, the quine and Hello, World! programs may output anything to STDERR, and the error quine may output anything to STDOUT.
- If possible, please link to an online interpreter (e.g. TIO) to run your program on.
- Please explain your answer. This is not necessary, but it makes it easier for others to understand.
- Neither one of the quines may output a trailing newline unless that newline also occurs in the source code.
- Languages newer than the question are allowed. This means you could create your own language where
a
is a quine,b
is an error quine, andab
is Hello, World!, and post an answer in that language with score 1, but expect many downvotes. - Non-programming languages are allowed. A non-programming language is a language which doesn't satisfy both of these conditions:
- Able to take two integers as input and print their sum
- Able to take one integer as input and print a truthy value if it is prime, and a falsy value if it is not
- Different versions of the same language may be used. For example, your quine could be in Python 2 and your Hello, World! program in Python 3.
- This is code-golf, so shortest code in bytes wins!
*Fun fact: these are all actual languages!
A
in Charcoal or PHP which outputA
isn't allowed), but the error quines is basically finding a program and error message that match exactly. I've deleted both my comments, since they both don't make much sense knowing this now. \$\endgroup\$