7 ms·
Clojure 1.5
- manaskarekar 14y agoReducers look interesting! The linked blog post by Rich hickey is an interesting read: http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html http://clojure.com/blog/2012/05/08/reducers-a-library-and-mo...
- ABS 14y agohere is the video of Rich's session on Reducers from EuroClojure 2012 http://vimeo.com/45561411 http://vimeo.com/45561411
- nialo 14y agoMy apologies for the slightly dumb question, and perhaps this is the wrong place to ask, but: These sound like a really good thing, but what if I want to use map and not reduce? Is Clojure smart enough to understand that some other function not named reduce should be transformed the same way?
- chongli 14y agoGo ahead and use map (just make sure you use the one from the clojure.core.reducers namespace). The reducers library provides implementations for many functions including map, mapcat, filter, flatten, take-while etc.
- chc 14y agoIt's not intelligently transforming your functions — it's providing alternate functions. The clojure.core.reducers namespace includes reducer-based functions named map, reduce, filter, etc. and you can pick and choose any of them you like. Just list the ones you want in your ns form like you would with any other library.
- alexott 14y agoclojure.core.reducers namespace provides implementation for many functions: map, flatten, filter, etc.
- jballanc 14y agoThe brilliance of the reducers library is that map is implemented in terms of reduce. Namely, mapping a->b in a collection is the same as reducing the collection (starting with an empty collection) by appending the converted form a->b to the accumulated collection.
- pbiggar 14y agoThe conditional threading macros are nice. I've been using them from clojure.core.incubator for a while as -?> and -?>>. Anyone know why the name change?
- cgrand-net 14y ago? in Clojure hints to predicates and boolean contexts while -?> just checks for nil.
- graue 14y agoLooks like the equivalents of `-?>` and `-?>>` are now `some->` and `some->>`, is that right? Perhaps the name change is meant to avoid confusion now that there are multiple variants, i.e. also `cond->` and `cond->>`, which are different. It also occurs to me that threading through `some->` and `some->>` is kind of like doing computations in the Maybe monad in Haskell.
- aaroniba 14y agoI've been using Swiss Arrows. https://github.com/rplevy/swiss-arrows https://github.com/rplevy/swiss-arrows
- jashmenn 14y agoShameless self plug: If you're interested in keeping up with clojure news, I recently started a clojure newsletter where we cover this sort of thing: http://defnewsletter.com http://defnewsletter.com
- manishsharan 14y agoHere is an idea for you : instead of news ( which is nice but not of urgent concern) , could you send out something like a another list "A drip of Javascript" does( not mine -- I am just a grateful subscriber). Having weekly cool clojure lessons would be nice.
- joshuacc 14y agoThanks for mentioning A Drip of JavaScript. I just noticed a bunch of new subscriptions come in at once, and I think that your comment is what triggered them. :-)
- jashmenn 14y agoThis is a great idea. One of the things we want to focus on is cool / useful code projects and how to grok advanced features (monads, ML, async io, etc). It would probably be better to pitch that our angle is code-heavy rather than news-heavy. Thanks for this feedback. Also, A drip of Javascript is really cool. I just subscribed.
- eric-hu 14y agoStatus Code, Javascript Weekly, and Ruby Weekly have similar layouts. They might be worth checking out for curating-inspiration as well. Both Javascript weekly and Ruby weekly periodically cover idioms of their respective languages, I like those. Ruby Weekly seems to have more posts about code refactoring and style, which I also appreciate.
- Nican 14y agoThere is already newsletter called "Clojure Gazette" http://us4.campaign-archive2.com/home/?u=a33b5228d1b5bf2e0c68a83f4&id=4c2b86e9f4 http://us4.campaign-archive2.com/home/?u=a33b5228d1b5bf2e0c6... Maybe you two can look what there is common into one news source?
- JeanPierre 14y agoThere's a lot of new small improvements in this update which are great for Clojure users, but the fundamental difference between 1.4 and 1.5 is the reducer library which was implemented. It's added mostly for performance reasons: By using this library, you will utilize Fork/Join in Java, but with a functional interface instead of the "gory" one. Very interesting, because the complexity of a typical `(reduce (map ...))` won't change, and you're suddenly utilizing all the cores on your computer. Rich Hickey had a talk about the new Reducers library[1], and I'd recommend you to see it, as it gives you a good understanding of how it works (and why it was implemented that way). Another slightly interesting thing is the sudden enhancement to read-eval and EDN[2]. That's mainly because of the rough weather Ruby/Rubygems was in with the YAML-exploits, which caused a heated discussion on how the Clojure reader should act by default[3][4]. [1]: http://www.infoq.com/presentations/Clojure-Reducers http://www.infoq.com/presentations/Clojure-Reducers [2]: https://github.com/clojure/clojure/blob/master/changes.md#212-new-edn-reader-improvements-to-read-eval https://github.com/clojure/clojure/blob/master/changes.md#21... [3]: http://dev.clojure.org/jira/browse/CLJ-1153 http://dev.clojure.org/jira/browse/CLJ-1153 [4]: https://groups.google.com/d/topic/clojure-dev/zG90eRnbbJQ/discussion https://groups.google.com/d/topic/clojure-dev/zG90eRnbbJQ/di...
- swannodette 14y agoOne my favorite features that came out of reducers - short circuiting reduce! (reduce (fn [a b] (if (> a 100) (reduced a) (+ a b))) (range 100000)) => 105 I've often had to use loop/recur instead of reduce because you could not short circuit. No longer.
- malkia 14y agoThis is so beautiful, like recur's blessing in disguise.
- invalidOrTaken 14y agoYES, I was hunting around for this in 1.4, happy to see it's arrived.
- k0t0n0 14y ago
- nivertech 14y agoHow do I upgrade just 'lein repl' to use Clojure 1.5? [bin]$ lein version Leiningen 2.0.0 on Java 1.7.0_15 Java HotSpot(TM) Client VM [bin]$ lein repl nREPL server started on port 41384 REPL-y 0.1.9 Clojure 1.4.0 I understand that Clojure is just a jar dependency, just need to find where lein's dependencies specified... For a new project I would have specified Clojure 1.5 in defproject, but for REPL?
- JeanPierre 14y agoThis is currently not possible with lein (bug/enhancement), but will be with 2.1.0. See #966[1] for details. As a workaround, any project dependent of Clojure 1.5.0 will utilize that for the repl. So when in a project using 1.5.0, the repl will be 1.5.0 too. [1]: https://github.com/technomancy/leiningen/issues/966 https://github.com/technomancy/leiningen/issues/966
- jballanc 14y agoI've seen many, many attempts at "automatic parallelization" over the years. Clojure 1.5's reducers are the first approach I've seen that I think might actually work!
- vemv 14y agoThe work-stealing part can be understood as automatic, but Java's FJ is responsible for that AFAICT. Having to state "do this in parallel" (by using clojure.core.reducers fns instead of their clojure.core counterparts) is not automatic but explicit parallelization. I believe that the idea of a compiler that will infer the parallelizable parts of your code crosses the limits of computability.
- jballanc 14y agoI view the need to use the reducer functions in place of the "vanilla" versions similarly to a compiler flag (you could stick it in the namespace definition and not worry about it for the rest of the code). In my mind, what makes this "automatic" is that in at least 80% of the cases, that's the only thing you would need to do. All of your code using map, reduce, and friends can remain mostly unchanged. Before reducers, I'd have said that Obj-C's blocks with GCD was the closest thing to "automatic parallelization" (in that you could get concurrent execution without the need to handle explicit concurrency primitives). The problem, of course, is that writing C/Obj-C with closures is a non-trivial shift in design. With Clojure, the way that code is currently written is already well positioned to benefit from reducers.
- Confusion 14y agoThe functions are in a separate namespace at the moment, but perhaps the ultimate plan is to make them the default? Does anyone know whether that is the plan? I suppose there should always be an escape hatch to explicitly choose either of the two for a specific piece of code, but the default could be "JVM, please choose what's best for my code".
- djpowell 14y ago
- douglasisshiny 14y agoPerhaps this isn't the best place: I eventually want to move on beyond ruby and java and try out a functional language. Clojure, Scala and Haskell all seem interesting. Haskell because it's pure functional. Scala and Clojure because they're functional and on the JVM, and out of the two, Clojure. So it's between clojure and haskell in my mind. Haskell has a great tutorial book/website (http://learnyouahaskell.com/ http://learnyouahaskell.com/). Is there a great resource like this for clojure? (obviously there are many books, but what's the best, and ideally, does it have a free online version that I can try out before buying)
- columbo 14y agoThis is good if you are into roguelikes: http://stevelosh.com/blog/2012/07/caves-of-clojure-01/ http://stevelosh.com/blog/2012/07/caves-of-clojure-01/ All parts: http://stevelosh.com/blog/ http://stevelosh.com/blog/
- douglasisshiny 14y agoThank you!
- dktbs 14y agoThis looks great, thanks!
- dimovich 14y agoThanks. Just completed peepcode's Clojure screencast based on https://github.com/technomancy/mire https://github.com/technomancy/mire This should be a nice follow-up.
- tel 14y agoFeel free to reach out to me for more information about Haskell (or Clojure). I think they're both fantastic languages to learn and I have a lot of experience in each.
- douglasisshiny 14y ago
- adestefan 14y agoThat's it I really need to buckle down and learn clojure. I just got the perfect project today since I have to use a certain Java only library and then do some text processing on the copious results of that library's processing.
- jsilva 14y agoI would like to to know if clojure has big memory footprint. Since is doing dynamic class generation and so on. I did find something[1] on stackoverflow but i would like some more info from real production usage. Thank you all. [1]http://stackoverflow.com/questions/4058430/how-well-does-clojure-perform-when-it-comes-to-memory-footprint http://stackoverflow.com/questions/4058430/how-well-does-clo...