Menu Home

Polyglot programming

Polyglot programmes run in more than one programming language at the same time. One example runs in C, PHP, and Bash; another one runs in a ridiculous 282 different languages.

Usually a computer programme works in only one language: Python, C++, JavaScript, Haskell (if you want to be fancy), and many others. But it’s possible to write a programme so that it can run in several languages at the same time, doing the same thing each time. This has pretty much no practical purpose, it’s just a nice way to show off your programming chops.

There are a few nice tricks that make this work. For example, most programming languages have a symbol that prevents specific lines from being processed. These symbols are used to add comments and instructions to the code, hints and help for any other programmer who views the code itself. But different languages use different symbols – so what is hidden in one language is visible in another.

That’s just one trick, but clever programmers have dozens of these tricks up their sleeves, and in the link below there’s one programme that works in 282 different languages. Ridiculous!

Categories: Computer science Sciences

The Generalist

I live in Auckland, New Zealand, and am curious about most things.

Leave a Reply