News for hackers. Stuff that matters.
Re:Ask HN: Was ES6 a Bust? by schwartzworld on Sunday January 03, 2021 @07:41PM (#25626765)
My team uses es6 features every day, and I can't imagine going back to writing es5 flavored JS.

Generators/iterators are just waiting for a use case. They aren't that useful in React-land, but I actually think there is a lot of potential there.

But also the features you said you see used most often are amazing. Not a day goes by at work when I don't use all of them except classes, but I use them more at home.

You should judge those features by the code that you aren't seeing written. Async / await is do clean and simple to write compared to endless callbacks. Arrow functions save lots of code to handle inconsistent `this` behavior. These are major fixes to a language that is often described as broken.

The one big downside is compatability with older browsers. The Redux team may be hesitant to use new features that require transpiling or polyfills, but I'll wager most code that consumes redux is written using those features.

Re:Ask HN: Was ES6 a Bust? by jfengel on Monday January 04, 2021 @12:57PM (#25635225)
In React land, generators are the basis of Redux sagas. I'm still on the fence about when sagas become worth the weight, but a lot of people are using them. (In the recommended style, a simple fetch call with sagas requires more than a dozen lines of code spread over several files. Which is a pain, but it integrates nicely with the Redux framework if you're using it.)

Generators are also really nice for writing parsers and other tree-walking operations. Rather than passing in visitors or producing an entire tree, it's very easy to yield an intermediate result and then keep going. I don't see it used all that much (I believe in part because people don't write all that many parsers), but they're actually a pretty good way to get a handle on generator writing.

Re:Ask HN: Was ES6 a Bust? by schwartzworld on Monday January 04, 2021 @03:55PM (#25637834)
I didn't know that about sagas. I'm not a redux guy, so I don't really know any of the patterns.
Re:Ask HN: Was ES6 a Bust? by jfengel on Tuesday January 05, 2021 @09:33AM (#25645871)
If you're curious:

https://github.com/redux-saga/redux-saga

As I said, I'm on the fence. Redux itself is for programs that get large enough, and interconnected enough, that you want a central place to manage global state. You add in sagas when you want to grow that to include all side effects.

It is really cool to use its debugger and look at every message that got passed, and how that changes the global state. But adding in the message passing system is really heavy: you have to connect the component to it, AND create an action for both the request AND the response, AND put the code in a separate "reducer", AND then the whole saga middleware magic, AND several other things.

So... keep it in the back of your mind. If nothing else, it's pretty cool to use generators for something.