8
1
Your task is to make a program which interprets the language it is run in, but also works in many languages.
Let's say you make a Brainfuck-Underload self-interpreglot, as it will be called. Run in Brainfuck, this program should be a Brainfuck interpreter; run in Underload, it should be a Underload interpreter.
Your program should work like the hypothetical given above: given a list of languages L1, L2, L3, L4... up to Ln, it should be an L1 interpreter in L1, an L2 interpreter in L2, an L3 interpreter in L3, up to being an Ln interpreter in Ln.
Your program can handle errors in any way. However, it must never output to STDERR (or closest equivalent) if the input given for interpretation has no errors.
It must output to STDOUT (or closest equivalent) and take input from STDIN (or again, closest equivalent).
You can choose any interpretation of a given language, e.g. if your polyglot works in Brainfuck, it can interpret Brainfuck with finite or unbounded tape. You must specify what interpretations you choose to use for each language.
Programs must have at least 2 characters for this challenge to prevent empty programs from competing.
Functions such as exec and eval are allowed.
Only a Turing-complete subset of a language has to be interpreted.
Different languages have to be interpreted, not different language versions.
Your score is C/(L^3), where C is code length, computed in bytes with UTF-8 encoding, and L is the amount of languages. The lowest score wins: if two winning answers have the same score the one posted earlier wins.
Have fun.
1Are functions such as
exec
andeval
allowed? Does the entire language spec have to be interpreted or just a turing complete subset? – FlipTack – 2019-12-28T17:27:27.010Yes and yes. Mostly for non-esoteric languages. – Andrew – 2019-12-28T18:47:27.493
4@FlipTack's second question was an "either/or" not a "yes/no"! :D – Shaggy – 2019-12-28T19:35:09.973
"In languages without any method of input (e.g. ///) programs may get input through an insertion into the source code" does this make the empty program a valid submission in some languages? https://codegolf.meta.stackexchange.com/a/10553/89930
– 79037662 – 2019-12-29T18:47:13.603