Hello Polyglots!

What is it?

Polyglot is a computer program in eight languages. You compile it with your favorite compiler and run it. It says:

hello polyglots

It supports the following languages:

  1. COBOL (ANSI)
  2. Pascal (ISO)
  3. Fortran (ANSI, f77)
  4. C (ANSI-ish)
  5. PostScript
  6. Linux/Unix shell script (bash, sh, csh)
  7. x86 machine language (MS-DOS, Win32)
  8. Perl (version 5)

How to use Polyglot

It's pretty simple:

  1. Download the source and rename it to
    polyglot.[cob|pas|f77|c|ps|sh|com|pl]
  2. Compile and run with your favorite compiler and operating system.

Notes:

  1. We have attempted to use only standard language features.
  2. Without the -traditional flag, gcc will issue a warning.
  3. When transfering from Linux/Unix to MS-DOS/Windows make sure that a LF is correctly translated into a CR/LF.
  4. Keep the blank lines at the start of the program. They are important.

10th Anniversary Edition

Polyglot turned 10 years old in February 2001. Kev thought it needed an update, so he added perl, and fixed the x86 machine language to work with Win32.

We felt pretty smug about getting another language in there, so we thought we'd submit it to the The International Obfuscated C Code Contest. Months later, when the results were finally announced, we failed to get a mention.

History

A long time ago (1990) some people were talking about polyglot programs in rec.puzzles. A couple of programs were posted that worked in two or three languages, and we thought that was pretty cool.

We thought we'd have a go, and wrote our own. It was fun. Some time later, we posted it back to the newsgroup. And later still, we put up this web page (http://ideology.com.au/polyglot).

Copying Polyglot

We have had a couple of enquiries about copying polyglot and including it in various Linux distributions.

Polyglot is in the public domain. You are free to do as you please with it. If you do use it, an acknowledgement would be nice.

The authors are Kevin Bungard, Peter Lisle, and Chris Tham. You can contact them here. Thanks goes to George Janczuk.