Hacker News new | ask | show | jobs
by erikpukinskis 3245 days ago
The first is more readable. It uses more common tokens, and is therefore more easily recognizable. You're confusing brevity for readability.

I don't understand your scope preference. These seem the same to me:

  family.findEldestFirst(person => this.isRoyal() && person.name == "Kate")
vs

  family.findEldestFirst(isPrincess.bind(family))

  function isPrincess(person) {
    return this.isRoyal() && person.name == "Kate"
  }
11 tokens vs 16, same order of magnitude. Second one has an explicit return, which is good for readability. Shorter lines, to which is better for readability. Also relies on fewer control structures, which is good for readability. No need to understand the =>/-> distinction, which is very subtle and beginners won't know about it. To me I'd rather just learn functions and closures and be done with it.

... And frankly I think using "this" that way in either case is not a win. I'd rather make family its own argument to isPrincess:

  family.findEldestFirst(isPrincess.bind(null, family))

  function isPrincess(family, person) {
    return family.isRoyal() && person.name == "Kate"
  }
Mm. Dat explicitness. Anyway... I think I'm not understanding you. How is this forcing your hand in terms of where you bind the scope?

Franky, my sense is that the people who like ES6 and promises are people who are just allergic to writing named functions. Named functions make callback hell go away, and they solve all the problems these arrow functions do. Somehow people think it's bad form to define lots of functions. But defining functions is my job. :) It doesn't bother me.

My sense is it's just Rubyists who miss Ruby and think "more Rubyish" is better. I sympathize because my path was BASIC -> PHP -> C# -> Ruby -> JavaScript. But I think it is a mistake to try to bring your old idioms to a new language.

... and if I wanted to reduce character count above all else, I'd just go use PERL.