Rich hickey on transducers

17 views
Skip to first unread message

Haim Ashkeanzi

unread,
Sep 20, 2014, 6:48:48 AM9/20/14
to clojure...@googlegroups.com
Hi all,

I have a lot of articles on my reading list about transducers, but as you may know, work and kids leaves you much less time than you want to invest in educating yourself :)

Then came along this talk (which is amazing that the video is released only a day after it was given) and now I have at least some idea what they are for :)


Enjoy

--
Haim

Daniel Szmulewicz

unread,
Sep 20, 2014, 10:06:34 AM9/20/14
to Haim Ashkeanzi, clojure...@googlegroups.com
Yes! I saw the talk yesterday night, as well as Nada Amin's and Joe Armstrong's. Which is why I didn't get up in the morning :-)

Transducers are easier to understand than Rich's talk. What I mean by that is that Rich devotes a substantial part of the talk to explain the concepts of transducers in terms of types. Why does he do that if Clojure doesn't even have types? Because when you're talking at an elite conference like Strangeloop, where half of the audience come from academia, you are obliged to explain *any* CS concept in terms of types, because they won't have it any other way.

In practical tems, map, filter and all their friends are now not only applicable to collections, but any other *thing*. The other *things* could be a stream, an observable or a channel. These are the examples that Rich referred to, but the idea is that the *thing* is abstracted away from the operations.

I've been using transducers in the code for an upcoming talk on Om. In that talk, I plan to live code a prototype that retrieves and displays the RSVP'ed users for the current meetup. Here's how it look like:

https://github.com/danielsz/om-meetup/blob/master/dev/user.clj

The transducer is called results-xform and is used to process the results from a meetup API call.
It is defined independently, on its own, just a series of steps that can be reused anywhere if need be.

From my perspective, transducers promise to be useful with core.async channels, too.

--
Daniel Szmulewicz
http://about.me/daniel.szmulewicz
> --
> You received this message because you are subscribed to the Google Groups "Clojure Israel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure-israe...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Haim Ashkeanzi

unread,
Sep 20, 2014, 12:58:49 PM9/20/14
to Daniel Szmulewicz, clojure...@googlegroups.com
Actually I really liked the theoretical part (I didn’t have time to see it all though). Especially the reference to scala :). 

I did see practical usage of transducers in David Nolan’s webinar a couple of weeks ago, but I was missing the logic behind them. It kind of set the background for me.

While we’re on the subject, if someone is willing to spend a few dollars a month I recommend subscribing to Tim Baldridge's clojure tutorials. It’s definitely not beginner material but it’s really worth the money and the time.
--
Haim

Daniel Szmulewicz

unread,
Sep 20, 2014, 5:26:06 PM9/20/14
to Haim Ashkeanzi, clojure...@googlegroups.com
Thanks for the Tim Baldridge recommendation!


RacketCon was organized in the vicinity of StrangeLoop, and you can watch a live stream here: 


It seems it will remain available as video recording.

Tzach Livyatan

unread,
Sep 21, 2014, 4:31:04 AM9/21/14
to Daniel Szmulewicz, Haim Ashkeanzi, clojure...@googlegroups.com
On Sat, Sep 20, 2014 at 5:06 PM, Daniel Szmulewicz <daniel.s...@gmail.com> wrote:
Yes! I saw the talk yesterday night, as well as Nada Amin's and Joe Armstrong's. Which is why I didn't get up in the morning :-)

Transducers are easier to understand than Rich's talk. What I mean by that is that Rich devotes a substantial part of the talk to explain the concepts of transducers in terms of types. Why does he do that if Clojure doesn't even have types? Because when you're talking at an elite conference like Strangeloop, where half of the audience come from academia, you are obliged to explain *any* CS concept in terms of types, because they won't have it any other way.

In practical tems, map, filter and all their friends are now not only applicable to collections, but any other *thing*. The other *things* could be a stream, an observable or a channel. These are the examples that Rich referred to, but the idea is that the *thing* is abstracted away from the operations.
More than working on other inputs, it allow expression of something new.
(def x (map inc))
(into [] x (range 17))

Such x was not available without transducers.
Now you can use it, combine it with others transducers etc.

(full disclosure: I haven't see the video yet, and I'm not sure I fully understand the value of transducers)


I've been using transducers in the code for an upcoming talk on Om. In that talk, I plan to live code a prototype that retrieves and displays the RSVP'ed users for the current meetup. Here's how it look like:

https://github.com/danielsz/om-meetup/blob/master/dev/user.clj

The transducer is called results-xform and is used to process the results from a meetup API call.
It is defined independently, on its own, just a series of steps that can be reused anywhere if need be.

From my perspective, transducers promise to be useful with core.async channels, too.

--
Daniel Szmulewicz
http://about.me/daniel.szmulewicz

On 20/09/2014, at 13:48, Haim Ashkeanzi wrote:

> Hi all,
>
> I have a lot of articles on my reading list about transducers, but as you may know, work and kids leaves you much less time than you want to invest in educating yourself :)
>
> Then came along this talk (which is amazing that the video is released only a day after it was given) and now I have at least some idea what they are for :)
>
> https://www.youtube.com/watch?v=6mTbuzafcII
>
> Enjoy
>
> --
> Haim
>
> --
> You received this message because you are subscribed to the Google Groups "Clojure Israel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure-israe...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Clojure Israel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-israe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards 
@TzachL

Tzach Livyatan

unread,
Sep 23, 2014, 4:03:52 PM9/23/14
to Daniel Szmulewicz, Haim Ashkeanzi, clojure...@googlegroups.com
I found the following useful
https://gist.github.com/ptaoussanis/e537bd8ffdc943bbbce7#file-transducers-clj

The similarity between transducers and Ring middleware helped me.
--
Regards 
@TzachL

Daniel Szmulewicz

unread,
Sep 23, 2014, 4:05:29 PM9/23/14
to Tzach Livyatan, Haim Ashkenazi, clojure...@googlegroups.com

Haim Ashkeanzi

unread,
Sep 24, 2014, 12:53:38 AM9/24/14
to Daniel Szmulewicz, Tzach Livyatan, clojure...@googlegroups.com
And now for something completely different (sorry for hijacking the thread), 

Daniel congrats on om-mode. I’ll try it next time I’ll use om (which sadly might not be so soon :( ).

--
Haim

Tzach Livyatan

unread,
Sep 24, 2014, 6:37:17 AM9/24/14
to Haim Ashkeanzi, Daniel Szmulewicz, clojure...@googlegroups.com
On Wed, Sep 24, 2014 at 7:53 AM, Haim Ashkeanzi <ha...@babysnakes.org> wrote:
And now for something completely different (sorry for hijacking the thread), 

Daniel congrats on om-mode. I’ll try it next time I’ll use om (which sadly might not be so soon :( ).
Nice work indeed!

 


On Tue, Sep 23, 2014 at 11:05 PM, Daniel Szmulewicz <daniel.s...@gmail.com> wrote:

--
Daniel Szmulewicz




On Sep 23, 2014, at 23:03, Tzach Livyatan <tzach.l...@gmail.com> wrote:

I created my own trivial transducer to help me better understand the transducers composition order



--
Regards 
@TzachL

Daniel Szmulewicz

unread,
Sep 24, 2014, 9:36:51 AM9/24/14
to Tzach Livyatan, Haim Ashkeanzi, clojure...@googlegroups.com
Awww, you’re too kind. Thanks!

Daniel Szmulewicz

unread,
Oct 4, 2014, 2:20:06 AM10/4/14
to clojure...@googlegroups.com
Still on the subject of transducers, there's a really good talk by Christophe Grand that explains the concepts from first principles. 

https://www.youtube.com/watch?v=R-e0jnlIMto

I was impressed. (To follow along you'd need to brush up some French).
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure-israel+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Clojure Israel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-israel+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards 
@TzachL



--
Regards 
@TzachL

Noam Ben-Ari

unread,
Oct 28, 2014, 3:30:38 AM10/28/14
to clojure...@googlegroups.com
I had to watch Rich twice to grok it (plus one blog), but it finally made sense, so much that I asked myself how come Ruby doesn't have it.

I would sum my understanding up as this:
1 - map, filter and friends can now be composed flexibly into a single function
2 - you can use that function to process your collection (of anything, including channels and whatnot)
3 - the new function (the transducer) is efficient, in the sense that it doesn't simply run the composed functions one-by-one on the collection, but it does all the processing in one pass over the collection.

Haim Ashkeanzi

unread,
Oct 28, 2014, 4:19:48 AM10/28/14
to Noam Ben-Ari, clojure...@googlegroups.com
Hey Noam,

Welcome to this meetup. Hope to see you in the meetings.

--
You received this message because you are subscribed to the Google Groups "Clojure Israel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-israe...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Haim

Noam Ben-Ari

unread,
Oct 28, 2014, 5:37:32 AM10/28/14
to clojure...@googlegroups.com, nbe...@gmail.com
Thanks Haim, I will come :)
Reply all
Reply to author
Forward
0 new messages