# Program that compiles into itself

We've had lots of questions about s, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a program where the executable and output are identical. But there's one combination left.

Using a compiled language (i.e. a language which has a compiler that converts source code to executables, which are then executed), write a program which, when compiled, will produce an executable which is bit-for-bit identical to the source code.

## Clarifications

• As with all challenges that do not state otherwise, you must obey the site's proper quine rules. In particular, this excludes zero-byte programs, and programs where all the commands compile into themselves.
• At least for this challenge, it doesn't matter what the resulting executable does when run; this is purely a challenge. (If it turns out to be easy, I'm sure that someone will end up posting a "write a program where the source code, executable and output when executed are all the same" challenge, but you don't need to go to that level of complexity for this challenge.)
• Your program will, in effect, be a between the source language, and the language it compiles into. This means that you will need to pick a source language, and executable format, for which such a combination is possible.
• Multistep compiling (e.g. compiling an esoteric language into C, which then compiles into an executable) is a legal way to answer the problem. However, this is limited to the use of three compilation steps at most (in order to avoid answers that encode the desired output in the sequence of compilers used rather than in the source code).
• Don't use unusual compiler flags to loophole the question via abusing the -D option of a C compiler to hide code (or similar techniques that move code from the program into the compiler flags). You might well need to use unusual compiler flags to produce the executable in the right format, but these should be flags that would generally be useful for compiling programs, not flags specific to the program you've written (and that embed information about it); remember that on this site, the language you're using is defined by the interpreter and compiler flags that you're using.
• Likewise, it's possible that your solution will require a specific filename for the source code; in order to prevent you using this to store code, any specific filename should consist of one character, possibly followed by a standard file extension for the language you are using.
• Please state the exact compiler and version you're using to compile your program, together with the compiler flags you need to build it, because your answer may be hard to reproduce / verify for correctness otherwise; solutions to this question are likely to inherently be somewhat compiler-specific.
• This problem is mostly aimed at compilation into executable formats used by operating systems, but if you have a language that compiles into something else (e.g. bytecode), feel free to submit an answer for that setup, too, even if it won't be quite as impressive. We aren't in the business of unnecessarily restricting what languages you can use here.

## Victory condition

This is effectively a (minimize size of the source) and sizecoding (minimize size of the executable) challenge at the same time (because the two are the same): in this challenge, a program is considered to score better than another if it has a shorter length in bytes. So once you've figured out how to solve this problem at all, you can see if you can do better by fitting the program into fewer bytes.

• @petStorm: I don't like to gain reputation permanently because I think it gives the wrong incentives. Unlike with answers, there's no way to avoid gaining rep for questions, so I'm using a temporary account for question-asking and receiving bounties. The most recent version of "ais523" is still alive, though (a few older versions were deleted and recreated to reset their reputation). Apr 13 '20 at 3:24
• "a language that compiles into something else (e.g. bytecode)..." Does something else include higher-level languages (e.g. Javascript)? Apr 13 '20 at 3:52
• @Bubbler: That's still a compile, and I had that sort of setup in mind when writing the list of clarifications; it wouldn't be correct to arbitrarily disallow languages which could be able to compete. I don't think it's really in the spirit of the question, but we don't normally care about the spirit of the question here at CGCC :-D Apr 13 '20 at 3:55
• @petStorm: I linked that question while writing this one (it's already mentioned in the introduction); it is about writing a program whose executable equals its output. This is about writing a program whose source equals its executable. The two are normally different because a program's source code and output are usually not the same, and in particular a program that answers both questions at once will not be competitive on either. Apr 13 '20 at 14:45
• I tried this compiler, but didn't find a way to copy string constants, and I'm not bothered to read the code in details for now. Someone may also try aspx. Apr 13 '20 at 21:20

# CoffeeScript to JavaScript, 2 bytes

a;


Try it

• a is compiled into a;. You may try it here.
• ; is compiled into nothing. You may try it here.

Without ban "programs where all the commands compile into themselves", js2js would be a much better choice, IMO.

• Thanks for the reminder that CoffeeScript exists Apr 13 '20 at 5:31
• Is Javascript considered an executable? Apr 13 '20 at 6:54
• @mypronounismonicareinstate It is allowed according to OP's clarification. Apr 13 '20 at 6:56
• This is a transpilation, not a compilation ;) Apr 13 '20 at 13:33
• Is JS higher-level than Coffee? I would think they are at least on the same level or Coffee is higher. And I don't think there's an incredibly official definition for the difference between transpilation and compilation but as far as I can find, compilation goes closer to the metal whereas transpilation goes upwards or nowhere. Apr 13 '20 at 13:40