Re:On moving code from C# to F#
by was_boring on Saturday March 19, 2016 @07:38PM
(#11321022)
I perfer the verbosity because it helps with eliminating ambiguity when the code changes hands or goes into "maintenance". This is especially true in weakly, or duck, typed languages.
Both have merits though.
> having so many extra pixels lit as you read things
Your brain is excellent at turning words, even long ones, into instantly recognizable shapes. That's why transposing lteters as I'm doign in this sentnce doesn't harm readability very much.
Good, easily-maintained code is not poetry, and it's not math. It's Hemingway: short, terse sentences that say only what they need to say and nothing more. They are self-contained and self-evident.
On a semi-related note, there's a study showing that non-programmers have a much easier time reading code with more white space. To adapt your example above:
var newCustomers = getNewCustomers()
foreach(var newCustomer in newCustomers)
{
newCustomer.this .that etc.
}
It's much easier for your brain to pull out different symbols when there's more white space.
It's not just the hassle of typing long names out; a good editor can help there. It's the visual overhead of having so many extra pixels lit as you read things.
Short functions are good for local functions:
It's nicer to instead have: let al = sb.AppendLine al bla ...This is especially true then the local code pattern is 2, 3, or more lines or when it contains branches.