top | item 19959783

Ask HN: I am looking for academic studies about computer program readability?

3 points| ldb | 6 years ago | reply

I wonder if there are any scientific studies that indicate whether the human brain is better suited to perceive a formula written as e.g. (1) "a * (b + c)", vs. (2) "mult(a, plus(b, c))", vs. (3) "(mult a (plus b c))".

2 comments

order
[+] RNeff|6 years ago|reply
FORTRAN was short for FORmula TRANslator. Its design goal was programmers would write normal math statements. This was copied by many other languages. Then languages started using the math symbols for other things. C++ allows programmers to define the math symbols to other types. Java and others use '+' for string concatenate.

The problem occurs when: 1. the function has more than two arguments; 2. the function is semantically different from the meaning implicit in a math symbol.

One solution is use the same syntax for all functions. In Lisp, every thing is a list, so ( function ( parameters )). In Smalltalk, every thing is an object, so send a message to an object with parameters.

Read the Lisp manual, and the SmallTalk-80 book about the language design theory.

The big boost in program readability is following a style guide with the rules for naming, indentation, commenting, and other important features, plus automated or manual style reviews.

The Hungarian notation for variables was an attempt to document the type of a variable in a language, 'C', which had loose typing rules.

[+] ldb|6 years ago|reply
> The big boost in program readability is following a style guide with the rules for naming, indentation, commenting, and other important features, plus automated or manual style reviews.

I completely agree. I just wondered if there has been done any research where programmers are presented with some code they've never seen before and then the time is measured until they have understood the code (e.g. can correctly answer some test questions regarding the function of the code). In such a scenario one could try to find a "best" style guide, i.e. a style guide where most programmers understand new code the quickest. Have you ever heard of such research?