Question

First of all, this is the definition of a polyglot:

In the context of computing, a polyglot is a computer program or script written in a valid form of multiple programming languages, which performs the same operations or output independently of the programming language used to compile or interpret it.

But here is the question: If I have a program like this:

#include <stdio.h>

int main() {
  puts("Hello, world!");
  return 0;
}

This is C. As Objective-C (a thin OO-layer on top of C) is a strict superset of C, this could also be Objective-C with the same output, making it a polyglot.

But do strict supersets count when it comes to polyglots (making every single C program a polyglot)?

Was it helpful?

Solution

Strictly speaking, yes that's a polyglot in C and Objective-C. But it won't impress anyone.

Polyglots are more interesting when they work on very different languages. If you can get it working in Python, Brainfuck, Perl and Befunge too it will be slightly more impressive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top