A New Javascript Runtime Fresh Out Of The Oven

A sizable portion of the Hackaday audience groans and runs their eyes when some new-fangled Javascript thing comes out. So what makes Bun different? Bun is a runtime (like Node or Deno)t that offers a performant all-in-one approach. Much to the Spice Girl’s delight, it is written in Zig. It offers bundling, transpiling, module resolution, and a fantastic foreign-function interface.

Node.js and Deno run on the V8 Javascript engine and provide the Node-API to access different features, such as filesystems, that don’t apply to web browsers. However, vast amounts of tooling have built up around Node.js and NPM (node package manager). Many Javascript projects have a bundling and transpiling step that takes the source and packages it together in a more standard format. Typescript needs to be packaged into javascript, and modules need to be resolved.

Bun bakes all this in. Typescript and JSX “just work.” This dramatically simplifies many projects as much of the build infrastructure is part of Bun itself, lowering cognitive load when trying to understand a project. A SQL client and a Jest-like unit test runner are both built-in. Rather than V8, it uses JavaScriptCore, which starts a little faster. But the incredible speedups that Bun offers come mainly from it being written in Zig and the sheer amount of effort dedicated to benchmarking, profiling, and optimizing. We’re What’s even wilder is that Bun is written by one person, [Jared Sumner].

Since Bun implemented most Node APIs (with more to come), many modules are drop-in compatible. Some web-specific APIs, such as fetch and Websockets, is also built-in. It’s an early project, and we’re suspicious of any claims made by the project developers, but we’re cautiously optimistic. Even if you aren’t big on Javascript things, you’re likely bound to learn WebAssembly eventually. A short video by [Fireship] gives a good overview. All the code for Bun is on Github under an MIT license if you’d like to look at it yourself.

Thanks to [Michael Carlson] for the terrible Spice Girl joke.

15 thoughts on “A New Javascript Runtime Fresh Out Of The Oven

  1. Javascript?
    Just nuke it from orbit.

    It has one purpose:
    When applying for a SE job ask ‘What server side Javascript do you run?’
    If the answer isn’t something along the lines of ‘None, are you insane?’, _run_ away.
    Terminate the interview right there and leave.
    You don’t want to work for those twits.
    Javascript could compile to the tightest machine code on earth and it’s ecosystem would still suck big wet donkey balls. It’s where all the worst coders have spent the last 20 years on the most monumental steaming pile, ever.

    Javascript outside the browser is a tell, like someone who drives a French car. No fixing that level of stupid.
    Wish them ‘Better luck next reincarnation’ and never look back.

    1. Agree, but sometimes someone sees they’ve got a hammer, and they’ve got to hit every “nail” with that same hammer, even if the “nail” is in fact a screw.

      I can get that it’s nice to have one language both sides of the HTTP server. Personally I’d like to see browsers consider supporting a language that’s less “loose”. Maybe WebAssembly and/or transpliers are a way forward? After all, pretty much everything we’ve ever run on a computer boils down to machine code which has no type-safety whatsoever.

  2. “Even if you aren’t big on Javascript things, you’re likely bound to learn WebAssembly eventually”

    Huh? Is it also a wasm runtime? Or else this comment makes no sense.

    1. @Jack said: “‘“Even if you aren’t big on Javascript things, you’re likely bound to learn WebAssembly eventually” Huh? Is it also a wasm runtime? Or else this comment makes no sense.’

      WebAssembly is Wasm:

      WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environment. The main goal of WebAssembly is to enable high-performance applications on web pages, “but it does not make any Web-specific assumptions or provide Web-specific features, so it can be employed in other environments as well.[1] Link below for more….

      1. https://en.wikipedia.org/wiki/WebAssembly

Leave a Reply to OstracusCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.