Polyglot. \Poly*glot’\ a. [Gr. manytongued; many + tongue, language:
cf. F.polyglotte.]
1. Containing, or made up, of, several
languages; as, a polyglot.
Well, I think it was inevitable. From the compiler of the Quine Page, here is a collection of polyglots (programs which can be compiled in more than one language). Okay, so there aren't many, but have you ever tried to write one?
Author: Micah Cochran
Languages: C, Perl
What it does: prints "Hello World"
Author: Maarten Litmaath (maart@cs.nu.vl)
Languages: C, Pascal, Fortran, sh
What it does: prints "Hello World"
Author: Maarten Litmaath (maart@cs.nu.vl)
Languages: C, Fortran, sh
What it does: prints "Hello World"
Author: Tom Dawes-Gamble
Languages: C, Cobol
What it does: prints "Hello World"
Author: Jack Applin
Languages: C, Fortran, sh
Note: IOCCC 1986 winner.
What it does: prints "Hello World"
Authors: Kevin Bungard, Peter Lisle and Chris Tham
Languages: COBOL, Pascal, Fortran, C, Postscript, sh, 8086 asm,
Note: Do not remove leading blank lines
What it does: prints "Hello Polyglot"
Authors: Tom Dawes-Gamble
Languages: C, Cobol
What it does: tells you if it was compiled in C by finding an "error"
Author: Ishai Ben-Aroya <ishai@techunix.technion.ac.il>
Languages: ANSI C and Turbo Pascal.
Notes: Pascal code has not been verified
What it does: It's a quine
Author: Joe Miller
Languages: C and tcl
What it does: quine
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.
What it does: another quine
Author: Bertram Felgenhauer
Languages: C and dc
What it does: quine
Author: Bertram Felgenhauer
Languages: C, dc, and BrainF***
What it does: quine
Author: njharve@waterloo.ca
Languages: C and vi (VIM 4.0)
What it does: yet another quine
Note: You need to set the following:
set noai
set wm=0
set nosi
set tw=0
set nogdefault
Author: Philippe "BooK" Bruhat
Langage: Perl and C
Notes: Depending on your hardware (little or big endian), you might
need to change an integer value in the code (see SOLUTION
file)
What it does : it's a clone of the well-known wc program, except
that its performances are several orders of magnitude
worse
(mainly because the files are read one byte at a time...)