News for hackers. Stuff that matters.
Re:Erlang beauty by dragonwriter on Tuesday November 17, 2015 @07:59PM (#10585195)
> Someone smart, somewhere, at some time, did a study which concluded that the human brain can easily hold six or seven items in short-term memory with little trouble, but beyond that, it becomes taxing. This applies nicely to lines of code in a function. Amazingly, after all the above guidelines have been followed, bringing a function’s lines-of-code count down to a maximum of seven is surprisingly easy to do.

https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus...

This has got to place as one of the most misapplied research findings in history. If you have an aesthetic preference for 7 as a limit to the number of lines of code in a function, then, sure, do that, but don't pretend there is science behind it (or at least not this particular science.)

Re:Erlang beauty by jacquesm on Tuesday November 17, 2015 @08:28PM (#10585316)
She may be wrong about that particular number, but it is really no secret that reducing the scope is a key ingredient to solving problems and avoiding bugs. Another key ingredient is to stay far away from side-effects and Erlang does a fairly good job of riding that fine line between ideal theory and pragmatism.

edit: gender of author corrected, thanks Nathancahill

Re:Erlang beauty by nathancahill on Tuesday November 17, 2015 @08:41PM (#10585358)
*she

When in doubt, 'they' is a safe bet too.

Re:Erlang beauty by StavrosK on Wednesday November 18, 2015 @05:04AM (#10586889)
To be fair, in our circles, "he" will be right about 95% of the time.
Re:Erlang beauty by nathancahill on Wednesday November 18, 2015 @11:22PM (#10592725)
:/
Re:Erlang beauty by dooptroop on Thursday November 19, 2015 @03:50AM (#10593550)
shim also works
Re:Erlang beauty by lqdc13 on Tuesday November 17, 2015 @08:25PM (#10585299)
Pretty sure nobody did a study with a specific number of LoC for best understanding, because it probably depends on a lot of things. But quick understanding is a function of consistent style and a small number of things to keep in mind required to understand each part.

Things are easier to understand when the deciphering part is done quickly and also when you only have to keep as few things in mind as possible.

An example of a Python statement that is short, but difficult to understand:

    '\n'.join([map(some_func, a) + 'somth' for i, j in c.items() for a, b in i.items()])