Are you a programmer? Do you have a hard time reading super_long_variable_names_like_this? Replace them with emoji for quick at-a-glance readability of source code! Become the mythical “10x engineer” thanks to this new programming idea.

Background:

Many programming languages allow extremely long user-defined variable and function names. Frequently, companies will have a specific policy on naming: for example, forbidding abbreviations and requiring descriptive variable names (e.g., “CALCULATE_TOTAL_COMPOUND_INTEREST” would be OK, but “COMPINT” or “CCI” would not).

The Issue:

Normally, this makes sense: if someone has to read a bunch of code written by a coworker, it’s a lot easier to interpret “did_customer_request_an_email == false” versus “c_eml == false”.

However, long variable names can also cause code to become unreadably verbose (Figure 1).

Fig. 1: The long variable names make this snippet of code hard to read. This particular example contains 2000 characters across 35 lines.

While this code complies with the company’s “descriptive variable names, no abbreviations” naming policy, it’s quite difficult to read!

Proposal:

Code-editing software should needs a single-button toggle that replaces all variables and function names with a short version—preferably, a single distinctive emoji.

As shown in Figure 2, this makes the code much less cluttered. Now we can see what’s going on!

Fig. 2: This is the same code as in Figure 1, but with emoji instead of “descriptive” variable names. This “decluttered“ code is less than half the size of the original (only 990 characters)!

Conclusion:

If a source code file happened to be so long that we entirely run out of emoji, that’s no problem either: there are over 98,000 Chinese characters in Unicode, so we can just use those—we won’t hit problems unless there are (somehow) over 100,000 unique functions/variables in a single file.

PROS: Since this would be a non-destructive toggle, there’s no downside: a programmer could enter “emoji mode” when looking at the structure of some code, but switch to “verbose mode” when detailed information was needed.

CONS: None!

Originally published 2024-07-01.