Has that ever been an advantage?
EDIT:
I'm not implying it's useful just for programming "math stuff", after all, everything can be reduced to a mathematical problem - including game engines[1], web application frameworks[2], etc.
[1] http://www.cse.unsw.edu.au/~pls/thesis/munc-thesis.pdf [2] https://github.com/yesodweb/yesod
In Haskell, if you see a short name, look up and down 3 lines for the definition. If you can't find it then complain.
Well... more power to python, and culture that embraces 'what your see is what your get' and super-readable code.
map f [] = []
map f (x:xs) = f x : map f xs
You're supposed to infer from the short function names that f and x could be anything. The only important bit is that you can apply one argument to f (so, for example, f could take two parameters, and then map is just doing a single partial application). In that context, x and xs is actually a better convention than "first" and "rest", because they indicate the adherence to the type system. The naming here is saying that x is of the type of elements of xs, and that this is the only important information for map. This seriously helps in more complicated functions like zip, etc.Compare:
map f [] = []
map f (x:xs) = f x : map f xs
With: map f xs = [f x | x <- xs]
Or even better, in Python: map = lambda func, iterable: [func(x) for x in iterable]
Which one is more readable?First one requires looking up and down in order to understand what is going on. Second one is better, context is limited to one line. And the last one doesn't require you to remember context at all.
map f xs = [f x | x <- xs]
the most readable, but given that list comprehension is basically a map and a filter joined together, that definition is kind of cheating.I find the python version hardest to read (even though it's also "cheating"), which is largely because both the identifiers and the control constructs are alphabetic.
[func(x) for x in iterable]
I have to read the words to figure out that for/in are the keywords and x/iterable are identifiers. func(x) is at least pretty obviously a function application. I'm glad it's not [call func x for x in iterable]
If you compare this to [f x | x <- iterable]
The parentheses-less function application might take some getting used to, but then it's pretty easy in my opinion. The | nicely divides it into two parts. A function application on the left, and a "take each element x out of iterable" on the right.The only other thing is that because "iterable" is such a long word I expect it to be an identifier imported from a library or somewhere else in the program, and certainly not earlier in the line.
In summary, I think a lot of what we find "readable" depends on what we are used to.
I think a general rule is that source code readability is inverse to the amount of context information that one needs to remember in order to interpret and understand the code.
If you can look at the code at any place (and at any scale, ranging from a single line to the whole call graph), and without any context understand what is happening at this particular place - code is readable. And on the opposite, if you need to know a lot about the context of each particular line of code - code is unreadable.
In C or C++ this newer was the case, because type information was never implied (until recently, when auto was introduced). And in dynamic languages, like Python, this is also almost never the case, because good mainstream developers use object names consistently.
In the functional world however, mainstream (if there is any mainstream, as I often see each developer working in his/her own unique style) folks just say phrases like 'true documentation comes from the types' and write their recursions freely, and with no regard to the reader.
So yes. We'll have to agree to disagree.