Developers: | Oven |
Date of the premiere of the system: | 2023/09/11 |
Technology: | Application Development Tools |
2023: Bun 1.0
On September 11, 2023, it became known that the first significant release of the Bun platform was presented, designed to separately execute applications written in JavaScript, JSX and TypeScript. The project aims to use Node.js as a transparent replacement for the platform, supports the mechanisms used in Node.js for working with modules and processing dependencies. The project code is written in Zig and C++, and is distributed under the MIT license. JavaScript engine JavaScriptCore and components of the WebKit project with additional patches are used to execute JavaScript.
As reported, Bun includes a complete set of tools for creating and executing applications in JavaScript and TypeScript. Among other things, the platform provides runtime for creating server handlers and running JavaScript applications without, browser an NPM-compatible package manager, execution tools, a self-contained tests package assembly system, and a bunx utility for installing and launching packages from the repository (NPM equivalent to npx and yarn dlx).
The goals stated are the ability to run most of the existing server-side JavaScript applications, achieve optimal performance and provide tools to reduce the complexity of development and optimize labor productivity. The project also provides a minimum set of optimized APIs to efficiently perform tasks such as starting an HTTP server and working with files. The "bun - hot" mode is supported for automatic hot code reboot in the event of changes to application files that run without stopping the program (during reboot, established connections will not be broken and the state will not be lost).
A feature of Bun is its very optimal performance. For example, in tests for executing a server application based on the React framework, Bun application demonstrates twice the bandwidth (the number of HTTP requests processed by the application per second) than the Deno platform and 4.7 times more than Node.js. In a test for the operation of a chat server using WebSocket, Bun doubles Deno and Node.js 6 times. In the test of loading large tables from SQLite, the Bun platform is twice as fast as Deno, and Node.js is 4 times faster.
Installing applications using the "bun install" command is 25 times faster than using "npm install," and building with the "build build" command is 1.76 faster than esbuild, 26 times faster than rspack, 155 times faster than Parcel 2 and 224 times faster than WebPack 5. Compared to Node.js and Deno, which use the V8 JavaScript engine, Bun is based on the JavaScriptCore framework developed by the company Apple for. browser Safari In addition to performance, JavaScriptCore also reduced memory consumption.
The project develops with an eye to ensuring compatibility with server applications written for Node.js, supports most of the Node.js APIs, including modules and structures fs, path, http, process, __ dirname and Buffer. The traditional Web API is also supported, including fetch, WebSocket, and ReadableStream objects. Compatibility is provided with both Node.js modules (CommonJS and node_modules), and JavaScript modules (ESM) created in accordance with the ECMAScript 6 specification and used in browser web applications. In the current form, most npm packages created for Node.js can be run in Bun without changes or with minimal edits. Many server frameworks are supported, such as Express, Koa and Hono.
The platform can also replace many related tools being developed for the Node.js ecosystem. For example, Bun can be used to run.js,.ts,.cjs,.mjs,.jsx, and.tsx files, replacing systems such as tsc, babel, ts-node, ts-node-esm, and tsx. The built-in system for assembling separate programs allows you to do without esbuild, webpack, parcel and rollup. The built-in package manager provides npm-compatible commands, processes package.json, writes the result to the node_modules directory, and can replace npm, yarn, pnpm, and lerna[1].