811 languages, 425536 bytes
LuaBash -> Python 3 -> Go -> Lua -> Rust -> Java -> C99 -> Python 32 -> JavaScript -> Ruby -> BashBatch
LuaBash:
e="echo -n "
p(){
eval "for i in {1..$1}
do
$e'\'
done"
}
$e'import sys;print("package main\nimport \"fmt\"\nfunc main() {fmt.Printf(\"if 1 == 1 then print(\\\"fn main() {let s='
p 7
$e'"public class Main{public static void main(String[] args){System.out.println('
p 15
$e'"#include <stdio.h>'
p 16
$e'nint main() {printf('
p 31
$e'"print '
p 63
$e"\"alert('puts "
p 128
$e"'@echo PPCG"
p 128
$e"'');"
p 63
$e'"'
p 31
$e'");}'
p 15
$e'");}}\\\\\\\";println!(\\\\\\\"{}\\\\\\\", s);}\\\") end\")}") if sys.version_info[0]==3 else exit()'
The p
function reduces the code size by 497 bytes compared to typing all backslashes manually.
Python 3:
import sys;print("package main\nimport \"fmt\"\nfunc main() {fmt.Printf(\"if 1 == 1 then print(\\\"fn main() {let s=\\\\\\\"public class Main{public static void main(String[] args){System.out.println(\\\\\\\\\\\\\\\"#include <stdio.h>\\\\\\\\\\\\\\\\nint main() {printf(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"print \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"alert('puts \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'@echo PPCG\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'');\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");}\\\\\\\\\\\\\\\");}}\\\\\\\";println!(\\\\\\\"{}\\\\\\\", s);}\\\") end\")}") if sys.version_info[0]==3 else exit()
The obligatory Python 2/3 differentiation.
Go:
package main
import "fmt"
func main() {fmt.Printf("if 1 == 1 then print("fn\"fn main() {let s=\\\"public class Main{public static void main(String[] args){System.out.println(\\\\\\\"#include <stdio.h>\\\\\\\\nint main() {printf(\\\\\\\\\\\\\\\"print \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"alert('puts \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'@echo PPCG\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'');\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\");}\\\\\\\");}}\\\";println!(\\\"{}\\\", s);}\") =end")}
Lua:
if \"public1 == 1 then print("fn main() {let s=\"public class Main{public static void main(String[] args){System.out.println(\\\"#include <stdio.h>\\\\nint main() {printf(\\\\\\\"print( \\\\\\\\\\\\\\\"alert('puts \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'echo\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'@echo \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"PPCG\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'');\\\\\\\\\\\\\\\"PPCG\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'')\\\\\\\\n\\\\\\\";\\\\\\\\\\\\\\\"\\\\\\\");}\\\");}}\";println!(\"{}\", s);}")
end
Using if 1 == 1 then
prevents Python compatibility. I assume I could have used Python 2 instead of 3.
fn main() {let s = "publics="public class Main{public static void main(String[] args){System.out.println(\"#include <stdio.h>\\nint main() {printf(\\\"print( \\\\\\\"alert('puts \\\\\\\\\\\\\\\\'echo\\\\\\\\\\\\\\\\'@echo \\\\\\\\\\\\\\\"PPCG\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\'');\\\\\\\"PPCG\\\\\\\\\\\\\\\\'')\\\\n\\\";\\\\\\\"\\\");}\");}}";println!("{}", s);}
public class Main{public static void main(String[] args){System.out.println("#include <stdio.h>\nint main() {printf(\"print( \\\"alert('puts \\\\\\\\'echo\\\\\\\\'@echo \\\\\\\"PPCG\\\\\\\"\\\\\\\\'');\\\"PPCG\\\\\\\\'')\\n\";\\\"\");}");}}
CC99:
#include <stdio.h>
int main() {printf("print( \"alert('puts \\\\'echo\\\\'@echo \\\"PPCG\\\"\\\\'');\"PPCG\\\\'')\n";\"");}
Python 32:
print( "alert('puts \\'echo\\'@echo \"PPCG\"\\''PPCG\\'');")
alert('puts \'echo\'@echo "PPCG"\''PPCG\'');
puts 'echo'@echo "PPCG"'PPCG'
BashBatch:
echo@echo "PPCG"PPCG