Skip to main content
Removed a forgotten comment that became obsolete with the last change.
Source Link
314
  • 41
  • 3

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

8 languages, 425 bytes

Lua -> Rust -> Java -> C99 -> Python 3 -> JavaScript -> Ruby -> Bash

Lua:

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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'');\\\\\\\\\\\\\\\")\\\\\\\\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 = "public class Main{public static void main(String[] args){System.out.println(\"#include <stdio.h>\\nint main() {printf(\\\"print(\\\\\\\"alert('puts \\\\\\\\\\\\\\\\'echo \\\\\\\\\\\\\\\"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 \\\\\\\"PPCG\\\\\\\"\\\\\\\\'');\\\")\\n\");}");}}

C:

#include <stdio.h>
int main() {printf("print(\"alert('puts \\\\'echo \\\"PPCG\\\"\\\\'');\")\n");}

Python 3:

print("alert('puts \\'echo \"PPCG\"\\'');")
alert('puts \'echo "PPCG"\'');
puts 'echo "PPCG"'

Bash:

echo "PPCG"

11 languages, 536 bytes

Bash -> Python 3 -> Go -> Lua -> Rust -> Java -> C99 -> Python 2 -> JavaScript -> Ruby -> Batch

Bash:

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 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 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

Using if 1 == 1 then prevents Python compatibility.

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);}
public class Main{public static void main(String[] args){System.out.println("#include <stdio.h>\nint main() {printf(\"print \\\"alert('puts \\\\\\\\'@echo PPCG\\\\\\\\'');\\\"\");}");}}

C99:

#include <stdio.h>
int main() {printf("print \"alert('puts \\\\'@echo PPCG\\\\'');\"");}

Python 2:

print "alert('puts \\'@echo PPCG\\'');"
alert('puts \'@echo PPCG\'');
puts '@echo PPCG'

Batch:

@echo PPCG
Source Link
314
  • 41
  • 3

8 languages, 425 bytes

Lua -> Rust -> Java -> C99 -> Python 3 -> JavaScript -> Ruby -> Bash

Lua:

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\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'');\\\\\\\\\\\\\\\")\\\\\\\\n\\\\\\\");}\\\");}}\";println!(\"{}\", s);}")
end

Using if 1 == 1 then prevents Python compatibility. I assume I could have used Python 2 instead of 3.

Rust:

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\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\\'');\\\\\\\")\\\\n\\\");}\");}}";println!("{}", s);}

Java:

public class Main{public static void main(String[] args){System.out.println("#include <stdio.h>\nint main() {printf(\"print(\\\"alert('puts \\\\\\\\'echo \\\\\\\"PPCG\\\\\\\"\\\\\\\\'');\\\")\\n\");}");}}

C:

#include <stdio.h>
int main() {printf("print(\"alert('puts \\\\'echo \\\"PPCG\\\"\\\\'');\")\n");}

Python 3:

print("alert('puts \\'echo \"PPCG\"\\'');")

JavaScript:

alert('puts \'echo "PPCG"\'');

Ruby:

puts 'echo "PPCG"'

Bash:

echo "PPCG"