News for hackers. Stuff that matters.
Re:Show HN: Rambda – Faster alternative to Ramda in just 10kB by self_refactor on Thursday June 08, 2017 @03:51AM (#14512627)
Partial paste from https://survivejs.com/blog/rambda-interview/#how-does-rambda... ---

The main reason for the better performance is that Rambda methods only need to take care for currying and execution, while Ramda methods cover more use cases. Therefore Ramda have more elaborate boilerplate around the actual execution, which results in slower performance.

We can see an illustration of that in the code of `find` method of Ramda and Rambda.

Ramda:

var _curry2 = require('./internal/_curry2');

var _dispatchable = require('./internal/_dispatchable');

var _xfind = require('./internal/_xfind');

module.exports = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) {

  var idx = 0;

  var len = list.length;

  while (idx < len) {

    if (fn(list[idx])) {

      return list[idx];

    }

    idx += 1;

  }
}));

Rambda:

function find(fn, arr){

  if (arr === undefined) {

    return holder => find(fn, holder)

  }

  return arr.find(fn)
}

There are no comments on this comment yet.