What do beginners struggle with?

Good points, I think between lazy sequences and transducers there are things that transducers make more convoluted as well, and there isn’t a transducer for every lazy-seq function, and I think part of that is because they aren’t always all trivial to implement as a transducer, and sometimes they don’t all compose as easily together or you need to be aware of the transducing context.

I guess the question would be more what it would look like against a hybrid of eager sequence functions and transducers. For the cases of modeling infinity and such it is still a good point as too what that would look like, I don’t know if it would be better, but its an interesting thought.

Another thing, which I’ve seen sometimes as a criticism in Clojure, is that sequence functions were in the core namespace to begin with. If they had been in say a sequence namespace, you could have had another namespace named transducer or something like that. So you could have both with similar interfaces. I can’t remember why Clojire didn’t do that and choose to overload arity for transducers, when it did do it for reducers.

Anyways, to beginners reading, remember all things have trade offs and pros/cons, and I think lazy sequences over iterator style streams like Java and C#, over eager functions over transducers don’t necessarily have a clear winner, just different qualities that sometimes make one better than another. Like John said, lazy sequences do end up being a really nice default with a good balance between performance, flexibility and convenience, and there is an easy path towards performant and eager variants.

1 Like