Hacker News new | ask | show | jobs
by talkingtab 58 days ago
When I first read about transducers I was wowed. For example, if I want to walk all the files on my computer and find the duplicate photos in the whole file system, transducers provide a conveyor belt approach. And whether there are saving in terms of memory or anything, maybe. But the big win for me was to think about the problem as pipes instead of loops. And then if you could add conditionals and branches it is even easier to think about. At least I find it so.

I tried to implement transducers in JavaScript using yield and generators and that worked. That was before async/await, but now you can just `await readdir("/"); I'm unclear as to whether transducers offer significant advantages over async/await?

[[Note: I have a personal grudge against Java and since Clojure requires Java I just find myself unable to go down that road]]

3 comments

I think, like with the rest of Clojure, none of this is "revolutionary" in itself. Clojure doesn't try to be revolutionary, it's a bunch of existing ideas implemented together in a cohesive whole that can be used to build real complex systems (Rich Hickey said so himself).

Transducers are not new or revolutionary. The ideas have been around for a long time, I still remember using SERIES in Common Lisp to get more performance without creating intermediate data structures. You can probably decompose transducers into several ideas put together, and each one of those can be reproduced in another way in another language. What makes them nice in Clojure is, like the rest of Clojure, the fact that they form a cohesive whole with the rest of the language and the standard library.

https://series.sourceforge.net/ this is the SERIES package you're referring to ? sorry, mostly a CL newb here, it's the first time I read about it
Yes, this is the one I wrote about. I used it quite a bit a long time ago to get more performance. I remember vaguely that the performance was indeed there, but the package wasn't that easy to use and errors were hard to debug.
You could always try ClojureScript
I believe at one point you could run ClojureScript without Java, but either I was wrong or that version is no longer available. As far as I can tell both Clojure and ClojureScript require Java as of now.

I was hoping that at some point one of those would get to be self compiling and so would not require Java, but that seems not to be the case?

Transducers don't really solve the same problem as async/await.