R.lt – are we that lazy?

I was browsing an old code of mine when I saw this line

const removeShortSentences = R.compose(
  R.lt(3), 
  R.length, 
  R.split(".")
)

I was surprised by how unreadable the piece with R.lt is, as all it does is to save a few characters.

The same logic without R.lt has much clearer intent:

const removeShortSentences = R.compose(
  x => x < 3, 
  R.length, 
  R.split(".")
)

In the above examples R is reference to Ramda, not Rambda. Because the value of these kind of functions is very low, they were never part of Rambda, but I had included them in Rambdax under the names of R.greater and R.less.

Still, when Rambdax hit 1.0.0 I was free to remove some methods that had little to no value and R.greater and R.less was among the victims.

My whole point is that it seems very suspicious to have such methods, that are replacing arrow functions of few characters. There are much more examples, but I will bring up just one – R.equalsToEmptyArray which is part of Ramda extensions. You can see the documentation of the method here.

Currently the team of Ramda is in process of moving to their first major bump, but I doubt that they will drop the methods R.gt, R.gte, R.lt and R.lte as they shouldn’t be there at first place.

My final words are that during the lifetime of Rambda, there were many request for inclusion of new methods, but not a single one for the group of R.lt. Which is just additional proof that we don’t need that kind of empty methods. Because imagine the look of the code reviewer face, when he see this jewel:

import { lt } from 'ramda'

export const isTooShort = lt(4)

Funny enough, just one day after this article was published, an interesting issue was open in Ramda where the question is why they keep these small functions. You can see the discussion following this link.

Advertisements

One thought on “R.lt – are we that lazy?

Comments are closed.