Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The AirBNB JS style guide is kind of like a relic in time from the transition to ES6 etc. Leave it in the past. Their only argument for not supporting eg. "for-of" is because of "legacy" browsers not supporting it. Maybe a salient argument at the time of writing (these issue threads are nearly 10 years ago), but certainly not today.




It’s mostly the argument of a single guy (ljharb), who has very strong and weird opinions.

There were several extremely long and unproductive GitHub discussion with him posted to HN before, where he sent unsolicited and unwanted PRs to lots of projects that tanked performance by orders of magnitude and introduced tens of dependencies (he wrote himself), to ensure that projects would be backwards compatible with completely irrelevant targets they never supported in the first place (like Internet Explorer 1.3 under Windows 95 or something along those lines).

When projects did not want to take these contributions, he played his TC39 authority card, and when that did not help became more and more incoherent in his ramblings.

My take is that this guy actually wants to and thinks he is doing good, while actually having lost the plot a while ago.


very interesting thread

i used to be like ljharb, changing company/stack made me live in python for loops but then i miss composable operators ..


> Their only argument for not supporting eg. "for-of" is because of "legacy" browsers not supporting it.

Not really, their rational is written in the document I linked --

    Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side effects.

    // bad
    let sum = 0;
    for (let num of numbers) {
      sum += num;
    }
    sum === 15;

    // good
    let sum = 0;
    numbers.forEach((num) => {
      sum += num;
    });
    sum === 15;
Which is... ridiculous. None of this is actually immutable, as "sum" is constantly being modified. A real FP purist would be using "reduce" in the "good" example. Otherwise, forEach is not better than for-of in terms of readability or maintainability in any way.

In addition, I think an issue is that for a long time, when you use ESLint CLI to create a new config file, airbnb is the default option, which ends up making it used very widely, even after the config itself is in maintenance mode. They were only removed in 2024: https://github.com/eslint/create-config/pull/108


Their rationale is written here, May 21 2021 final comment on the closed issue from the creator themself. Even in 2021 this was a dubious argument to make given the browser landscape, and they are clearly just frustrated to be challenged on this topic. They think legacy browsers are forever and furthermore readability of .forEach() is better anyway:

> in the latest version of all browsers. Despite marketing, no browsers are "evergreen" according to the google analytics of major websites I've been able to review over the last couple years. (Nothing but safari will likely ever support PTC - which is not an optimization - so that's not really relevant to discuss) Performance isn't important, readability is.

ref: https://github.com/airbnb/javascript/issues/1122#issuecommen...


In the specific example, both have side effects... if you really wanted to avoid them, you'd use .reduce, and even then, depends on the amount of data. More often than not, if you're doing these kinds of things in JS on in-memory data, you're probably doing something wrong and have bigger concerns imo.

I say this as someone who loves JS since before The Good Parts book.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: