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.



A New Javascript Runtime Fresh Out Of The Oven
Source: Manila Flash Report

Post a Comment

0 Comments