Comparing transducers and reducers
Both transducers and reducers, which were discussed in Chapter 3, Parallelization Using Reducers, are ways to improve the performance of computations performed over collections. While transducers are a generalization of data processing for multiple data sources, there are a few other subtle differences between transducers and reducers, which are described as follows:
- Transducers are implemented as part of the Clojure language in the
clojure.core
namespace. However, reducers must be explicitly included in a program, as they are implemented in theclojure.core.reducers
namespace. - Transducers only create a collection when producing the final result of a series of transformations. There are no intermediary collections required to store the results of a transformation that constitutes a transducer. On the other hand, reducers produce intermediate collections to store results, and only avoid the creation of unnecessary empty collections.
- Transducers deal with efficient...