What makes code readable? I feel like this word is borderline synonymous with “I like this thing”. We all know code is read more than written, so readability matters, but does anyone actually know what makes it easier to read and understand?
So, my opinion is that 'readable code' organizes pragmatic sections together, and uses line comments and blank lines to annotate and separate. It's also perfectly fair to expand sections of your code if you're confident that your compiler will optimize it properly; I've seen people complain about C/C++ code doing this, but I think it does wonders for readability. Taking 20 seconds to make a readable version of your function could save hours of debugging time down the line, you never know.
I think code readability means that you can read and understand code you have never seen before with the least amount of effort.
It means that the code follows the "principle of least surprise" and "works as expected". Those are imprecise terms, but they mean that the code you see is the code that runs.
I have grown to appreciate the readability of Ada because it is easy to read and understand. What you see is what you get without any "default magic", "implicit conversions", or "this is probably not what you want, but I will do it anyways" that other programming languages do.
"Ada's philosophy is different from most other languages. Underlying Ada's design are principles that include the following:
Readability is more important than conciseness. Syntactically this shows through the fact that keywords are preferred to symbols, that no keyword is an abbreviation, etc.
Very strong typing. It is very easy to introduce new types in Ada, with the benefit of preventing data usage errors.
It is similar to many functional languages in that regard, except that the programmer has to be much more explicit about typing in Ada, because there is almost no type inference.
Explicit is better than implicit. Although this is a Python commandment, Ada takes it way further than any language we know of:
There is mostly no structural typing, and most types need to be explicitly named by the programmer.
As previously said, there is mostly no type inference.
Semantics are very well defined, and undefined behavior is limited to an absolute minimum.
The programmer can generally give a lot of information about what their program means to the compiler (and other programmers). This allows the compiler to be extremely helpful (read: strict) with the programmer."
Source: https://learn.adacore.com/courses/intro-to-ada/chapters/intr...
Yeah.
"Readable" code for me doesn't waste vertical real estate. If it's off the screen, it's out of my head. This doesn't mean writing 200 char lines; I usually limit myself to 80. It means picking better languages, or at the very least not enforcing obnoxious linting like
f(
x,
y,
z
);
the moment a line goes over a limit.