News for hackers. Stuff that matters.
Re:Readable Clojure by abc_lisper on Wednesday May 24, 2017 @06:59PM (#14414100)
Agree with most of them, except,

Advise against higher order functions. Higher order functions separate clojure from other languages, and is one of defining features of this class of languages.

Advise to not use threading. Threading is just a series of steps. I find it very readable. If I start using symbols the step sequence can become a step graph FWIW.

Re:Readable Clojure by emidln on Wednesday May 24, 2017 @09:32PM (#14414729)
I'd go so far as to advise aggressive use of the threading macros in order to remove visual nesting. It is much easier to read:

    (def good-set-of-stuff
      (->> stuff
           (filter good?)
           (map enrich)
           (into #{}))
than it is to read:

     (def good-set-of-stuff
       (into #{}
             (map enrich
                  (filter good? stuff))))
or

    (def good-set-of-stuff (into #{} (map enrich (filter good? stuff))))
Re:Readable Clojure by jwdunne on Thursday May 25, 2017 @03:10AM (#14415797)
Without much Clojure experience, I agree. Sequential, what-comes-first, is easier to read than finding the first evaluated expression and peeling backwards just to build the same mental model.
Re:Readable Clojure by chc on Wednesday May 24, 2017 @07:28PM (#14414255)
Based on the examples presented, it seems like the OP doesn't actually mean "higher-order functions" in general. The "good" example still uses map, which is a higher-order function. It seems like what OP has a problem with is specifically functions that return functions.
Re:Readable Clojure by KurtMueller on Wednesday May 24, 2017 @08:51PM (#14414604)
So basically he'd be against currying? I find currying useful in certain situations - threading/piping being a common scenario.
Re:Readable Clojure by chc on Wednesday May 24, 2017 @09:21PM (#14414698)
Currying and composition, I think.

I actually think he has a point on those two in the context of Clojure specifically. The process of explicitly currying or composing functions (again, in Clojure specifically) is usually more verbose and IMO harder to read than just writing an anonymous function that expresses the same thing.

Re:Readable Clojure by daxfohl on Wednesday May 24, 2017 @09:43PM (#14414770)
I frankly don't like these features even in Haskell. There are a few specific places where it makes things more elegant, but in general I dislike having to think about "how do I arrange params to allow for the greatest possible use of partial application in the rest of my code?", and then the inevitable "oh I can fix that with (flip (flip flip))" or some nonsense. It's tangential to the requirements of getting my app done, and generally time / brain cells wasted. I'd rather it simply not be part of the language in the first place.

Granted most of my Haskell work is in boring line of business apps, so maybe partial application is more important in other fields.

Re:Readable Clojure by Silhouette on Wednesday May 24, 2017 @11:21PM (#14415093)
It's one of those things where you can take a simple tool and probably make something hideously complicated with it if you go too far, but in simple cases it's useful all over the place.

For example, I very often write functions that take an initial parameter representing some sort of customisable context and then further parameters that are the right types to use with some standard higher order function like a map, filter or fold. Partial application then supplies the context and gives back something ready to pass into that HOF.

Re:Readable Clojure by a-saleh on Thursday May 25, 2017 @02:47AM (#14415712)
If you were to get rid of curried functions everywhere, how would change the applicative pattern.

I just find the "plain_fn <$> weird_type <*> weird_type ..." e.t.c really convenient.

Re:Readable Clojure by michaelmrose on Thursday May 25, 2017 @12:02AM (#14415230)
I would rather chunks of functionality not be removed from tools to suit other peoples aesthetic sensibilities.
Re:Readable Clojure by allengeorge on Thursday May 25, 2017 @09:28AM (#14417125)
Not all features have equivalent upside (I.e. Some features have very limited upside and significant cost, in terms of maintainability etc.) When creating a codebase we should be conservative with the features we use - and this is all the article is arguing for.
Re:Readable Clojure by mercer on Thursday May 25, 2017 @11:31AM (#14417909)
I feel this way about the destructuring assignment and spread syntax in javascript, or at least a little bit.

It's incredibly convenient to use, but sometimes when I look at 'idiomatic' React code, in particular in the context of Redux, I can't help but feel it's a bit too much, especially when I look at the code through 'teacher' eyes, and especially when it's combined with JSX. And that's not even mentioning the arrow function variants, default parameters, and other ESNext goodies.

And yet I find it difficult to keep my hands off it, because it's just so damn convenient.

Re:Readable Clojure by daxfohl on Thursday May 25, 2017 @01:12PM (#14418607)
I believe I've heard it said: the most difficult thing when building a language is not deciding which features to add, but which features to leave out.
Re:Readable Clojure by allengeorge on Sunday May 28, 2017 @09:44AM (#14434350)
This is a pretty common maxim, and applies to any design exercise :)

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. "

-- Antoine de Saint-Exupery

Re:Readable Clojure by fnordsensei on Wednesday May 24, 2017 @11:51PM (#14415203)
Sometimes they have different characteristics even though they produce the same result. Such as when composing transducers, which has performance implications.
Re:Readable Clojure by rhinoceraptor on Wednesday May 24, 2017 @09:38PM (#14414750)
I use it a lot when writing functions with side-effects in JavaScript, as a sort of informal dependency injection. If I have a function that needs to do an HTTP request, I will curry it so that the outermost function of the service takes the HTTP service as its argument.
Re:Readable Clojure by adambard on Wednesday May 24, 2017 @07:18PM (#14414203)
I for one enthusiastically agree with the author's advice to use the `#()` syntax in place of `partial` and/or `comp`. It's just plain easier to parse, even for those who are familiar with higher-order functions but especially for those that aren't.
Re:Readable Clojure by nickfargo on Wednesday May 24, 2017 @08:06PM (#14414405)
That's interesting, because I find #() rather less easy to parse compared to (comp) or (partial) for otherwise equivalent expressions.

At a glance I know that (comp f g h) and its flat list of arguments expresses a simple function composition chain. Seeing a #(f (g (h %))) where (comp) will do makes me sift through more parens; more than that though, when (comp) is embraced as convention, a #() is an immediate cue that simple function composition is not what's being expressed, which draws me in necessarily to examine the particular structure of the #() body.

Re:Readable Clojure by jraines on Wednesday May 24, 2017 @08:56PM (#14414627)
A happy medium IMO is to give the function resulting from `partial` or `comp` a name in a let binding. If it takes one arg, great; if it doesn't then the #() form with the named fn inside still a little shorter & easier to parse. This is inline with the other advice that brevity isn't the main virtue for readability.
Re:Readable Clojure by bilboa on Wednesday May 24, 2017 @07:34PM (#14414279)
Exactly. The author wasn't advising against using higher order functions in general, just certain ones like comp and partial, which are easily replaced by anonymous functions. I.e. (comp a b) is the same as #(a (b %)), so why not use the latter if it's easier to understand. I don't completely agree with the author on this point, but I know he wasn't against higher order functions.
Re:Readable Clojure by lacampbell on Wednesday May 24, 2017 @08:04PM (#14414398)
Higher order functions separate clojure from other languages

I don't know if that's true anymore. HoF are becoming mainstream - and rightly so.

Java, C++, Python, C#, VB.NET, Javascript, PHP, Perl, Ruby.. they all have them.

Re:Readable Clojure by posterboy on Thursday May 25, 2017 @03:41AM (#14415900)
does C's qsort count?
Re:Readable Clojure by lacampbell on Thursday May 25, 2017 @07:48PM (#14420986)
I'd draw the line at that.

But every corporate programming language has lambdas you can pass around as data now.

Re:Readable Clojure by devin on Wednesday May 24, 2017 @09:54PM (#14414816)
-> and ->> are not equal to some->, cond->, etc.

Threading enhances readability so long as it is not overused.