Live data from Hacker News

Transducers.js: A JavaScript Library for Transformation of Data

jlongster.com

21–22 of 22 posts

Re: Transducers.js: A JavaScript Library for Transformation of Data

#21
post #3

I think the name "transducers" is a little unfortunate only in that it sounds very foreign to most coders, leading the concept to potentially be ignored. Don't let the name "transducers" or the relation to Clojure scare you off; you don't have to know either thing to understand how transducers can be useful.

The name is not at all unfortunate. But pandering to anti-intellectualism is extremely unfortunate. Irrational fear of new terminology is a major stumbling block to progress. There is a wealth of new things to discover that will require new modes of thinking, new concepts, and new terminology. If devs wish to remain stagnant in their knowledge and their practice, that's fine. But in doing so, there's no reason why th…

To anyone with hardware design experience transducers are hardware sensors. That meaning has been around for >60 years now.

So a lot of people are going to see 'transducers.js' and think this is a library for interfacing I2S or 1-wire sensors to Node, or something.

That's not anti-intellectualism, it's pointing out that the word already has an established meaning among engineers, and trying to redefine it is going to mislead a lot of people about what this library is trying to do.

Re: Transducers.js: A JavaScript Library for Transformation of Data

#22
Reading that article inspired me to write a little generic recursion library. The idea is that you'd write a 'map' function for each recursive data structure and then generate recursive functions from non-recursive functions using 'induction' and 'coinduction'.

    // induction : ((t (Fix t), Fix t -> r) -> t r, t r -> r) -> Fix t -> r
    function induction(map, f) {
        // g : Fix t -> r
        function g(x) {
            return f(map(x.unfold(), g));
        };
        return g;
    };
    
    // coinduction : ((t s, s -> Fix t) -> t (Fix t), s -> t s) -> s -> Fix t
    function coinduction(map, f) {
        // g : s -> Fix t
        function g(s) {
            return {
    	        unfold: function() {
    	            return map(f(s), g);
                }
            };
        };
        return g;
    };

    // fold : t (Fix t) -> Fix t
    function fold(w) {
        return {
            unfold: function() { return w; }
        };
    };
Post reply on HN