News for hackers. Stuff that matters.
Re:Bun v1.0.0 by zx2c4 on Friday September 08, 2023 @11:12AM (#37434552)
I would be interested to learn from somebody with experience using both Bun and Deno: which one is actually the more compelling Node successor? Bun's website makes some impressive performance claims over Deno. Are these true in practice? And if so, why? Seems like Deno also has similar goals. Also, are there large philosophical differences between the two projects? Like Bun tries to reimplement the kitchen sink but Deno wants a new post-Node way of doing things? (Just guessing, no idea if that's true.)

Any seasoned users with time spent on both?

Re:Bun v1.0.0 by TheAceOfHearts on Friday September 08, 2023 @11:26AM (#37434813)
These tools are way too young for anyone to have actually spent a lot of time using them.

Bun is bundling everything and making it really fast, while also striving to maintain as much compatibility as possible with Node. It doesn't throw away the existing ecosystem.

Deno took on too much of an adversarial perspective towards the Node ecosystem and now they're working towards re-adding support.

So in terms of a successor, I'd say the only option is Bun because it's still trying to maintain compatibility with Node while innovating with new features.

Re:Bun v1.0.0 by mirkodrummer on Friday September 08, 2023 @11:22AM (#37434755)
Not a seasoned users, mostly played with Deno. To me Deno seems more oriented to be an alternative Node runtime with security as first principle and built-in support for Typescript, JSX with some tooling like linter. It's also based on V8. My best guess it's what Ryan Dahl wanted Node to be as an afterthought. Bun, technically speaking is based on Webkit, but can't really say why, seems a better all-in-on tool(also remember rome?) and not only a runtime. Also with compatibility with current frameworks out of box, Deno wasn't npm compatible some time ago and I wonder if it ever meant to be and not a pivotal change on the run
Re:Bun v1.0.0 by ShadowBanThis01 on Friday September 08, 2023 @08:11PM (#37440894)
It's known that Deno tacked on NPM support.

For new, from-scratch projects done by someone who doesn't know Node anyway, why not use Deno? I just started writing the server side of a mobile app with it, and I didn't even know JS, TS, or have any experience with routing frameworks. I had server-side queries working in a matter of days, and I don't claim to be fast at all.

The issues cited in the Bun PR, like the morass of modules and related performance problems, don't seem to exist in plain Deno. Or am I missing something? I don't anticipate ever integrating anything from NPM, so I'm actually disappointed (but understanding of the motivation) to see Deno hedge on the "fresh start" idea.

Re:Bun v1.0.0 by kozzz on Sunday September 10, 2023 @06:29AM (#37454552)
You’re unlikely to encounter any issues with Node in a small project. It’s possible though that you’ll need some module that is not working with Deno.
Re:Bun v1.0.0 by ShadowBanThis01 on Monday September 11, 2023 @04:01PM (#37472842)
Thanks. If I can do CRUD and client authorization I should be OK…

I say now, anyway!

Re:Bun v1.0.0 by azu on Saturday September 09, 2023 @01:37AM (#37442578)
> technically speaking is based on Webkit, but can't really say why

Why Bun uses WebKit/JSC was described here:

> One of the reasons why Bun bet on JavaScriptCore instead of embracing the server-side V8 monoculture is because JavaScriptCore and WebKit/Safari are strongly tied together. This means that Bun can often use implementations of Web APIs from WebKit/Safari directly, without having to reimplement them. This is a great example of that.

via https://bun.sh/blog/bun-v0.7.1#messageport-messagechannel-ar...

Re:Bun v1.0.0 by e1g on Friday September 08, 2023 @11:38AM (#37435009)
We're a full-stack TypeScript shop, and I manage ~50 internal libs and ~500K LOC of TS. Last month I tested out both Deno and Bun as alternative runtimes for us. TLDR: for any semi-complex codebase we have, Bun almost always works, Deno almost never works. We now run all our tests in both Node.js and Bun, and gave up on trying to make Deno happen.
Re:Bun v1.0.0 by ketzo on Friday September 08, 2023 @11:42AM (#37435093)
If you don't mind sharing, what are some of the issues you've had with Bun so far?
Re:Bun v1.0.0 by e1g on Friday September 08, 2023 @11:58AM (#37435347)

  1. Missing `node:http2`
  2. Missing `node:test`, so it's more difficult to execute the same test files within Bun as we do via Node. I wrote a custom Bun loader to mock parts of `node:test`.
  3. Vite and ESLint do not work.
  4. Still occasionally segfaults, and it's difficult to find out why/where.
  5. Surprisingly, some code runs slower in Bun than in Node. For example, generating JWE with symmetric encryption. But this might be WebCrypto vs OpenSSL.
  6. Subtle differences between WebKit and V8 (e.g., how they handle dates).
Re:Bun v1.0.0 by jaktet on Friday September 08, 2023 @01:10PM (#37436352)
Have you tried since v0.7? Vite support was supposedly added then
Re:Bun v1.0.0 by e1g on Friday September 08, 2023 @10:21PM (#37441578)
So it has, thanks for pointing that out. I goofed as I actually actually meant to write Vitest, which remains broken in v1.0.
Re:Bun v1.0.0 by tarasglek on Saturday September 09, 2023 @02:22AM (#37442760)
I am annoyed with the bombastic claims behind bun.

I wasted a day trying to get vite to work when they first announced it. Really excited about not needing >1gb of ram to compile a react project... Boggles my mind that react bundling uses more RAM than compiling linux.

It is still unable compile http://chatcraft.org due to some problem with wasm plugin.

They also said that bunx --bun option was a pre-1.0 workaround, and didn't keep that promise.

Performance-wise their claims are suspect, safari js engine was always better at startup and memory use at the expense of a relatively weak JIT. They paired that up with a ton of stuff reimplemented in native code to make their cli and hello world workflows fast. This means people will be in for a perf surprise when they start bottlenecking in JS hotpaths.

Re:Bun v1.0.0 by e1g on Saturday September 09, 2023 @10:55AM (#37446122)
And you're right to be skeptical. With performance, so much depends on your actual code and program-specific bottlenecks. The difference in runtime speed between JSC and V8 is minimal, so a lot of Bun optimization must be in the gaps between your code and the core JS engine or in startup time (e.g., running `bun install` or `bun test`).

In my benchmarks, our actual runtime performance of long-running JS code is ~25% faster under Bun than under Node. However, sometimes Bun is ~25% slower - notably with tasks that require binary processing (e.g, fflate, sharp) or encryption (e.g., jose). We're committed to JS and will be constrained by its performance for a long time, so a "free" 10-30% speed up at runtime is worth the effort, but it's not a 10x slam dunk like the benchmarks on Bun's homepage imply.

Re:Bun v1.0.0 by wdb on Friday September 08, 2023 @11:52AM (#37435267)
I haven't been able to get any work code working in Bun yet. All my personal/pet projects work fine, though. Speed is impressive when it works.

I did raise issues with repros for it only wasn't able to try to fix the issues myself. Building Bun is not working for me

Re:Bun v1.0.0 by ShadowBanThis01 on Friday September 08, 2023 @08:20PM (#37440949)
What were your "semi-complex" codebases written in and for? Were they testing native Deno, or its integration of NPM packages?

I have never used Node and am creating a new project from scratch, so I don't know how worried to be about your commentary.

Re:Bun v1.0.0 by e1g on Friday September 08, 2023 @10:25PM (#37441606)
The "semi-complex" code is legacy code, aka revenue code. Started with plain JS in CJS on Node 12 and evolved to strict TS/ESM on Node 20. A lot of cruft built up from that multi-year evolution.

These days, if you're authoring from scratch, just write idiomatic TS in ESM, and you'll be fine. Even if targeting only Node, prefer to use Web standards (e.g., fetch, Request/Response, WebCrypto, Web Streams, URL, AbortController) as Node is migrating in that direction, and standard-compliant code will give you optionality in runtimes (Bun/Node/Workers).

Re:Bun v1.0.0 by ShadowBanThis01 on Friday September 08, 2023 @11:48PM (#37442103)
Thanks for the reply! I'm just writing TS code that utilizes Deno/Oak and their MySQL support, to present a REST-style API. I don't know enough to say whether these depart from the standards you're recommending. If they do, I don't know how I would do routing and API support using only the things you mentioned. I'm a one-man band writing both a mobile app and the server to support it. I also know very little about scaling, which I anticipate hiring outside expertise on.

I want to invest my time wisely and learn portable techniques, but I realize the scope of my ignorance may exceed what you can address in a comment forum!

Re:Bun v1.0.0 by e1g on Saturday September 09, 2023 @10:08AM (#37445626)
I have the luxury of toying with tech because the business around it is relatively successful. Engineering deep-dives are a lagging indicator of success (your own or your employer's) and almost never a leading one. All those "we did X/Y/Z with cutting-edge stuff" blog posts are overwhelmingly written by people who don't need to worry about bringing in money to pay for the time spent on that stuff.

Choose the tech stack that allows you to rapidly experiment in building something other people will give you money to use. That means choosing DX and iteration speed over runtime speed. That means using whatever gives you the most joy, so you're incentivized to build more often. That means something high-level so you don't waste time re-building components your customers don't care about, so you spend fewer hours on invisible, undifferentiated, but complex and time-consuming stuff.

If you're most effective with JS, Node is fine. Bun is fine. Deno is fine (for greenfield). One is super stable, battle-tested, and has 10x more contributors and 100x more libraries than the other two (most of them are trash). This maturity gap may not matter at all or may break your startup if you must re-implement something complex or continuously spend hours understanding and battling your runtime with minimal information on the web from others who encountered the same problem before. The same goes for your prod infrastructure, mobile app architecture, business ops, infosec, etc. Choose boring technology https://boringtechnology.club

Re:Bun v1.0.0 by ShadowBanThis01 on Saturday September 09, 2023 @07:49PM (#37451474)
Thanks for that. I'm in the middle situation, in that I'm somewhat in a hurry but not desperate (yet). So far I've been pretty encouraged by how quickly I've gotten something working with Deno; the main reason I went with it over PHP 8 is that I wanted to learn JS/TS. Second, the author's goals of addressing Node shortcomings and providing a cleaner import mechanism resonated with me. Thus far it hasn't annoyed me, which is a miracle because I'm easily annoyed. I think sifting through a vast collection of libraries (mostly junk, as you say) would annoy the shit out of me but more importantly waste valuable time.

I learned that problems that seem simple and solved apparently often aren't, regardless of how many blog posts and HN posts there are about the framework of the week. I needed to define an API, so I did so using OpenAPI. While the idea and standard seems mostly sound, the tooling (from editing to code generation) is absolute trash. I wasted soooo much time trying to make it work. Should I ever use it again, I'm writing my own tools. But right now I do just need to get stuff done.

Re:Bun v1.0.0 by manojlds on Friday September 08, 2023 @11:15AM (#37434615)
Deno wanted a post-Node way but they have gone back on their original ambitions (which never resonated with me, to be frank) and now have a pretty limited compatbility whereas Bun has full compatibility with Node.
Re:Bun v1.0.0 by ignoramous on Friday September 08, 2023 @11:17AM (#37434656)
Per their own docs, Bun is not fully node compatible [0]. In my experience, even for APIs its docs claim full-compatibility has some sharp edges. That said, Bun's node-compat story is better than Deno's.

While Node's performance story keeps improving release over release [1].

[0] https://archive.is/NCzRQ

[1] https://twitter.com/lemire/status/1699459534190698999

Re:Bun v1.0.0 by evbogue on Friday September 08, 2023 @11:25AM (#37434809)
Does Bun support url imports for module loading?
Re:Bun v1.0.0 by lioeters on Friday September 08, 2023 @03:36PM (#37438373)
I was curious about this too, whether Bun supports URL module imports. Skimmed through the documentation a few times, and I believe it does not.

But, the command `bun install` supports NPM and custom registries, as well as Git and .tgz URLs.

https://bun.sh/docs/cli/install#git-dependencies

Re:Bun v1.0.0 by wdb on Friday September 08, 2023 @06:58PM (#37440327)
I think you can achieve this via a bun plugin
Re:Bun v1.0.0 by re-thc on Friday September 08, 2023 @11:19AM (#37434690)
Deno wanted to be different but never did enough to force its way. Maybe if they had 10x the funding to rewrite the ecosystem. Now it's in limbo.

Bun aims to be a better replacement to Node. There's less to consider so it's just a matter of if it's compatible enough and faster / better to warrant the switch. A lot easier to swallow.

Re:Bun v1.0.0 by ShadowBanThis01 on Friday September 08, 2023 @08:25PM (#37440970)
There's plenty to consider if you don't care about Node compatibility. From what I've read (including in this thread and on the Bun PR page), Node seems pretty messy, with modules coming from different sources in different ways. In Deno you just import with a URL.

I know very little about JS and TS and "modules," but from a newcomer that's how it all looks. I'm happy to have any further insight!

Re:Bun v1.0.0 by afavour on Friday September 08, 2023 @11:47AM (#37435174)
I’m not over the moon with it but I’m kind of interested to know why I need a Node successor at all. Both Bun and Deno are VC funded tools so I have base level suspicion around monetization and longevity.

It seems Bun’s major selling point is performance. I can’t say I’ve really run into massive performance concerns with Node. It isn’t earth shatteringly fast but I’m way more likely to run into IO constraints than Node speed issues.

Deno’s major selling point was that it was Node Done Right in many ways: better packaging, ES6 all the way, etc. (a pitch I was sold on!) but it seems they gave up trying to create a new ecosystem and instead are adding Node compatibility.

Alongside all of this I'm encouraged by a number of recent Node improvements like having its own test runner and built in .env support. So I’m struggling to see good reason to use either Bun or Deno. Even if I were to switch I'd need to make sure I have a concrete path back to Node should the new generation tool become unviable.

Re:Bun v1.0.0 by madsbuch on Friday September 08, 2023 @12:19PM (#37435663)
It is well explained in the blog article: https://bun.sh/blog/bun-v1.0#why-bun-exists

This is extremely compelling for frontend DX.

Re:Bun v1.0.0 by afavour on Friday September 08, 2023 @12:30PM (#37435799)
That kind of speaks to my point, though: a number of the features listed there (e.g. test runner, .env file support, watch mode) have either been recently added to Node or will be soon (and are available today as experimental flags).

The bundler stuff is certainly more compelling though the page doesn't specify what makes it better than rebuild except that it comes built-in... but that's where, for me, VC concerns raise their head. If I go all in on Bun bundler, what happens if the company switches their priority towards monetization and neglects the bundler? I'm going to have to unroll all the configuration work I will have done and go back to an external bundling library. And it's still not entirely clear what I gain!

Re:Bun v1.0.0 by fkyoureadthedoc on Friday September 08, 2023 @05:23PM (#37439611)
If it delivers on the promise of solving the require vs import module nonsense that would be enough for me. Maybe node copies that too, but that's also a win imo.
Re:Bun v1.0.0 by ShadowBanThis01 on Friday September 08, 2023 @08:06PM (#37440863)
Does Deno suffer from that in the first place? I don't know what that issue even is, so I'm just asking.
Re:Bun v1.0.0 by Rapzid on Friday September 08, 2023 @01:27PM (#37436600)
Getting VC funded HHVM vibes.

Not sure how they plan on monetizing.

Re:Bun v1.0.0 by afavour on Friday September 08, 2023 @01:28PM (#37436623)
Seems they both have similar plans: serverless hosting, continuous integration, etc. etc.

All valid ideas. But the involvement of VCs makes me wonder what kind of scale they're going to be expected to achieve and what will happen if they don't.

Re:Bun v1.0.0 by Rapzid on Friday September 08, 2023 @04:34PM (#37439051)
I'm super skeptical of the viability, much less the desirability, of language VM specific CI and hosting services..

Feels like an acquisition by Cloudflare/Vercel is a more likely exit scenario.. But then if we get an HHVM repeat and most of the benefits are just introduced into Node proper what's the real value to the aquirer? Aqui-hire? Deno has raised at least $25m though, and bun $7m..

I guess most startups fail so maybe there is just no answer.

Re:Bun v1.0.0 by bsimpson on Friday September 08, 2023 @09:51PM (#37441411)
Google is failing me - what's the VC spin on HHVM?
Re:Bun v1.0.0 by Rapzid on Saturday September 09, 2023 @02:57AM (#37442898)
VC spin?

HipHop Virtual Machine was created over a decade ago to address serious performance issues with PHP. This spurred(lit a fire?) serious efforts to address the issues in PHP proper. Over a rather short period of time PHP became performant enough that HHVM was sunsetted.

I think the history here would call into question the viability of Bun as a monetary investment. It may end up a net good for the ecosystem , but if the major benefits can just be incorporated back into Node proper what are the ROI prospects?

Re:Bun v1.0.0 by bsimpson on Saturday September 09, 2023 @01:03PM (#37447545)
Thanks for the clarification.

I thought you're original comment was saying something to the effect of "VCs funded HHVM, and this feels similar."

I'd only heard of HHVM in the context of Facebook, so I was surprised to read that (but I know Phabricator was another infrastructure company spun out of FB, so it seemed possible).

Re:Bun v1.0.0 by schemescape on Friday September 08, 2023 @11:55AM (#37435302)
If I recall correctly, Bun doesn’t support Windows, unlike Node/Deno.

Edit: sounds like this is changing. Thanks for the correction!

Re:Bun v1.0.0 by jakegmaths on Friday September 08, 2023 @12:08PM (#37435486)
It has experimental support as of this release: https://bun.sh/blog/bun-v1.0#bun-more-thing
Re:Bun v1.0.0 by schemescape on Friday September 08, 2023 @12:13PM (#37435563)
Interesting! The original link has no Windows binaries, so I assumed nothing had changed.
Re:Bun v1.0.0 by schemescape on Friday September 08, 2023 @09:03PM (#37441175)
The link has been changed to the Bun 1.0 blog post which specifically mentions experimental/incomplete Windows support.