It also means that, for a function that takes several parameters, some parameter orders are better than others.
It also means that, for a function that takes several parameters, some parameter orders are better than others.
I try to write my code this way. map, filter, and reduce are terrible from this perspective. Unless you have do blocks like in Ruby or Julia!
Also, dplyr's %>% pipe operator is a great way to reduce dependency length in R code.
In general, if you have a function call f(a, ..., y, z), when you parse that (mentally, or in a shift-reduce parser) you have to keep the function name f in memory all the way to z. So you want to make a, ..., y as short as possible.
Similarly, dependency length minimization predicts that in English people will want to order expressions from short to long after a verb or preposition. There is a lot of evidence for this preference; it's been documented since the 1930s.
If there were a programming language where the function name came after the arguments, like (a, b)f, then the best order would be long-to-short.
Similarly, the DLM prediction for verb-final languages like Japanese is that people will prefer long-to-short orders. It appears that this preference does exist, but it is much weaker than the short-to-long preference among speakers of English-like languages.
For example, natural languages are infamously redundant—for example, gender agreement between nouns and adjectives and even (in some languages) verbs—but that's because they developed so that they could be understood even if you were shouting over the wind or otherwise didn't hear part of the sentence. Programming languages have no such restrictions, and as such, optimizing a programming language for the same kind of redundancy as a natural language would lead to needless tedium like
int x = int_addition(int 2, int 3);
but in the context of a programming language, this kind of redundancy ends up being needless bookkeeping without presenting any of the same advantages of redundancy in natural language.That doesn't mean that your conclusions are wrong—I think some parameter orderings are better than others! But I think that's true for reasons orthogonal to the findings in this paper.
int limitedSearch(int *array, int startOffset, int endOffset, int searchValue)
causes less cognitive load than int limitedSearch(int *array, int searchValue, int startOffset, int endOffset)
simply because the offsets "go with" the array to make up one concept (where you're searching).There may be other reasons why some parameter orderings are better than others, but I think the article is directly relevant.