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.

D-Kuru / CC BY-SA 3.0 AT

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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s