Transducers now available for Java/JavaScript/Ruby
cognitect-labs.github.io
cognitect-labs.github.io
Playing the violin takes hard earned, tactile expertise to the specific end of being able to pay the violin (not required: the ability to read music, compose original pieces, or know how to physically construct a violin).
Separating implementation details from performant, coherent, composible abstractions is not just another skill to specialize in, not just another programing language specialization to acquire- it's the entire pursuit of our industry.
In go you will have to replicate to logic every single time. I have not used much, but the fact that I cant even use generic map/filter things make me not want to try it. Even when I first learned programming (in C) I was trying to figure out how not to write for (int x=0;x==5;x++) again and again. I dont really want to go back to that.
To me the most interesting aspect of the Ruby implementation is the use of pseudo macros that meta-program most of the implementation.
Introducing a Transducable module would also make sense in the OOP perspective. Replacing Transducer.transduce(transducer, ...) calls with transducer.transduce(...), same with Transducer.compose
filter(lambda x: x%2==0, xrange(10))
Is this basically the same concept?Unlike those traditional functions, however, transducer versions are composable. So I can put a whole bunch of maps, reducers, and filters in a row, and assign that composition to a variable. Then I can apply that composition to any type of collection and know that it only requires one pass.
EDIT: _part_ of the appeal. The other is concisely describing things like takeWhile in a way that's both polymorphic and doesn't require multiple implementations. Good refactor motivation in general, happens to have the above property, which is good.