Bun v1.0.0
bun.sh
bun.sh
Could the mods change the link to the blog post? It explains better than the github release page
Blog post: https://bun.sh/blog/bun-v1.0
> The transition from CommonJS to ES modules has been slow and full of terrors.
> Bun supports both module systems, all the time. No need to worry about file
> extensions, .js vs .cjs vs .mjs, or including "type": "module" in your
> package.json.
>
> You can even use import and require(), in the same file. It just works.
This is the highlight for me. The Node.js ecosystem is more-or-less completely broken otherwise. This might save it.(I think that the most impressive thing about Bun isn't its performance but the pragmatic, developer-friendly choices that have been consistently made by Jarred.)
I imagine that's quite rare, because such a package would only be imported or required for its side effects; and because that package cannot import or require any others, could you safely just assume that if it was `require()`ed use CJS, and if it was `import`ed, use ESM?
The risk for Bun's adoption is that they're wrong, of course.
The risk for Node's usage is that they're right, and library authors begin urging users to use Bun because it's 100x easier than making a useful library with Node. (This will happen very slowly, but things that happen very slowly can start happening all at once very quickly.)
Such as? If you could provide 5-10 of your many examples and why you think that Bun's approach doesn't solve them it would be very helpful.
Possibly the most devious nuance is whether the spec's appendix B applies, which affects whether html comment syntax is valid (yes, this is a thing). The html comment token can therefore be parsed either as a comment or as a series of operators depending on the grammar being used.
Effectively, this means it's possible to craft a program that does different things in CJS vs ESM mode.
https://twitter.com/threepointone/status/1698271991927648643
1) We patched JavaScriptCore to load ES Modules synchronously when they don't use top-level await. The main tradeoff here is that requiring an ES Module which uses top-level await is unsupported (Bun throws an exception when you try to do this)
2) To support require() inside ES Modules, we add `import.meta.require` and have a transpiler integration to convert calls to module.require() or require() into import.meta.require(). This either loads the file as an ES Module or as a CommonJS module, depending on what the transpiler says it is
3) We rely on certain heuristics to decide whether a script is an ES Module or a CommonJS module. If they use certain sloppy mode or CommonJS-only features, it becomes CommonJS. If they use ESM features or it's somewhat ambiguous, it becomes an ES Module.
Is there an option to require each file to use either CJS or ESM features, but not both? If not, may I suggest adding that option?
Mixed require and import (the latter in both its static and dynamic variants) is already possible with Webpack and Vite.
I hate it and would complain about any code introducing this in any kind of review.
It's great for integration, full stop.
This is an inconvenience where tradeoffs really show and demand to study the behavioral/semantic differences.
Funnily enough, I still find Bun interesting.
Regarding import.meta., I already love Vite's dynamic import transpilation features. They aim to work almost transparently and often do (I am not even talking about the glob feature here).
That being said, I'm unsure if Bun's way of bridging the module ecosystem gap using import.meta will be as useful.
If you ask me, frontend code should ban Node/CJS/require entirely or transpile it into static or dynamic ESM imports; respectively.
Any case where this is not possible unambiguously is a case for human intervention and code rewrite/conversion.
>Any case where this is not possible unambiguously is a case for human intervention and code rewrite/conversion.
Good god, yes
All three patches mentioned will lead to modules that work only in bun and not work in node/deno/browsers, further fragmentating the ecosystem.
If I want, I can literally run a TS file directly with mixed import/require (not that you would ever) directly, without a package.json, tsconfig, dependencies, etc.
In my experience, it's basically Node, minus all the setup/config/build headaches.
Node's split ecosystem has really hurt the entire language and runtime.
I wrote an extensive post a few weeks ago detailing all the pain that I've dealt with and problems I've run into this year trying to modernize the Redux packages to fully support ESM and CJS:
- https://blog.isquaredsoftware.com/2023/08/esm-modernization-...
I've gotten a lot of feedback from other maintainers saying they've run into similar issues.
Also had a couple podcast discussions following up on that topic:
- https://syntax.fm/show/661/supper-club-shipping-esm-with-mar...
- The dependencies of a module can be scraped without running the code
- The subset of declarations used in an import can be known
This allows modules to be loaded in parallel, and also allows for things like tree-shaking. The biggest benefits are for web browsers, but all around it's a more constrained way to express dependencies, which allows the bundler/runtime to take more liberties.
We are in this mess because tc39 explicitly chose to not give a damn about nodejs ecosystem.
None of the secondary benefits of ESM to commonjs semantics incompatibility (like recursive imports, top level awaits etc) are IMHO worth the ecosystem disruption.
That's bad.
What I am saying is that
import Foo from "foo"
could be sematically equivalent to
const Foo = require("foo")
and
const Foo = await import("foo")
could be semantically equivalent to
const Foo = await Promise.resolve(() => require("foo"))
if tc39 designed ESM import spec with CJS compat in mind.
It is fully possible to introduce additional syntax while not breaking the ecosystem.
(Hypothetically there might have been a place and time in CJS history to force CJS require() to always return a promise and module.exports to always take a function that returns a promise and that hypothetical version might have been compatible enough to import directly from ESM. Nobody actually wanted that hypothetical "ACJS" so it never existed. ACJS could have at least met browsers half-way and might have made the transition less overall painful.)
Having said that, the fact remains that vast majority of pain points that people who actually need to maintain isomorphic libraries face today have nothing to do with synchronous vs asynchronous nature of cjs and esm modules.
It is the myriad pointless nuances like default export, namespace imports etc. that are sources of biggest headaches in day to day work. In cjs there is a simple model that a module exports an object and while importing you import that object. Instead now we have a situation where we need to deal with:
export default {
foo() {...}
}
is not same as: export function foo() { ... }
and import Foo from "foo"
is something different from import * as Foo from "foo"
Plus the additional complexities introduced by import bindings being live etc. are just annoyances that one has to deal with over and over again every time module interop is involved.We don’t have super rigid standards in many ways, however that experience has lead me to wonder why so many engineers are struggling with dual support or cjs and ESM.
That said, none of those packages are redux level of downloads, and imagine you hit more edge cases than I do in that
Edit: originally stated hundreds. Turns out we’ve grown enough that I can say thousands now
I forked and customized an old Javascript templating engine and have published it as npm packages. Should I spend effort migrating to the new way?
> Build artifact formats (ESM, CJS, UMD)
I don't know anyone that ever used AMD/UMD. CJS is loadable in ESM, and tsup makes the two of them trivial.
> > Matrixed with: dev/prod/NODE_ENV builds
Not every library has this issue.
> Bundled or individual .js per source
Not a new issue, this has always been a toss up (I prefer .js per source)
> exports setup
Yup this is a pain, especially because I prefer multiple .js files, and I wish tsup would help here.
> Webpack 4 limits
I'm not sure what you mean by webpack not understanding optional chaining syntax, we use webpack 4 and use it all the time. Might be a benefit of using typescript.
And tsup helps with the .js requirement issue.
> TS moduleResolution options
Again it looks like tsup solves this.
> User environments
When is that ever not an issue? Very fair for maintainers to say "nope, sorry, that's too esoteric an environment"
> TS typedef output (bundled? individual? .d.ts, or .d.mts?)
Should match your .js file output 1:1 (.cjs/.mjs et al)
---
All that to say, if you use typescript and don't do anything fancy, you've got a pretty compatible library with just `tsc`
And if you're looking to do something cross compatible, tsup will help a lot.
Like why is this the standpoint that trumps everything else (eg stability of the ecosystem)? Have a tool to solve the problem and be done with it. It's not like with esm you can publish packages free of tooling anyway.
I'm saying that I've spent much of this year dealing with all the pain around this, and linked an article on my own experiences, and that other package maintainers agree that this matches their experiences.
If you can build a tool that magically solves all these problems, great! Please let me know when that's available :)
(FWIW Bun looks like a genuine improvement on the _consuming_ side of things, but that doesn't help on the _publishing_ side of things.)
Maybe at most, hide the capability behind an execution flag.
The only solution to this problem is to upgrade require work for importing ESM. Once that is implemented ESM will become the natural choice for those publishing libraries. Until that happens library authors are going to continue to use CJS so their libraries are available to everyone.
Node 10 was truly the last LTS that had zero ESM support, and that support ended 2 and a half years ago.
Agree in sentiment, but I don't think this even applies to the module/import mess. My experience has been that the difficulty is in using different packages that made different choices, and making them interop with your own code. I have still yet to make top-level await work in a Typescript codebase where I need to import nontrivial packages. I don't think you should ever need to worry about the specific way your modules are imported, not in prototyping or in production.
I only know that I perfer writing import over require as those semantics and syntax make more sense to me.
The fact Bun solves that problem is more than enough of a reason for me to give it a try, I'm honestly fucking stoked to try it out, and I never thought I'd have those feelings for yet another JS runtime or build tool. Big thanks to the Bun folks, I'm looking forward to gaining some sanity in my day.
Very rarely run into issues but have gotten around with pnpm patch and meta modifications in the past until projects have fixed issues..
My take is 2023 is the year of the module. The water is fine.
It's also against the guidelines, but again 5k karma...
That said, kinda curious now downvoted into negative for sharing my, extensive, experience creating module type projects.. Hrrmmm.
That doesn't paint a great picture.
I don't know about the past 10 years as I haven't tried to use modules for the past 10 years. I've been using them for the past year on new AND existing projects with Vite+React, Vite+Storybook, SWC+Fastify, Rollup and library projects, and etc.
Unless somebody has to work in the past I'm sure what relevance that has on using modules in 2023.
My stack is usually Fastify with official plugins and a PG client.
I remember hearing that once from the Python devs...
The let-down from the first two projects not being a drop-in replacement is jarring, now I have to be skeptical of all communications coming from bun.
For context, both projects use osc which requires dgram. I was able to find a feature request tracking ticket from 9 months ago with no communicated plans to implement, but searching for 'dgram' in this announcement page doesn't show anything.
For a quick suggestion - can you explicitly state what modules are not supported by bun 1.0 and put that in the section related to node.js compat?
edit: found the docs on node support - https://bun.sh/docs/runtime/nodejs-apis . Would be nice to link in the release notes.
Cursory glance looks like for modules - 17 implemented - 17 partially implemented - 7 unimplemented
> Note — For a detailed breakdown of Node.js compatibility, check out: bun.sh/nodejs.
The detailed breakdown explicitly states which modules are not supported.
---
[1] Not a drop-in replacement
That's up to you, and society. Do you accept that tall people exist?
Right. Now exactly what height do you need to be a "tall person"?
This is the same. I haven't used it so I can't say how optimistic their "drop-in replacement" claim is, but they certainly don't need it to work 100% of the time with 100% of project with 0 changes to make that claim.
If you call something a drop in replacement and it is not a drop in replacement, it's simply a lie.
That's obviously wrong, because there are things that could be different while the API/compatibility is still matching 1:1, such as:
- speed, memory usage, memory safety
- additional features, more capabilities
- simple licensing stuff
Imho, a drop-in replacement actually suggests that you can simply swap out the runtime and expect your code to work out of the box.
It does generally suggest a high degree of compatibility to me though.
> [Drop-in replacement] refers to the ability to replace one hardware or software component with another one without any other code or configuration changes being required and resulting in no negative impacts.
But it works enough of the time without any changes that it's reasonable to call it a drop-in replacement.
It seems the note mentioning this feels buried for me under a large banner image, instead of near all the other text about compatibility.
Anyway, glad it is there, hope that their communications design improves in the future as at least a few others got caught with mismanaged expectations.
The question isn't just how many? but also which ones?. Anecdotally, I've been test driving bun for a large application with millions of existing customers. So far, the only issue I've had isn't with bun per se, it's with patch-package not yet supporting the lock file (bun.lockb).
Bun is without question faster than yarn by a wide margin. And I say this as someone who really loves yarn.
The fact is each potential adopter either needs to go through and comb over the compatibility page (not what I would expect with a drop-in replacement); or just try and see if it works, and be surprised later if they run into an unimplemented module because they were operating under an incorrect assumption.
Nevertheless I am super impressed with their speed and exited with the result. Didn't expect this project to grow so quickly to this state, I though it will take them much more time. For comparison, deno was started way earlier and now they are miles behind (personal feeling). I am considering to use it for my pet projects
The repl is about to be added and rewritten completely
Most programs should bind to port 0 and let the OS allocate a free port and then report the resulting port to any future clients.
I just started a new project, writing the back end. I'm new to JS and TS, and I don't want to deal with NPM and a morass of modules at all. Deno, Oak, and MariaDB seem like a pretty tidy combo. I have routes and queries up and working with no experience in writing server-side code since PHP 5.
What makes Bun better?
* can't use AWS SDK v3 because throws an error when parsing a response;
* can't use octokit (or anything that depends on jsonwebtoken, for that matter) because node:crypto is not fully implemented;
* can’t run our tests, because jest.resetAllMocks() is missing
* in another project, bun test failed to even run, complaining about invalid call to shared library So for me the local workflow is “run it with bun, see if it fails, re-run with node if it does”. At least I can always replace npm with it, I guess? Can’t imagine running our services with it just yet. Really excited for the future of the project, because when it works - it really is amazing. But I wouldn’t call it 1.0 if the selling feature is Node compatibility.
This has probably been asked before, but has there been any thoughts about moving community chat to a platform other than Discord? Discord has been brought up many times on HN for its accessibility/privacy/proprietary lock-in concerns that don't seem to be in line with the spirit of open-source. Also see [1].
[1] https://drewdevault.com/2021/12/28/Dont-use-Discord-for-FOSS...
https://news.ycombinator.com/item?id=35970869
And in the comments of the bun 0.8 announcement, the same question generates very little interest and some well every other project uses it, so...:
> Choosing proprietary tools and services for your free software project ultimately sends a message to downstream developers and users of your project that freedom of all users—developers included—is not a priority.
— Matt Lee
The Discord-hate is a double standard that is not applied to any service (to the extent that comments criticizing Discord appear with extreme regularity on threads that should be completely unrelated).
And I think Deno uses it.
> Discord-hate is a double standard that is not applied to any service
What does this mean? Dropbox/Amazon/Google/Windows get criticism across the web and on HN regularly, some of those far more than Discord.
> to the extent that comments criticizing Discord appear with extreme regularity on threads that should be completely unrelated
I don't get it. Are you implying a conspiracy?
Discord is just an added communication channel, mostly for the community.
Relevant discussions happen on GH.
I am part of numerous programming discords and I just see no issue with them being on discord, again, starting from the fact being there is far from being a requirement for anything really.
Has Discord ever asked you to provide and confirm your phone number to continue using it?
But otherwise, yeah, I would warn against potential vendor lock-in, especially if that service is not open-source.
Well, and joining most discussions require an account, and if your alternative communication platform is Discord, we see all the same issues of lock-in.
> What I can tell you is that, to my surprise, Discord’s accessibility has apparently improved in recent years, and more blind people are using it now. One of my blind friends told me that most Discord functionality is very accessible and several blind communities are using it. He also told me about a group of young blind programmers who are using Discord to discuss the development of a new open-source screen reader to replace the current Orca screen reader for GNOME
Discord is honestly a great place for FOSS to house their communications. I find all of the articles claims very haphazard:
> When you choose Discord, you are legitimizing their platform and divesting from FOSS platforms
It is legit? It's free? It has loads of compelling features, is very accessible, and - most importantly... Also, choosing Discord does not take value away from FOSS communication platforms.
> Use IRC
It isn't IRC which is very inaccessible to lots of people new to computers and software in general.
Free as in gratis, sure. But as in libre? No, it’s definitely proprietary & it’s free because users are the product (data collected and upselling Nitro); not every user wants to give up their privacy freedoms to participate. Discord’s not federated so users will be required to create an account & agree to the ToS & CoC of Discord, not the community running it. Discord has also been hostile towards folks trying to make alternative clients to meet usability needs & certain kind of bots.
Without IRCV3 & bouncer it would be a difficult/unexpected experience for a new user. Luckily IRC isn’t the only libre option. If you want to keep the system requirements low XMPP MUCs are good & allow federation. If you want newer bells & whistles at the cost of system requirements federated Matrix can be considered (tho centralization concerns around Matrix.org having the most users, most used server, most used client, & controls the spec). There are bridges between all of these that you can choose as many or as few as meets the community needs such as a community-hosted XMPP main server in a neutral country with bridges to IRC & Discord.
Yes, but this ignores the others issues the post brings up: Users who cannot afford new enough hardware to make the resource-intensive client pleasant to use are also left by the wayside.
Or: Discord also declines service to users in countries under US sanctions, such as Iran.
> Discord is honestly a great place for FOSS to house their communications ... Discord does not take value away from FOSS communication platforms.
The blog's author, and others such as myself disagree. Discord chats are not indexible by search engines, so solutions are harder to find. You need a Discord account, and you need to join the channel to even see chat and use the search feature. Discord is proprietary and non-extensible because of it. Lastly, Discord is also profit-motivated, so they can shut things down or add limitations because they need to maintain a profit, and there would be nothing we can do about it. "Enshittification" as HN users love to say, is practically inevitable.
> It isn't IRC which is very inaccessible to lots of people new to computers and software in general.
Which client are you speaking of? :) The beauty of IRC, Matrix, XMPP, etc is that you have the choice and freedom (without being legally threatened by Discord Inc.) to build your own client.
Instead of bashing library authors that have already so much to think, why don't you propose a discord replacement and pay for it, while providing the same ease of use for the users and the same features from channels, threads, third party apps/plugins, video conferencing, etc?
I'm glad you enjoy Discord! And thanks for your hard work. But I disagree, and all of the issues with Discord I pointed out above still persist despite your love for the UX.
> Instead of bashing library authors that have already so much to think
I never bashed library authors.
> why don't you propose a discord replacement and pay for it
I engage in communities that use Zulip and Matrix. Zulip is free for open-source projects [1], and I donate to a small community that hosts its own Matrix server.
> while providing the same ease of use for the users and the same features from channels, threads, third party apps/plugins, video conferencing, etc?
We're kinda getting away from the point here. No one is suggesting that there is a FOSS alternative to Discord that has 100% feature parity.
Wait… people can’t run web browsers?
it does though. it's the same vicious cycle that allowed microsoft to gain control of the OS market: developers write programs for windows (because that's where the users are) and users run windows (because that's where the programs run). the more people agree to use discord, the more it becomes "the place where the <x> community is", the harder it becomes for any community to not use it.
9/10 discord users don't understand or care about this at all. which is why it's of utmost importance that developers - especially open source developers, presumably developing open source software for a reason - encourage discussion on other platforms.
There's some room for debate about offering Discord as a bridged option. But having the official community chat only on Discord? How is there even a question?
Both are proprietary websites owned by for-profit companies. Both require you to create an account in order to participate in discussion.
Don't get me wrong. I get small developers defaulting to infrastructure they don't have to set up and maintain themselves, and I understand wanting to meet people where they're at. But it's definitely a problem that GitHub plays such a central role in F/OSS development, too.
1. Git is distributed by design. Hosting on Github tends to not be controversial because that code can also live on Gitea/Sourcehut/your private git server at the same time. If Github goes down, it does not really matter. Very different from Discord, where there is no way to actually backup server/channel data, and attempting to do so may be a violation of the ToS and get you IP banned.
2. Your argument hinges on the fact that you have never seen an open-source project criticized, but it does happen. The blogpost in the parent comment even suggests not hosting on Github.
Some time ago I asked them whether they planned to ever become Free Software so it could be actually safe and have a community around it, and after a couple of messages they went (not verbatim, but in spirit) "oh, open source? lolno", missing the point entirely in multiple ways.
Taking into account their massive teen-focused PR campaign - which is a particularly social phase of human growth and FOMO reigns supreme, their predecessor OpenFeint's demise including a privacy lawsuit, the amounts of data and metadata implicitly and explicitly collected, it's at least _likely enough to distrust it_. The doors in the back are bound to be giving that sweet personal data to whomever has a big enough money stick, and/or other non-trustable agencies.
Could you link to the program they are working on? Nothing appears when searching for "orca screen reader for gnome replacement."
Creating a channel on Matrix.org is free.
Libera.Chat & OFTC offer free IRC for open source—& can depending on the community be a welcome bridged platform for any alternative as IRC requires the least resources to run (tho if you need rooms with encryption, that won’t be an option).
I see bun's licensing is MIT, and that is fantastic. So that does give me some hope it won't die should the business go under. I hope the business succeeds, but I'm curious should I adopt bun, what might the upsell be down the road.
Oven will provide incredibly fast serverless hosting & continuous integration for backend & frontend JavaScript apps — and it will be powered by Bun.
It will support popular frontend frameworks like Next.js, Vite, SvelteKit, SolidStart and many more — along with backend frameworks like Express, Fastify, NestJS and more.
The plan is to run our own servers on the edge in datacenters around the world. Oven will leverage end-to-end integration of the entire JavaScript stack (down to the hardware) to make new things possible.
Trying to keep up with one guy's side project caused me so much pain that I moved everything to Rollup and never looked back.
VC funded and random side project clearly have different concerns, but the ultimate risk with either is "if the creator can't support me, then what"
The tooling situation around JavaScript is certainly my biggest pain point around it and turns a really very capable and pleasant language (ES6 + TS) into a complete chore. Here’s hoping that Bun can deliver.
It has to be a similar feeling as going from CMake to Cargo.
It reminds me as a runtime version of Rome tools, which had a similar goal (replace a bunch of software with a single faster one). It went under and has [transition to OSS under a new team](https://biomejs.dev/blog/annoucing-biome). I hope you find more success than they did! It's certainly a hard problem to solve.
Any seasoned users with time spent on both?
While Node's performance story keeps improving release over release [1].
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.
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!
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.
I say now, anyway!
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...
But, the command `bun install` supports NPM and custom registries, as well as Git and .tgz URLs.
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.
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
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).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.
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.
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.
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).
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!
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
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.
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.
This is extremely compelling for frontend DX.
The bundler stuff is certainly more compelling though the page doesn't specify what makes it better than esbuild 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!
Not sure how they plan on monetizing.
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.
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.
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?
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).
Edit: sounds like this is changing. Thanks for the correction!
The specific bug ended up not being in fetch() body streaming, but in our JavaScriptCore binding for getting a property from an object that may not have defined the property. Not all of our code was checking that the value was an object (only that it was a JSCell, which usually is an object, but things like symbols and BigInt are not JSObject)
Thread from yesterday: https://news.ycombinator.com/item?id=37424724
Extra hint - you may provide text snippet for Ansible playbook/taskset with proper sha256/similar checksumming for installing via "Download from Internet, not from your distro repos", the same for Puppet (which gonna be bit more complicated).
Will ease up a bit system's administrators work - SAX - system administrator experience, if you wanna name it that way :)
I'm confused cause this guide on the official site showcases how to use Bun + Vite.js to build a TypeScript React app. [1]
There is also this issue on their Github. [2]
Can Vite.js be used to handle more complicated scenarios / advanced use cases that Bun doesn't handle? My use of Vite.js is pretty basic (start & build with the default TS+React config) so maybe I'm missing something here.
--
Granted I have no experience with bun yet, my take on it is that you can leverage bun for running the local dev server (instead of node), leverage bun for bundling (instead of esbuild or tsc or rollup or an amalgamation of them), and leverage bun for transpiring instead of Babel and typescript.
What vite provides is an easy to configure setup for developing frontend applications with a nice DevX when working locally.
And most of the new meta frameworks(nuxt,sveltekit,astro,solidstart,qwik) runs on vite so that might pave a path for adoption.
Realistically how much of a problem is this likely to be?
Seriously, I think this question is worth asking. Why was Zig chosen as the language when it’s not even stable, and what implications does this have for the long term viability of the project (besides the fact that its _fast_)? Zig’s head guy isn’t even sure when Zig will hit v.1.0, and Bun’s head guy hasn’t really responded either AFAIK.
Demonstrably by this 1.0 bun release it seems safe to say it ended up being a fine decision, no?
That’s just a decision they’ve made themselves. I honestly think it’s an interesting question: can software built on a <1.0 base legitimately call itself 1.0? What if there are big underlying issues discovered within Zig?
If Zig dies tomorrow, bun could probably continue using it as-is, perhaps after fixing the bugs they encounter. It's "the API and language spec isn't complete yet" unstable, not "we haven't implemented floating point operations yet" unstable. So far, only the allocalypse has caused major grief in terms of language changes, as far as I know.
Why is it not ready for production if the binaries work just fine?
In one such change, all *Allocator parameters were turned into Allocator parameters (not the missing *). That meant rewriting tons of function bodies and signatures, because passing specific allocators around is one of Zig's strengths. The compiled binaries came out just fine, but every major Zig component needed refactoring from one compiler version to the next.
That's what I don't like about these modern languages. You have to be in the community and keep up with the latest releases in order to use the language. I just want something that's stable. I don't want to keep relearning everything.
It is a very young language with momentum and a foundation behind it. I'm not aware of any pre 1.0 stability guarantees.
In fact it is generally recommended to use the nightly release (see: https://ziglang.org/learn/getting-started/) because they are moving quickly.
Definitely seems to be in a early adopters and tinkerers phase.
I've been following the progress of bun since your initial announcement and today I decided to give it a try, just to play around.
Haven't done much with it, but even for the 5 min I played with it I'm kind of impressed so far.
- Superquick install PLUS did not require root (like many other installs)
- It identified I was using fish shell and added to path (nice!)
- I ran a very quick bench on "npm install" vs "bun install" on one of the projects I have, and the performance is amazing. 50seconds vs 4.5 seconds on the first install. Moreover re-executing "bun install" takes 122ms on my machine. Removing node_modules and re-executing it takes 769ms (because of course, it uses a local cache elsewhere, but still). Amazing.
I'll probably continue exploring tomorrow and see whether it is able to run the rest of the backend/frontend or whether it gives me a hard time. I've seen there are certain things that are not 100% compatible with node yet, but since the initial impressions are great I'll explore further.
BTW A code formatter and a linter would be a great addition to bun.
I know there is this ticket: https://github.com/oven-sh/bun/discussions/712
But one of the advantages of integrating both things in bun is that it makes it the perfect standard tool to be used inside of a team. So no extra installations from other projects, no extra mental burden of what to use, etc... bun would be the perfect dev companion with both ;)
Probably a linter is a different beast (and not sure you or the rest of people working in bun want to get in there... probably not important right now), but a formatter seems doable and it does add a lot of value from my point of view. Given that bun already runs, installs, tests and bundles, to the very least _formatting_ seems like a natural addition to the family. To me a formatter is part of the standard toolset for developers nowadays.
Once again, thanks a lot for the effort to you and the rest of the people contributing to the project!
(edit: re-formatted my comment :p)
I haven't thought twice about it. Frankly, I forgot that bun has been happily running behind the scenes for me. I highly recommend anyone using NodeJS to give it a go.
And Bun is going to improve that?
Sure, the instability of Zig may increase the maintenance costs for Jarred, to use updated versions of Zig. But this has no effect on the features that Bun provides. The risk that a change to Zig would be so consequential that they would actually prevent Jarred from continuing to work on Bun, or would otherwise force Jarred to fork Zig, that risk is so low as to be inconsequential.
(disclaimer: not associated with either bun or zig, the above are pure opinions)
With that said, it is probably fine to use for most ordinary apps, but I wouldn't yet build a bank infrastructure on top for example.
But from anecdotes, I have the impression people still run into bugs and missing functionality semi-commonly. I'm sure it works great for small/personal projects, but I've been hesitant to recommend it for production use at my workplace because of this impression
So my question is: how feature-complete/stable/secure is it right now, what does the v1.0 label say about that, and what are the long-term plans/prioritization/guarantees around this area?
ESM can use top-level await and CJS can't. So this can't possibly work, right?
// x.mjs
export const x = await 'x';
// y.cjs
console.log(require('./x.mjs').x);
And, indeed, it doesn't work in Bun. When I `bun y.cjs` it gives me this error message: TypeError: require() async module "/tmp/x.mjs" is unsupported. use "await import()" instead.
… but using "await import()" instead is exactly what I was trying to avoid! I can use "await import()" in Node, too.But it looks like it does work in Bun if I drop the `await` from y.mjs. So, is it just transpiling ESM to CJS, and failing out if the ESM uses top-level await?
EDIT: I see the documentation page https://bun.sh/docs/runtime/modules has a "low-level details" section, explaining how import(CJS) works (by transpiling CJS to ESM), but it doesn't say anything there about how require(ESM) works, which is unfortunate, because that's by far the most interesting part! I've filed a doc bug on this. https://github.com/oven-sh/bun/issues/4601
I love it, it super simplifies project and for minimalists it's perfect.
TSC is simultaneously the most valuable and the most flaky part of your typical JS project setup. That’s the main part I’d be interested in replacing with a different tool.
It has to run TSC (or expect somebody else to run it) in order to typecheck, though, right?
> Bun can run .js, .ts, .cjs, .mjs, .jsx, and .tsx files, which can replace: > > tsc — (but you can keep it for typechecking!)
It hardly mentions anything until the very bottom on what's changed to reach v1, the github release page on the other hand clearly outlines it.
Personally found the blog post to read like documentation rather than a release announcement.
[0] - https://oven.sh/
However, if I recall correctly, the early days of node.js was mostly funded by Joyent. It took time and some major conflicts for Node to be controlled by a foundation.
Any plans for other interesting experimental features (like macros)?
I don't know how much this is still a problem, but a few years ago one area where I used to experience a bit of pain was that package.json scripts would get pretty unwieldy and supporting windows required using third-party tools. Have you consider experimenting a bit with the scripts or are you happy with the state of that feature?
"Unlike Node.js and other runtimes that are built using Google's V8 engine, Bun is built using Apple's WebKit engine. WebKit is the engine that powers Safari and is used by billions of devices every day. It's fast, efficient, and has been battle-tested for decades."
That's really interesting, does WebKit do less JITing or something to be faster for startup?
I don't know that much so I have some questions, sorry if they're already answered. (share link if any if its possible)
Do you plan to support as much as possible the Node.js API (99%) or most features and make your own API for lets say Clustering module and such ?
Speaking of Cluster module, do you want to recreate Node.js Cluster module, or do you plan to create your own way for multi-processing using Bun in a more performant way ?
I've seen Deno putting a lot of effort into the platform around their runtime, making deploying Deno app easy, is that your goal too ?
I've seen that you use Zig instead of C++, what do you like the most about Zig while working on Bun ?
In anyway, I hope the project will make the JSRuntime world better, its promising.
I’ve been loosely following the progress of Bun for awhile, but I haven’t actually tried it. The blog post you linked does make it sound very intriguing.
[0]: http://remix.run/
It's probably fine for new projects though.
It may not matter to you personally, but if it is used in a project with developers working on different platforms, it is going to present some hurdles.
I use all 3 OSes and this superiority complex is tiresome
what do you base this ad hominem on?
If you try to convince your company to deploy servers on a windows environment instead of linux, you better have a really extraodinary reason, that's just a fact. If Windows is any good it's because of the software ran on it (games and related drivers?), despite the OS
Look at OP's original post. Why would one consider a change at all when everything that one needs is already in the OS? I mean... it could perhaps be a preference. Shocking right?
Anyhow, I wouldn't convince any company to use windows environment unless necessary as you mentioned. However not all software are web servers and there are plenty of reason, not extraordinaryly, requiring a windows environment.
If you have circumstances requiring Win env and you want to do web stuff, run WSL. If you want to do web stuff and Win without WSL is your _prefererence_ don't expect the world to bend for you -> keep wallowing in your masochism.
In addition, your "bun-linux-x64.zip" doesn't work on CentOS7 due to glibc compatibility. Would be good to provide a more portable binary.
I am amazed and not at all amazed that GCC has never got a --compatible-with-old-linux flag.
To be fair MacOS doesn't really either, but people tend not to run 9 year old versions of MacOS.
> ...
> pnpm
pnpm's flagship feature is global deduplication of packages, so sadly bun's package manager doesn't seem to be a replacement. Is there any plan or intention to support pnpm-like disk saving? (I suppose not having to esbuild etc. everywhere already helps.)
That said, I'm very impressed with the speed of `bun add` with already cached packages. Literally instant.
According to that, the speed benefits will probably not be as noticeable in windows.
That, coupled with the fact that bun installs twice as fast when no packages are cached (634ms compared to 1.3s) and 100x as fast when all packages are cached (6ms to 639ms), I think it's fair to say that bun can replace pnpm.
Here's the package.json I tried:
{ "dependencies": { "express": "^4.18.2" } }%I know it’s possible to get it to work, but I didn’t have time to fiddle all the bits.
If Bun made this easier, I’d switch from pnpm immediately.
I would have trusted it in production before 1.0 and moreso now. Unfortunately, I cannot use it for most projects right now. I package my applications with Nix for deployment and Nix and bundling JS dependencies is mostly not a great story right now. buildNpmPackage works just fine most of the time, but requires that I use npm to bundle my dependencies.
Of course, this is no fault of Bun whatsover. Bun can emit a yarn.lock that is compatible with Yarn 1. If it could also emit a package-lock.json that might unblock my use case. The more ideal solution would be to build an equivalent of buildNpmPackage that deals directly with Bun, but I'm afraid the effort would not be worth it right now.
The places where WebKit lags behind aren't the places Bun really cares about. I'm honestly quite glad they add some diversity to Javascript land.
I recall reading a comment that JavaScriptCore was chosen because of performance. I believe JSC is quicker to start up, and I wouldn't be surprised if it wasn't faster at executing the type of code Bun executes as well.
% cd /tmp
% mkdir app
% cd app
% time bun install react
bun add v0.6.1 (78229da7)
installed react@18.2.0
3 packages installed [20.00ms]
bun install react 0.01s user 0.01s system 50% cpu 0.041 total
% find node_modules | wc -l
41 $ cd /tmp/
$ mkdir app1 && cd app1
$ time bun install react
bun add v1.0.0 (822a00c4)
installed react@18.2.0
3 packages installed [431.00ms]
real 0m0.436s
user 0m0.031s
sys 0m0.052s
$ cd ..
$ mkdir app2 && cd app2
$ time bun install react
bun add v1.0.0 (822a00c4)
installed react@18.2.0
3 packages installed [6.00ms]
real 0m0.010s
user 0m0.006s
sys 0m0.005s
Though even 431ms is obviously amazing!Guides: https://bun.sh/guides
The docs say that Bun uses clonesfiles / hardlinks (yay). But it also states that clonefiles don't benefit space saving:
> This benefit does not extend to macOS, which uses clonefile for performance reasons
As far as I know, clonefiles are COW, which should not take any space except the extra inode.
I am still absolutely amazed at how much more performant websockets throughput in bun vs node.
Congrats on 1.0!
With non trivial I mean an application using a lot of Nest.js features and libraries like TypeORM, Swagger-UI.
Bun has seriously been a god send. I am so happy that we can finally do top level awaits and it allowed us to delete a lot of hacky code that we had in place just to make node and all the build dependencies happy.
ERROR Cannot build module „nuxt“ {}
Feel free to DM me if I can be helpful.
I've tried this release on one of my projects and encountered some errors, where is the best place to send reports about compatibility issues?
As a library author, how convenient is it to have one suite of tests that can execute in both Bun and Node.js? (E.g. with jest?)
Either way still excited to check it out
what type of project can I use Bun on without regretting it (due to unforeseen bugs, incompatibilities, etc)?
Performance comparisons to Go/Java on the backend would be insightful. Would be interesting to see how close the gap is.
There's a slightly similar case high on the frontpage right now: https://news.ycombinator.com/item?id=37434918. The thing isn't released yet but the appetite to discuss it is strong.
====
Doc's install section for Linux missing DEB/RPM
I'll have to see how it goes on slower machines, ARM, etc.
Thanks!
This makes for a pretty awesome combination considering bun's system calls and sqlite support.