Live data from Hacker News

Modern Node.js Patterns

kashw1n.com

31–40 of 448 posts

Re: Modern Node.js Patterns

#31
Matteo Collina says that the node fetch under the hood is the fetch from the undici node client [0]; and that also, because it needs to generate WHATWG web streams, it is inherently slower than the alternative — undici request [1].

[0] - https://www.youtube.com/watch?v=cIyiDDts0lo

[1] - https://blog.platformatic.dev/http-fundamentals-understandin...

Re: Modern Node.js Patterns

#32
I've been away from the node ecosystem for quite some time. A lot of really neat stuff in here.

Hard to imagine that this wasn't due to competition in the space. With Deno and Bun trying to eat up some of the Node market in the past several years, seems like the Node dev got kicked into high gear.

Re: Modern Node.js Patterns

#33

Earlier quoted context omitted.

One of the core things Node.js got right was streams. (Anyone remember substack’s presentation “Thinking in streams”?) It’s good to see them continue to push that forward.

Why? Why is a stream better than an array? Why is the concept of a realtime loop and for looping through a buffer not sufficient?

Streams have backpressure, making it possible for downstream to tell upstream to throttle their streaming. This avoids many issues related to queuing theory.

That also happens automatically, it is abstracted away from the users of streams.

Re: Modern Node.js Patterns

#34
Some good stuff in here. I had no idea about AsyncIterators before this article, but I've done similar things with generators in the past.

A couple of things seem borrowed from Bun (unless I didn't know about them before?). This seems to be the silver lining from the constant churn in the Javascript ecosystem

Re: Modern Node.js Patterns

#35

Earlier quoted context omitted.

Architecture astronaut is a term I hadn't heard but can appreciate. However I fail to see that here. It's a fair overview of newish Node features... Haven't touched Node in a few years so kinda useful.

It's a good one with some history and growing public knowledge now. I'd encourage a deep dive, it goes all the way back to at least CPP and small talk. While I can see some arguments for "we need good tools like Node so that we can more easily write actual applications that solve actual business problems", this seems to me to be the opposite. All I should ever have to do to import a bunch of functions from a file is…

Did you read the article? Your comments feel entirely disconnected from its contents - mostly low level piece or things that can replace libraries you probably used anyway

Re: Modern Node.js Patterns

#36

Earlier quoted context omitted.

ESM is literally a standard. You can rant all you want, but you'll adopt it anyway.

Not really, from everything I can see, authors are basically forced to ship both, so it’s just another schism. Libraries that stopped shipping CJS we just never adopted, because we’re not dropping mature tech for pointless junior attitudes like this. No idea why you think otherwise, I’m over here actually shipping.

[deleted]

Re: Modern Node.js Patterns

#37

Earlier quoted context omitted.

One of the core things Node.js got right was streams. (Anyone remember substack’s presentation “Thinking in streams”?) It’s good to see them continue to push that forward.

Why? Why is a stream better than an array? Why is the concept of a realtime loop and for looping through a buffer not sufficient?

Why is an array better than pointer arithmetic and manually managing memory? Because it's a higher level abstraction that frees you from the low level plumbing and gives you new ways to think and code.

Streams can be piped, split, joined etc. You can do all these things with arrays but you'll be doing a lot of bookkeeping yourself. Also streams have backpressure signalling

Re: Modern Node.js Patterns

#38
I think slowly Node is shaping up to offer strong competition to Bun.js, Deno, etc. such that there is little reason to switch. The mutual competition is good for the continued development of JS runtimes

Re: Modern Node.js Patterns

#40
One thing you should add to section 10 is encouraging people to pass `cause` option while throwing new Error instances. For example

new Error("something bad happened", {cause:innerException})

Post reply on HN