Inspired by a polyglot on the Stack Overflow 404 page:

# Goal

Your goal is simple, to create a polyglot that outputs the number 404, and then terminate, in as many languages as possible.

# Restrictions

Here's the twist, there's a restriction to make it harder:

You have to write N programs and pick N languages in a particular order. the ith program needs to print 404 in the first i languages, but not in any language after the ith. This is to prevent very simple solutions from destroying competition

# Scoring:

• The first criterion for determining a winner is the number of languages the main program runs in.
• The second criterion is byte count, where the programs with more languages have more importance for this criterion.
• The third and final criterion is time of submission

# Clarifications:

The source codes of the programs do not need to have any relation. They're run as separate programs. Any of the programs can output trailing and/or leading whitespace. THE PROGRAMS DO NOT HAVE TO BE SUBSEQUENCES OF EACH OTHER!

Thanks to @MartinEnder for a better explanation!

• You think anyone is going to get to 404 languages? – Jo King Jan 21 '18 at 3:23
• @JoKing That would be greater than the current "add a language to a polyglot" challenges, so probably not... – Esolanging Fruit Jan 21 '18 at 5:35
• "The source code of the subprograms does not need to have any relation" - but they must each be a subsequence of the full (byte-count) program that runs in all N languages, right? If not could you please define "sub-program"? – Jonathan Allan Jan 21 '18 at 12:24
• +1 only because now I know what that crap was. I just ignored it before. Oh no, this cannot be unseen now! – sergiol Jan 22 '18 at 0:22
• @Zacharý why's that? They print 404. If trailing whitespace is OK I think that should be OK. – MD XF Jan 26 '18 at 4:03

# 54 Languages, 1331 bytes

This is getting very long, so at @MDXF's suggestion, I'm moving the subprograms and comments to a gist. The program here is only the final program. Thanks to MDXF again for providing the TIO test driver.

# 54. Whirl

##\$"404"#N#S# , ,,#$#?@\404!?@GJlICJlGCC*G^+0%=%=+0%x&fqpqqqiipsoddddoiipsohphhhhyhhhh? 	  ?nnn4$4#!000110000011110000100000100000110000011001100000111100001110011000111000110000 #?\++++:----:++++:H@((((4O0O4O@((((()()()){}){x}x){}x()){}){}()){}){})<[-]>[-]-[<+>-----]<+x%"404"?.⌂----.++++.>11 #i(N/"404"ooo@ENTHOEONHSSEONTHOEONSETssipceaiiiiiscejiiiijeeeejapmzaeeaeueewzaeeeaeewzaeeaeueewqs??|?)999|997+|++++!999777+++++!999997+++++! print(404) __DATA__=1 # \"404"*CC'[-][ .-$_"404"&]
"""pp
I want 404 of this
How much is it
#  -52, Z, -1                          #
#  -48, Y, -1                          #
#  -52, X, -1                          #
[-][
x::=~404
::=
x
]<<<
> 404
>> Output 1
red up two blue up red up one blue up red up two blue up
baaaaa bleeeeeeeeet bleeeeeeeeet baaaaa bleeeeeeeeet
a now 404 dollar off!
a has been selling out worldwide!
2 LEFT
2 LEFT
2 UP
2 LEFT
2 TEACH
1 LEFT
1 RIGHT
1 BOND
1 BOND
1 TEACH
2 YELL
1 FIGHT
2 YELL
1 TEACH
2 YELL
set ! 52
set ! 48
set ! 52
+------+
|$0011\| |/000\0| |0/0@11| |00 10| |0\10/0| |\1100/| +------+$'main'
\-444o000o444omm^

[-][$++++++++++++++++++++++++++++++++++++++++++++++++++++.----.++++.# <<<<<<>>>>.>.>. ] ss""" #7777777777777777777777777777724091557093543643💬404💬➡77▲▲▲²²▲²²¡▼▼▼▼¡▲▲▲▲¡⠎⡆⡎⡆⢐⠣⠃s&&&&~-<<:<<:<<<:<:>>>>>>>>:^||||G<>  Try it online! Whirl is described as a Turning Tarpit [sic], which uses only two instructions, 1 and 0. 1 rotates the current wheel of instructions (either the math wheel or the operations wheel), 0 swaps the rotation of the wheel, and two 0s executes the instruction and switches wheels. The relevant instructions are on the first line: 000110000011110000100000100000110000011001100000111100001110011000111000110000 000110000 Switch to math wheel and execute math.not (math.val = 1) 011110000 Execute math.store, (memval = math.val = 1) 10000 Execute math.add, (math.val = math.val+memval = 1+1 = 2) 010000 Execute math.store (memval = math.val = 2) 0110000 Execute math.multiply, (math.val = math.val*memval = 2*2 = 4) 01100 Execute math.store (memval=math.val) and switch to the ops ring 110000 Execute ops.one (ops.val = 1) 011110000 Executes ops.intio, printing memval (4) 11100 Add one to memory pointer (memval=0) 1100 Execute maths.nop to switch back to ops ring 011100 Execute ops.intio, printing memval (0) 01100 Execute maths.store, (memval=maths.val=4) 00 Execute maths.intio, printing memval (4)  The leading 01s cancel each other out, and the trailing 01s cause a floating point exception. Edit: fixed a bunch of broken stuff (Commands to be careful about in the future: UDLR%"[.]o473psjw) If any programs work for future languages or don't work for current or previous languages, please comment. • @Zacharý RE: my comment under the OP - at some stages this has ...print(0 or 404) but it is not a subsequence of the 97 byte N-program. – Jonathan Allan Jan 21 '18 at 12:26 • @JonathanAllan yeah, I was a little concerned about that too. Sub-program does imply they are related to the final program, but I’m going off the question specs here – Jo King Jan 21 '18 at 12:57 • No, you're not going off question specs. "Submission" meant the entire post, not the code. – Adalynn Jan 21 '18 at 15:16 • @Mego Done. Was a little harder than suggested, but it all worked out – Jo King Jan 23 '18 at 21:26 • I think you should be able to add TinCan. @MDXF too. I can't because Jelly and M won't allow any line to begin with #. I'm really regretting including those two languages haha. – dylnan Jan 24 '18 at 1:31 # 53 languages, 2789 bytes Bash, Foo, Implicit, Charcoal, Emoji, ><>, rk, Brain-Flak, C, Set, Cood, Arcyou, TRANSCRIPT, S.I.L.O.S, Commercial, C++, Braille, Deadfish~, Memescript 1.0, ETA, Python 1, Python 3, PARI/GP, Lily, Fission, Decimal, Cubically, Bitwise, TinCan, Whispers, Thue, Emotinomicon, what??!, Ook!, evil, Lennyfuck, Blablafuck, Stones, TacO, COW, Symbolic Brainfuck, Underload, Rail, Reticular, Gaot++, PATH, axo, Monkeys, Nhohnhehr, xEec, VTFF, K-on Fuck, Churro, and Forked. Try everything online in the test driver! Join us in the chatroom for this challenge! This post got way too large so here's a gist containing my progress. Current final program: # Forked #undef l" 404"p;((((\)0)0)0)0;(😭4😲⏬😭0😲⏬😭4😲⏬«404»[:5*11-1/1]%&)(404)S^/*NNNNTNNEONHSSEONTHOEONiisoddddoiisohOok! Ook! Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. ????!?!!?!??!!!???????????????!?!!!?!????!??????????????!!??!??!??!????!⎚404»💬404💬➡ to for the and of to to to to to is the and a to to to to a and and and and a ;n4n0n4 #11404D301 \4%0%p%& """"echo 404|| rk:start int x = 404 print: x rk:end R"404"* exit; #; OUT &52 &1 OUT &48 &1 OUT &52 &1 */ #include<stdio.h> main(){char aA[]={37,100,0};printf(aA,404);}/*<<<<<mzaeeeaeeaaaawuuuuwaaaa what the frick frack backtrack snick snack tic tac snick snack patty wack diddily dack tic tac diddily dack frick frack quarterback frick frack x::=~404 ::= x # set ! 52 #;⠎⡆⡎⡆⢐⠣⠃▲▲▲²²▲²²¡▼▼▼▼¡▲▲▲▲¡(♥ ͜ʖ♥)( ͡°((∩ ͡° ͜ʖ ͡°)⊃━☆ﾟ.*( ͡° ͜ʖ ͡°)ᕦ( ͡°ヮ ͡°)ᕥ(♥ ͜ʖ♥)(♥ ͜ʖ♥)(♥ ͜ʖ♥)(♥ ͜ʖ♥)(♥ ͜ʖ♥)) ͡°)(∩ ͡° ͜ʖ ͡°)⊃━☆ﾟ.*( ͡° ͜ʖ ͡°)(> ͜ʖ<)(♥ ͜ʖ♥)(♥ ͜ʖ♥)(♥ ͜ʖ♥)(♥ ͜ʖ♥)(> ͜ʖ<)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)( ͡° ͜ʖ ͡°)(> ͜ʖ<)うんうんうんうんたんたんたんたんうんうんうんたんうんたんうんうんうんうんうんたんたんうんたんたんうんたんたんうんたんたんうんたんたんたんたんたんうんうんたんうんたんうんたんうんうんうんたんたんうんたんたんうんたんたんうんたんたんたんうんうんうんたんうんうんたんうんうんたんうんうんたんうんたんうんうん {o}===}{======={o}{o}}{======={o}{o}===}{======={o} > 404 >> Output 1 I want 404 of this. How much is it? Ju is here. >Ju, 404 >X Ju b = 404 printInt b ; set ! 48 MoOMoOMoO set ! 52 MoOOOMmoO +--------+ |$00110\ |
|/00001/ |
|\11000\ |
|/11000/ |
|\0100 \ |
|        | baaaaa bleeeeeeeeet
|  404p@ |
|        |
+--------+
$'main': OOMmOoOOM ; \-444o000o444o-{<$\$^- >}+{-----v}+.----.++++.#
#  bleeeeeeeeet baaaaa ^        < bleeeeeeeeet >
2 LEFT
2 LEFT
2 UP
2 LEFT
2 TEACH
1 LEFT
1 RIGHT
1 BOND
1 BOND
1 TEACH
2 YELL
1 FIGHT
2 YELL
1 TEACH
2 YELL
red up two blue up red up one blue up red up two blue up ;
o now 404 dollars off!
o has been selling out worldwide!
#  -52, Z, -1                          #
#  -48, Y, -1                          #
#  -52, X, -1                          #
⡆⡎⡆⢐⠣⠃((((p 404)((()(((()()()){}){}){}){}){}){}){}) h#4 o# h#0 o# h#4 o# """
print(404)#"*/


Try it online!

My new (-ly implemented) esolang!

• what the frick frack paddy wack (give the dog a bone) is that language? (congratz on passing me) – Jo King Jan 23 '18 at 5:33
• @JoKing honestly I have no idea what was going through my head when I made that language.... also thanks for the help with Braille and Deadfish~, I hope you don't mind that I used your code? – MD XF Jan 23 '18 at 5:57
• no worries mate – Jo King Jan 23 '18 at 6:02
• MDXF v. Dylnan, I see. – Adalynn Jan 24 '18 at 3:10
• @Zacharý MD XF v Dylnan v Jo King; every time I pull ahead, I fall asleep and then have to go to school and by the time I get back on they both are ahead again, building off my languages and each others'... sigh – MD XF Jan 24 '18 at 3:11

# 34 Languages, 387 characters

Jelly, M, Pyon, Proton, Python 3, Python 2, Python 1, Perl 6, Perl 5, Ruby, bc, Pari/GP, brainfuck, Emoji, Emotin🌗micon, Charcoal, Braingolf, Whitespace, Deadfish~, Deadfish, Self-modifying Brainfuck, Symbolic Brainfuck, Numberwang, Cardinal, Actually, Fission, Prelude, Brain-Flak (BrainHack), Alphuck, Deadfish x, TacO, Braille, rk, evil

This answer is getting very long so here is the full answer. From now on only the last program will be kept here.

If anyone finds that one of the programs is broken for one language or one program works for a language it shouldn't, let me know.

print(404)
+1#<[-]>--[<+>-----]"404".⌂<+.----.++++.💬404💬➡😒😀😒😨😨😨⎚404»___pppissiiiisiiiio▲▲▲²²▲²²¡▼▼▼▼¡▲▲▲▲¡sipceaiiiiiscejiiiijeeeejaxxcxxxcxxxKddddKcxxxx7777777724091557093543643%R"404";77999++++++++!++++++++6+1+!++++++5++++!> @p404 sp7 rk:start print: "404"77szaeeaeueewzaeeeaeewzaeeaeueew

+1#((a(()a((()(((()()())a{})a{})a{})a{})a{})a{})a{})

+1#ṛ“Nạç»⠎⡆⡎⡆⢐⠣⠃


Try it online!

• Wow, congrats, you've just blown everyone else out of the water. – MD XF Jan 22 '18 at 1:56
• @MDXF Thanks! I'm planning on doing more I just have to stop for now. – dylnan Jan 22 '18 at 2:18
• If only the Julia versions were different enough I could've beaten you by 10 bytes with this sigh – MD XF Jan 22 '18 at 5:32
• @MDXF Someone did post a double Julia answer to the Trick or Treat polyglot question exploiting some bug but it got deleted and I don't remember what it was – dylnan Jan 22 '18 at 6:51
• @dynlan well I can see deleted posts so I'll go check it out, thanks! – MD XF Jan 22 '18 at 20:51

# 11 languages, 10 bytes

### Pyon

print(404


### Pyon, Python 2

print 808//2


### Pyon, Python 2, Python 1

print None or 404


### Pyon, Python 2, Python 1, Python 3

die=0
print(die or 404);


### Pyon, Python 2, Python 1, Python 3, Lua

print(None or 404)


### Pyon, Python 2, Python 1, Python 3, Lua, Perl 5

print(404 or 0)


### Pyon, Python 2, Python 1, Python 3, Lua, Perl 5, Ruby

;print("40"+"4")


### Pyon, Python 2, Python 1, Python 3, Lua, Perl 5, Ruby, Swift 4

print("40"+"4")


### Pyon, Python 2, Python 1, Python 3, Lua, Perl 5, Ruby, Swift 4, Perl 6

print(404**1)


### Pyon, Python 2, Python 1, Python 3, Lua, Perl 5, Ruby, Swift 4, Perl 6, Julia

print(404);


### Pyon, Python 2, Python 1, Python 3, Lua, Perl 5, Ruby, Swift 4, Perl 6, Julia, Lily

print(404)

• Nice. Very clean and simple answer and it still has plenty of languages – dylnan Jan 22 '18 at 6:49

# 4 Languages: CJam, Python, Underload, ><>

The following works in CJam but not Python, Underload, or ><>:

404

• To CJam: This pushes the literal 404 to the stack. The program ends, and the 404 is output.
• To Python: This program consists of a single expression 404. The expression is evaluated, and the program terminates.
• To Underload: 4 and 0 are invalid commands, so the TIO interpreter simply ignores them, and the program terminates.
• To ><>: 404 pushes 4, 0 and 4 to the stack. The IP wraps around to the beginning, and the program repeats infinitely.

The following works in CJam or Underload (though it errors) but not Python or ><>:

N(404)S;(\

• To CJam: N pushes a string (array of characters) containing a newline to the stack. ( pops the single character (a newline) out of the string. 404 pushes 404 to the stack, and then ) increments it to give 405. S; pushes a spaces and then immediately deletes it. ( decrements again to get 404, and then \ swaps the newline and the 404. 404\n is output (the empty array is displayed as nothing).
• To Underload: N is ignored. (404) pushes the string 404 to the stack. S outputs it. ; is ignored. ( causes the interpreter to try to look for a closing ), but as none is found, the program segfaults.
• To Python: This is invalid syntax (the expression N(404) is followed by an identifier S, which is malformed), so the program errors.
• To ><>: N is an invalid instruction, so the program errors.

The following works in CJam (though it errors), Underload, or Python, but not ><>:

[]
Le=404
+Le#(404)S
(print(404))

• To CJam: [] pushes the empty array to the stack, and L pushes the empty array to the stack. e= counts the number of occurrences of [] in [], giving 0. 404 pushes 404 to the stack. + adds the two numbers together, giving 404. L pushes the empty array to the stack again, and e# creates a comment that lasts until the end of the line. ( tries to pop an element out of an array, but since the top stack element is the empty array [], the program errors. 404 is still output.
• To Python: [] is a statement consisting of a no-op instruction. Le=404 defines a variable Le to be equal to 404. +Le takes the unary plus of the variable Le (a rather useless operation) and the result is discarded. #(404)S is a line comment. (print(404)) prints 404.
• To Underload: The only relevant part is (404)S, which pushes 404 to the stack and outputs it. (print(404)) pushes print(404) to the stack, but nothing is done with it and the program terminates.
• To ><>: [ tries to pop a number off the top stack on the metastack, and then pop that many elements off that stack and make them into a new stack which is then pushed to the metastack. There is no number on the stack, so the program errors.

The following works in CJam (though it errors), Python, Underload, and ><>:

"404nnn;\
"
Le=404
+Le#(404)S
(print(404))

• To CJam: Most of what I said last time applies here. Instead of being [], we now have a string literal, but the content is still unimportant.
• To Python: Most of what I said last time applies here. Instead of being [], the unused first expression is now a string literal, but the content is still unimportant.
• To Underload: Everything I said last time applies here. All of the commands are still ignored.
• To ><>: The " begins string mode, and the IP wraps around the first row pushing every character code it sees to the stack (this is unimportant). The IP wraps around and hits " again, which exits string mode. 404 pushes the digits 404 to the stack, and then nnn outputs each of them (technically, this happens in reverse order, but since 404 is a palindrome this doesn't matter). ; ends the program.

# 6 Languages Brain-Hack, Brain-Flak, Brain-Fuck, Foo, Javascript, Alphuck

More to come!

## Brain-Hack

#(((()((()(((()()()){}){}){}){}){}){}){})


Prints 404 in Brain-Hack

## Brain-Hack, Brain-Flak

(((()((()(((()()()){}){}){}){}){}){}){})


## Brain-Hack, Brain-Flak, Brain-Fuck

(((()((()(((()()()){}){}){}){}){}){}){})#-[<+>-----]<+.----.++++.>-.++++.


Uses comments in Brain-Flak to print it

## Brain-Hack, Brain-Flak, Brain-Fuck, Foo

"404"
(((()((()(((()()()){}){}){}){}){}){}){})#-[<+>-----]<+.----.++++.>-.++++.


## Brain-Hack, Brain-Flak, Brain-Fuck, Foo, Javascript

console.log("404")
//(((()((()(((()()()){}){}){}){}){}){}){})#-[<+>-----]<+.----.++++.>-.++++.


## Brain-Hack, Brain-Flak, Brain-Fuck, Foo, Javascript, Alphuck

console.log("404")
//(((()((()(((()()()){}){}){}){}){}){}){})#-[<+>-----]<+.----.++++.>-.++++.iaipiiiiiaecsaejiiiijeeeej

• Did i mention i use esolangs? – Christopher Jan 22 '18 at 19:42
• Umm, your original Brainfuck code prints 4... – MD XF Jan 29 '18 at 18:32
• @MDXF fixed that lol – Christopher Jan 29 '18 at 18:41
• Now the brainfuck has alot of extra code. – MD XF Feb 1 '18 at 3:03

# 5 languages (87 bytes)

### Pyon

print(404


Try it online!

### Python 2

print(404)


Try it online!

### Brain-Flak (BrainHack)

print(404)#(((()((()(((()()()){}){}){}){}){}){}){})


Try it online!

### brainfuck

Taken from Jo King's answer because I wasn't able to come up with a brainfuck code that had the brackets balanced (Brain-flak restriction).

print(404)#(((()((()(((()()()){}){}){}){}){}){}){})-[<+>-----]<+.----.++++.>


Try it online!

### 05AB1E

Note that this also works with Ohm.

#404q
print(404)#(((()((()(((()()()){}){}){}){}){}){}){})-[<+>-----]<+.----.++++.>


Try it online!

Thanks to Jo King for -6 bytes.

• The x%x and [-] aren’t necessary – Jo King Jan 22 '18 at 20:34
• @JoKing Oh whoops I forgot to remove them after adapting your brainfuck code >_<. Edited. Thanks – Mr. Xcoder Jan 22 '18 at 20:34
• You can easily add Python 1: gist.github.com/anonymous/77ed24162c35aae0a10e4e1cada8547a – MD XF Jan 26 '18 at 4:54
• @MDXF That seems invalid to me. 1) The Python 1 version doesn’t work in Pyon 2) The Python 1 version also works in Python 2, which is forbidden. – Mr. Xcoder Jan 26 '18 at 5:26
• @Mr.Xcoder Oh, I forgot that the non-parenthesis syntax works in Python 2. – MD XF Jan 26 '18 at 5:47

# Program 1: Python 3

print('404')


# Program 2: Python 3 and Batch

print('404')#|echo 404


After the the hash comments the rest of the code in python, and the | is a statement in bash to do this if the other command fails.

# 2 Languages, 53 bytes: C and Python

Let's start things off with something simple.

## Program 1: C

int main(){printf("404");}


## Program 2: C and Python

#define print(X)int main(){printf("404");}
print(404)


This is just an example, and will probably be beaten many times over.

# C++

#ifdef __cplusplus
#include "stdio.h"
int main(){printf("%d",404);}
#endif


# C++, C

#include "stdio.h"
int main(){printf("%d",404);}


Removes the C++ macro

# C++, C, Befunge

#define A "404",,,@
#include "stdio.h"
int main(){printf("%d",404);}


Adds a macro that will be ignored in C++, but read as code in Befunge.

# C++, C, Befunge, Python

#define A "404",,,@
#include "stdio.h"//\
print(404);'''
int main(){printf("%d",404);}//'''


Ads a piece of code that causes the next line to be a comment in C, but not in Python (//<backslash>`)