by orkoden · 12y ago · 0 comments
var result = somefunc(a,b) // object var otherResult = somefunc(a) // function
It gets even more confusing if overloading of function names for different parameters or different number of parameters is allowed.
So elegant: maybe. Readable: no. Depends on the programming language.
In a previous article (http://fr.umio.us/why-ramda/) I discuss more thoroughly how I would tend to use this currying, namely to build up collections of useful functions, often in points-free style, so that major parts of the application would end up as (ideally well-named) functions, each which serve as pipelines of these smaller functions, passing data through the system.
I do find this significantly more readable, but _de gustibus non est disputandum_.
Basically, it seems to me like trying to fix something that isn't broken.
The purpose of currying is to improve reuse and chaining of functions, resulting in easier to read and more elegant code.
The minute you step into the standard industry things change a little bit. I once maintained an amazing piece of javascript that did dynamic server requests and rendered graph data, processed user input, changed views, and make lasting configuration changes to the database. The first 30 or so lines of code was simply setting up the functional haskellish environment for javascript, and the last 40 lines + 40 lines of HTML put everything else together. It was terse, compact, elegant, and impossible to maintain or make wider changes after the original author had moved on. It was tightly contained into one piece of the code, so not something that will be seen on the mainline easily. Going in and fixing any tiny little bug forced any unfortunate developer to immediately learn Chinese. Someone was tasked to re-write it so the rest of the team could maintain it effectively.
I like ruby/python a lot because it meets in the middle fairly easily, and doesn't require contortions to the natural intent of the language to get rid of cruft.
I was talking about currying and FP in nicer languages.