Brutkey

David Chisnall (*Now with 50% more sarcasm!*)
@david_chisnall@infosec.exchange

People often complain that my coding style rule that you should not use abbreviations gives overly verbose code. I normally reply that:
Code is written once and read many times, optimising for reading is better, and
People have different preconceptions about what abbreviations may mean.

Today, I found a
great example, in the #xmake codebase. The function that checks whether a code snippet in a C-family language compiles has the following set of options to pick the languages:

cc|cxx|mm|mxx

You will note that
most of these are file extensions that the compiler will support with a default language inferred from the extension:
cc: C++ file.
cxx: C++ file.
mm: Objective-C++ file.
mxx: None.

In contrast, xmake treats them as:
cc: C
cxx: C++
mm: Objective-C
mxx: Objective-C++

If you see in the code
sourcekind="mm", you would be forgiven for assuming that the code should be assumed to be Objective-C++, because that's what clang or gcc will assume a .mm file is.

It adds almost nothing to the verbosity of these to treat
c as C, c++ as C++, objective-c as Objective-C, and objective-c++ as Objective-C++. Yet a person who sees sourcekind="objective-c" will be able to understand that the code should be treated as Objective-C with zero additional context.