News for hackers. Stuff that matters.
Re:Bun v0.5 by nequo on Wednesday January 18, 2023 @11:10PM (#34436602)
Hi Jarred, I am curious about your insight into the source of Bun's performance advantage over Node.js. The Bun website[1] writes this:

  Why is Bun fast?

  ... Zig's low-level control over memory and lack of hidden control flow makes it much simpler to write fast software. ...
Is your sense also that this is the root cause of Bun's outstanding speed? Node.js is written in C++ (although not primarily) which also requires low-level control over memory.

Is there something about C++ that makes it less well-suited than Zig for what Bun does?

Or is the problem with Node.js that it relies too much on JavaScript rather than C++ in hot paths?[2]

[1] https://bun.sh/

[2] https://github.com/nodejs/node

Re:Bun v0.5 by nonethewiser on Thursday January 19, 2023 @12:38AM (#34437079)
This is a great question, hope he answers.
Re:Bun v0.5 by culi on Thursday January 19, 2023 @01:16AM (#34437276)
Those benchmarks may not actually hold up to independent analysis:

https://medium.com/deno-the-complete-reference/node-js-vs-de...

Re:Bun v0.5 by Jarred on Thursday January 19, 2023 @01:57AM (#34437470)
Two things about the linked benchmark:

1) That benchmark appears to be bottlenecked by the HTTP client — that’s why the numbers are so close for each runtime. Effectively, it is benchmarking the http client and not the http server.

The benchmarking tool has to be at least as fast the server and it needs to support HTTP keep alive. That means popular Node.js-based benchmarking tools like autocannon don’t produce useful results in benchmarks like these

Instead, a tool like oha or wrk or bombardier is better

2) That benchmark is not using the ReactDOM server build for Bun's runtime, which is used in Bun's benchmark and is part of the next release of react-dom.

PR: https://github.com/facebook/react/pull/25597#issuecomment-13...

Source of Bun's homepage benchmark: https://github.com/oven-sh/bun/blob/9ef33312b1b199931c29c182...

Re:Bun v0.5 by culi on Thursday January 19, 2023 @11:55AM (#34442526)
Thanks for the response. If you haven't already, I'd hit up the author as they've done and continue to regularly do similar benchmarks
Re:Bun v0.5 by hiccuphippo on Thursday January 19, 2023 @10:08AM (#34441077)
He has an answer in this talk around the 11:30 mark: https://youtu.be/eF48Ar-JjT8&t=690