Mimic is a brilliant tool for injecting mayhem into code. It has a simple strategy, swapping existing characters with homoglyphs – other characters that are visually identical but semantically different – from across Unicode’s Basic Multilingual Plane.
It was inspired by this tweet:
MT: Replace a semicolon (;) with a greek question mark (;) in your friend’s C# code and watch them pull their hair out over the syntax error
— Peter Ritchie (@@peterritchie) November 16, 2014
The Greek question mark looks identical to the semi-colon in most fonts. Other symbols, like the full width semi-colon, differ only in how much whitespace they occupy, or other differences that are indiscernible at a glance. Mimic replaces letters, numbers, punctuation, and whitespace itself, to create incomprehensible error messages:
The screenshot above has only one character replaced. Why is index not index??
Mimic doesn’t care if the symbols it introduces are valid symbols in the language the code is written in – invisible control characters can make the code uncompileable just as well as adding the letter “b” everywhere. Whether or not they are characters allowed for use in an identifier would only change the type of error that occurs.
However, the idea of using characters with identical appearance for different purposes could be an interesting one for esolangers when put to good use. Some Uniciode-aware compilers are pretty unrestrictive with variable names, even allowing characters from the far reaches of Unicode. Even stodgy, old-school C++ has some ranges of Unicode that are acceptable. Those ranges vary based on compiler, but gcc and Visual C++, oddly, both include the Greek question mark, which seems like a terrible idea to include.
Here’s simple code using the Greek question mark in a variable name – it works if one remembers to set the file to UTF-8 (codepage 65001):
Creating a variable called a; in C++
This looks ridiculous but is perfectly valid C++. This can be thought of as the opposite of code Mimic produces: it looks like it should certainly fail, yet runs perfectly well.