lp0 on fire

My personal blog

Programming: Code accessability

With human languages, not only words themselves, but also the grammar and structure of a language dictates how we think. For example, in a language where gender is assigned to various forms of words, it will dictate how you use those words.

Chinese for example is terribly difficult due to all kinds of exceptions to the rules and lack of dictated structure, whereas English is much easier to pick up due to having less complicated rules, exceptions and a more clearly defined structure. However, in Chinese we have tight compression of a sentence, and it can express ideas that cannot be done in English because simply no equivant.

After having used a variety of languages, I can confirm it's the same for programming languages as well with the exception of expression depending on how close to the operating system a language is.

  • Code one-liners that are long is more obfuscated than a language that forces you to make multiple simple sentences to explain the same concepts.
  • Lines with many operations at once are more obfuscated than distributing them to multiple lines.
  • No clear definition of data and/or structure makes it much easier for the code and operations to become messy and obfuscated.
  • Large standard libraries and codebases cannot fit inside the brain of the code authors, thus it makes the author dependent on external tooling and cannot write without it. The same holds true for long descriptive names.
  • Data structures for humans and not for computers means we think and write code with all the deficiencies of human languages.

Complexity is the detriment of languages, and all of the above add complexity.

Having one operation per line, a clear distinction of scope, plenty of spacing to segment code, self-explanatory code, zero to very little reliance on (standard) libraries, a maximum line width of 80 characters, and write verbose and clear data structures and code helps tremendously with improving code readability.

In fact, it helps people with monocular vision (like me) too. I only see and read one side of a 24' inch monitor. By having one operation per line, it's easier for screen readers to read the code out loud and keep it segmented.

I know my brain capacity is limited. Reading code, remembering what I read and thinking of a solution for the problem at hand together requires quite some energy and brain capacity. That's why it's important to keep it small, structured and segmented. To write code like a machine, not like a human or use fancy tricks/paradigms/libraries. To make it good enough that I can work on the code in unmodded GNU Nano without code completion or syntax highlighting.