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.

@david_chisnall Overly verbose code is the one that does not use abstraction or force you to see the details of these abstraction when you want to stay at a higher level.
People who complain about variable length often fail to understand where that and... tend to do very verbose code.
Btw, I like functionnal style code where one character long variable name are ok because functions are only 3 lines long and the type is explicit and that's enough.
@david_chisnall +1 for verbose code. it helped me a ton in 500'000 lines of code written over 25 years of my main projects. I still refactor stuff to give it better names.