Multiple Languages:

The following programs are quines in different languages. If you run them in more than one language, it produces itself as output.

Author: Joe Miller
Languages: C and tcl

#define set char*f=
#define F
#define proc main(){
set F "#define set char*f=
#define F
#define proc main(){
set F %c%s%c;
proc /* {} {}
puts -nonewline %cformat %cF 34 %cF 34 91 36 36]
set a {*/printf(f,34,f,34,91,36,36);}
";
proc /* {} {}
puts -nonewline [format $F 34 $F 34 91 36 36]
set a {*/printf(f,34,f,34,91,36,36);}
 
 

Author: Joe Miller
Languages: C and Lisp

Notes: (from the author) The Lisp sucks. It consists almost entirely of destructive variable assignments and sequences of statements. Oh well. For reasons I do not want to discuss, the first line is blank.
 
 

t(setq /*;*/){}main(){char q='\"',s='\\';char*a=
"~%t(setq /*;*/){}main(){char q='~A';char*a=
~S;char*b=/*
)(setq a ~S)
(setq */ ~S;printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}~%";char*b=/*
)(setq a "\\\"',s='\\\\")
(setq */ "
t(setq /*;*/){}main(){char q='%c%c',s='%c%c';char*a=
%c%s%c;char*b=/*
)(setq a %c%c%c%c%c',s='%c%c%c%c%c)
(setq */ %c%s%c;printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}
";printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}
 
 

Author: Ishai Ben-Aroya <ishai@techunix.technion.ac.il>

Languages: ANSI C and Turbo Pascal.

Notes: Pascal code has not been verified
 
 

(*a);main(){char i,*s[]={"%c%s%c%c%c",
"(*a);main(){char i,*s[]={",
"%c%c%c%s%c%s%c%s%c%s%c/*%c%s",
";printf(s[1]);for(i=0;i<=12;i++)printf(s[0],34,s[i],34,44,10);",
"printf(s[2],34,34,125,s[3],10,s[4],10,s[5],10,s[6],10,41,s[7]);",
"for(i=0;i<=12;i++)printf(s[0],39,s[i],39,44,10);",
"printf(s[12],39,39,41,s[8],10,s[9],10,s[10],10,s[11],10,47,125);",
"const q=#34;w=#39;n=#13#10;s:array[0..13] of string=(",
";var i:integer;begin write(s[1]);for i:=0to 12do write(q,s[i],q,#44,n);",
"write(#34#34#125,s[3],n,s[4],n,s[5],n,s[6],n,#47#42#41,s[7]);",
"for i:=0to 12do write(w,s[i],w,#44,n); ",
"write(#39#39#41,s[8],n,s[9],n,s[10],n,s[11],n,#123#42#47#125);end.",
"%c%c%c%s%c%s%c%s%c%s%c{*%c%c",
""};printf(s[1]);for(i=0;i<=12;i++)printf(s[0],34,s[i],34,44,10);
printf(s[2],34,34,125,s[3],10,s[4],10,s[5],10,s[6],10,41,s[7]);
for(i=0;i<=12;i++)printf(s[0],39,s[i],39,44,10);
printf(s[12],39,39,41,s[8],10,s[9],10,s[10],10,s[11],10,47,125);
/*)const q=#34;w=#39;n=#13#10;s:array[0..13] of string=('%c%s%c%c%c',
'(*a);main(){char i,*s[]={',
'%c%c%c%s%c%s%c%s%c%s%c/*%c%s',
';printf(s[1]);for(i=0;i<=12;i++)printf(s[0],34,s[i],34,44,10);',
'printf(s[2],34,34,125,s[3],10,s[4],10,s[5],10,s[6],10,41,s[7]);',
'for(i=0;i<=12;i++)printf(s[0],39,s[i],39,44,10);',
'printf(s[12],39,39,41,s[8],10,s[9],10,s[10],10,s[11],10,47,125);',
'const q=#34;w=#39;n=#13#10;s:array[0..13] of string=(',
';var i:integer;begin write(s[1]);for i:=0to 12do write(q,s[i],q,#44,n);',
'write(#34#34#125,s[3],n,s[4],n,s[5],n,s[6],n,#47#42#41,s[7]);',
'for i:=0to 12do write(w,s[i],w,#44,n); ',
'write(#39#39#41,s[8],n,s[9],n,s[10],n,s[11],n,#123#42#47#125);end.',
'%c%c%c%s%c%s%c%s%c%s%c{*%c%c',
'');var i:integer;begin write(s[1]);for i:=0to 12do write(q,s[i],q,#44,n);
write(#34#34#125,s[3],n,s[4],n,s[5],n,s[6],n,#47#42#41,s[7]);
for i:=0to 12do write(w,s[i],w,#44,n);
write(#39#39#41,s[8],n,s[9],n,s[10],n,s[11],n,#123#42#47#125);end.
{*/}

Author: Bertram Felgenhauer
Languages: dc and C
Notes: uses // comment style

z1d//[[z1d//]P91PP93P[dx]Pq
;main(){char*a="z1d//[[z1d//]P91PP93P[dx]Pq%c;main(){char*a=%c%s%c;printf(a,10,34,a,34);}//]dx";printf(a,10,34,a,34);}//]dx
 

Author: Bertram Felgenhauer
Languages: C, dc, and BrainF***
Notes: You'll have to bootstrap this yourself, but here it is

bertram2.txt
 

Author: njharve@waterloo.ca

Languages: C and vi (VIM 4.0)

Note: This file contains control characters, so it is kept seperate. Also, you need to set the following:

set noai
set wm=0
set nosi
set tw=0
set nogdefault

self_c_vi.txt