6 ms·
I like Clojure quite a bit more than Java, but some of these are unfair if you are comparing against modern Java. For instance, the sorting example can be simp
by kilink 11y ago
I like Clojure quite a bit more than Java, but some of these are unfair if you are comparing against modern Java.
For instance, the sorting example can be simplified:
Comparator<User> userOrdering = Comparator.comparing(User::isSubscription).thenComparing(User::getName);
// forward sort
Collections.sort(users, userOrdering);
// reverse sort
Collections.sort(users, userOrdering.reversed());
A lot less verbose than it's made out to be.
- codahale 11y agoWhile it’s definitely the case that there are more concise domain-specific examples, as you’ve pointed out, the article’s point stands: in Clojure, a Strategy is simply passing a function as an argument to another function.
- phamilton 11y agoThe caveat is perhaps that in Java 8, a Strategy is simply passing a function as an argument to another function too. I'd love to see patterns struck down as obsolete with Java language updates.
- TwoSheds 11y ago+ Finding or creating suitable functional interface for passing the function
- Dr_tldr 11y agoEvery "language comparison" between dominant ones and less popular ones (even implicitly) ends up being a little contrived, which is unfortunate because in general Clojure is the real deal.
- arsenerei 11y ago> Reverse sorting should keep subscripted users on top. Will userOrdering.reversed() account for this?