News for hackers. Stuff that matters.
Re:MIT claims to have found a “language universal” that ties... by AnimalMuppet on Thursday August 06, 2015 @02:46PM (#10018497)
I think it has implications for language design. Some syntaxes are going to be better than others, based on this.

It also means that, for a function that takes several parameters, some parameter orders are better than others.

Re:MIT claims to have found a “language universal” that ties... by canjobear on Thursday August 06, 2015 @02:51PM (#10018532)
Yes, specifically you should order arguments so the order will be on average from short to long.

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.

Re:MIT claims to have found a “language universal” that ties... by jonahx on Thursday August 06, 2015 @09:30PM (#10020489)
Thanks for all your answers here! Could you elaborate on the above? Why does it imply short to long orderings are better? Also, I don't follow your comment about map/filter/reduce being bad except unless you have ruby-esque do blocks. Are you referring to something like map(<big function>, array)?
Re:MIT claims to have found a “language universal” that ties... by canjobear on Thursday August 06, 2015 @11:32PM (#10020829)
Yeah, map(<big function>, array) creates a dependency that exists from when you read "map" to when you read the name of the array, potentially spanning a very long function. But if you have map(array) do <big function>, then you only have a dependency from "map" to the beginning of the function.

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.

Re:MIT claims to have found a “language universal” that ties... by andolanra on Thursday August 06, 2015 @03:15PM (#10018692)
There's a hidden premise in your argument that I would argue is false, and that's that programming languages should attempt to emulate the same principles as natural languages. Programming languages and natural languages do not at all fill the same niche, and there are many cases in which natural languages optimize for things that would be bad in programming 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.

Re:MIT claims to have found a “language universal” that ties... by AnimalMuppet on Thursday August 06, 2015 @03:23PM (#10018743)
I agree that you don't (shouldn't!) have the redundancy in computer languages. But I think the point of the article is that some word orderings cause less load on our brains. I think that's directly applicable to function parameters. For example, if I have a function that takes an array, a starting offset, an ending offset, and a value to search for within those offsets, then

  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.