Duplicate? I knew somebody must've done this before.

Programming a programming language in itself is something that has interested me since I knew what a programming language was. So I thought I'd create a Code Golf challenge for you.


Create an interpreter for a given programming language, programmed entirely in itself. The interpreter should be able to run any valid program in that language, including itself.


The program can take it's input as a file passed as a parameter (e.g. python myfile.py) or as lines from stdin (cat myfile.py | python).


Whatever an interpreter would normally output, on the correct streams (stdout, stderr etc.)


  • The code needs to be written in an interpretable language, and serve as an interpreter for its own language.
  • It can't use an eval() function to interpret code.
  • It must run any valid program in that language. If the language allows external modules (or includes), it must be able to read those modules.
  • This task is code golf. The submission with the least characters that is correct wins. In case of a tie, the solution that was submitted first wins.

Loophole remover:

  • Yes, if you can interpret Java, Bytecode or HQ9++ in themselves, go ahead!
  • In JavaScript / ES, using HTML tags such as <script> is not allowed.
  • \$\begingroup\$ Our default scoring method is bytes, not characters, because scoring in character will likely get you answers like this. You are free to choose characters over bytes if you really want to, but I thought I'd let you know about the consequences. ;) \$\endgroup\$ Commented Aug 29, 2015 at 14:19
  • 1
    \$\begingroup\$ Seems like this might be a better popularity contest than code golf- there are many extremely degenerate non-general esolangs which have simple solutions to this problem and more interesting languages have no chance of competing. \$\endgroup\$
    – JohnE
    Commented Aug 29, 2015 at 14:34
  • 2
    \$\begingroup\$ Oh well, this contest is over. Loopholes should be closed not opened. \$\endgroup\$
    – Dennis
    Commented Aug 29, 2015 at 14:40
  • \$\begingroup\$ @MartinBüttner I meant bytes! But there's no point editing now, even though the duplicate refers to an old and inactive challenge. \$\endgroup\$
    – wizzwizz4
    Commented Aug 30, 2015 at 7:30
  • \$\begingroup\$ is tcl interp create valid? \$\endgroup\$
    – sergiol
    Commented Jul 6, 2017 at 20:46

2 Answers 2


Nothing, 0 chars

The source code is an empty file. It does nothing, like any Nothing program, therefore it is the correct execution of every such program.

  • 2
    \$\begingroup\$ Nothing doesn't satisfy our definition of programming language. \$\endgroup\$
    – Dennis
    Commented Aug 29, 2015 at 14:36
  • \$\begingroup\$ @Dennis the OP seems to explicitly accept such languages (e.g. HQ9++) \$\endgroup\$ Commented Aug 29, 2015 at 14:37
  • 11
    \$\begingroup\$ In that case, nothing beats Nothing. \$\endgroup\$
    – Dennis
    Commented Aug 29, 2015 at 14:38
  • \$\begingroup\$ @aditsu That was a joke, as there is no way to create an interpreter of HQ9++ in itself. But this is accepted. \$\endgroup\$
    – wizzwizz4
    Commented Aug 29, 2015 at 16:32

JavaScript ES6, 44 bytes/chars


Defines a function, taking the code string as a parameter.

How it works:

This function simply takes the code, wraps it in <script> tags, and writes it into the page. It doesn't use the eval function at all - the browser simply runs the code when the new <script> element is inserted into the page.

Tested in the FireFox console on the about:blank page as follows:


Yes, this is probably a loophole and as such I don't really expect to win. (It's impossible to beat the Nothing answer, anyway...)

If anything, hopefully it shows how it is possible to evaluate code in javascript without the use of the eval function.

  • 1
    \$\begingroup\$ This is a loophole. I'll add it to the Loophole remover. \$\endgroup\$
    – wizzwizz4
    Commented Aug 29, 2015 at 16:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.