Why do people write convoluted code

What's wrong with comments explaining complex code?

The need for comments is inversely proportional to the level of abstraction in the code.

For example, assembly language is incomprehensible for most practical purposes without comments. Here is an excerpt from a small program that calculates and prints Fibonacci series terms:

Groking can be tricky, even with comments.

Modern example: Regexes are often very low abstraction constructs (lowercase letters, numbers 0, 1, 2, new lines, etc.). You will likely need sample comments (Bob Martin, IIRC, recognizes this). Here is a regular expression that (in my opinion) should match HTTP (S) and FTP URLs:

As languages ​​evolve the abstraction hierarchy, the programmer can use evocative abstractions (variable names, function names, class names, module names, interfaces, callbacks, etc.) to provide integrated documentation. Neglecting to take advantage of this and to put comments on paper is lazy, a disservice and disrespect to the supervisor.

I think of Numerical recipes in C , mostly literally in Numeric recipes have been translated into C ++ what I call Numerical recipes (in FORTAN) with all variables, began,,, etc. that are managed in each version. The algorithms may have been correct, but they did not take advantage of the abstractions of the languages ​​provided. And they kill me. Example from an article by Dr. Dobbs - Fast Fourier Transform:

As a special case of abstraction, each language has idioms / canonical code fragments for certain general tasks (deleting a dynamic linked list in C). Regardless of what they look like, they shouldn't be documented. Programmers should learn these idioms as they are unofficially part of the language.

So to take away: Non-idiomatic code made up of simple building blocks that cannot be avoided requires comments. And that's WAAAAY less necessary than it happens.