←back to thread

295 points todsacerdoti | 4 comments | | HN request time: 0s | source
Show context
noosphr ◴[] No.45949148[source]
I see this as an absolute win. The state of micro dependencies of js was a nightmare that only happened because a lot of undereducated developers flooded the market to get that sweet faang money.

Now that both have dried up I hope we can close the vault door on js and have people learn how to code again.

replies(5): >>45949409 #>>45949466 #>>45949548 #>>45949614 #>>45952603 #
SchemaLoad ◴[] No.45949466[source]
The best outcome was things like jquery and then lodash where a whole collection of small util functions get rolled in to one package.
replies(1): >>45950575 #
josephg ◴[] No.45950575[source]
Oh god, without tree shaking, lodash is such a blight.

I've seen so many tiny packages pull in lodash for some little utility method so many times. 400 bytes of source code becomes 70kb in an instant, all because someone doesn't know how to filter items in an array. And I've also seen plenty of projects which somehow include multiple copies of lodash in their dependency tree.

Its such a common junior move. Ugh.

Experienced engineers know how to pull in just what they need from lodash. But ... most experienced engineers I know & work with don't bother with it. Javascript includes almost everything you need these days anyway. And when it doesn't, the kind of helper functions lodash provides are usually about 4 lines of code to write yourself. Much better to do that manually rather than pull in some 70kb dependency.

replies(4): >>45950988 #>>45951555 #>>45951828 #>>45951926 #
SchemaLoad ◴[] No.45950988[source]
I agree the JS standard library includes most of the stuff you need these days, rendering jquery and half of lodash irrelevant now. But there's still a lot of useful utilities in lodash, and potentially a new project could curate a collection of new, still relevant utilities.
replies(1): >>45951136 #
josephg ◴[] No.45951136[source]
Can you give some examples? I’ve written js / ts for 10-15 years and I’ve never reached for lodash in my life.
replies(1): >>45951278 #
1. epicureanideal ◴[] No.45951278[source]
_.any, some, every, keyBy.
replies(1): >>45951522 #
2. skrebbel ◴[] No.45951522[source]
_.any doesn’t seem to exist.

Some and every are also in JS (with the same names even!).

keyBy is just Array.map -> Object.fromEntries

replies(2): >>45952204 #>>45952465 #
3. ◴[] No.45952204[source]
4. dsego ◴[] No.45952465[source]
It was more useful before when browsers didn't support array.map and fromEntries. That's the origin of all these libraries, but browsers caught up. Things like keyBy, groupBy, debounce, uniqueId, and some others, are still useful.