Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

For challenges involving code that runs in multiple programming languages.

What is a polyglot?

A polyglot is code that runs in multiple programming languages. For example, this one prints Hello, world! in ANSI C, PHP, and Bash:

#define a /*
#<?php
echo "\010Hello, world!\n";// 2> /dev/null > /dev/null \ ;
// 2> /dev/null; x=a;
$x=5; // 2> /dev/null \ ;
if (($x))
// 2> /dev/null; then
return 0;
// 2> /dev/null; fi
#define e ?>
#define b */
#include <stdio.h>
#define main() int main(void)
#define printf printf(
#define true )
#define function
function main()
{
printf "Hello, world!\n"true/* 2> /dev/null | grep -v true*/;
return 0;
}
#define c /*
main
#*/

Here is more information about polyglots.

Polyglots will often require programs to do the same thing (example), but many challenges require that programs do different things in each language (example)

history | excerpt history