A new JS runtime is out again! JS runtime overview


The JavaScript runtime is the environment or platform where JavaScript code is executed. It is responsible for parsing and executing JavaScript code, providing the required functionality and interfaces to run on a specific operating system or device.

Node.js

Node.js is a JavaScript runtime environment based on the Google V8 engine, and it is currently the most commonly used JavaScript runtime. It allows developers to program using JavaScript on the server side, thereby realizing a full-stack JavaScript development model. The emergence of Node.js has greatly promoted the application of JavaScript on the server side and changed many traditional Web development models.

pictureHere are some of the key features of Node.js:

  • Non-blocking I/O : Node.js adopts a non-blocking I/O model, giving it excellent performance when handling high concurrent requests. This means that Node.js can handle multiple requests at the same time, instead of waiting for one request to complete before processing the next request like the traditional blocking model.
  • Event-driven : Node.js’ event-driven architecture enables it to efficiently handle large numbers of concurrent connections.
  • Single-threaded : Although Node.js is single-threaded, it is still able to efficiently handle a large number of concurrent requests due to its non-blocking I/O and event-driven nature. Of course, this also means that developers need to avoid performing CPU-intensive tasks in Node.js to avoid blocking the event loop.
  • Cross-platform : Node.js can run on a variety of operating systems, including Windows, Linux, macOS, etc. This gives developers the flexibility to choose a development environment that suits them.
  • Rich ecosystem : Node.js has a large open source community and rich ecosystem, providing a large number of third-party modules and tools to easily implement various functions.
  • Versatility:  Node.js is suitable for building various types of applications, including web servers, API servers, real-time applications (such as chat applications), command line tools, etc.

Node.js has the following problems:

  • Security issues : Node.js has relatively loose default security settings, which can increase security risks when handling sensitive data or executing unverified code. While it can be enhanced with additional security measures, this increases the burden on developers and can introduce potential configuration errors.
  • Insufficient TypeScript support : Node.js’s support for TypeScript is relatively weak and requires additional configuration and tool chains to implement. This increases development complexity and maintenance costs, especially for developers who tend to use TypeScript.
  • Module system compatibility challenge : Node.js mainly uses the CommonJS module system, but modern JavaScript development is increasingly inclined to use ES modules. Although Node.js has gradually begun to support ES modules, there are still compatibility issues with CommonJS modules, which can lead to confusion and complexity when mixing different module systems in projects.
  • Performance bottleneck : Node.js's single-threaded model works well when handling high-concurrency I/O operations, but it can be limited when handling CPU-intensive tasks. For tasks that require heavy computing resources, Node.js may not perform as well as multi-threaded or compiled languages.

Not

Deno was originally created in 2018 by Ryan Dahl, the original creator of Node.js, to solve some problems he believed existed in Node.js, such as performance and security. It focuses on security, modern JavaScript practices, and developer experience. Built on the V8 JavaScript engine and written in Rust.

pictureDeno’s core features include:

  • Secure by Default : Deno defaults to no file, network, or environment access unless explicitly granted by the user. This design makes Deno more secure when handling sensitive data or executing untrusted code.
  • TypeScript support : Deno supports TypeScript out of the box, with no additional configuration or toolchain required. This allows developers to write TypeScript code directly and execute it in the Deno environment. .
  • Node ecosystem compatibility : Deno is backwards compatible with Node.js’ built-in API and more than 2 million modules on npm, which makes it easier for developers to migrate or integrate existing Node.js code bases.

Deno has more comprehensive features compared to Node.js. It has good support for Web API and modern standards, and also supports most NPM packages. Deno also provides a great development experience, especially if you use TypeScript, which comes out of the box. Deno also has the advantages of built-in linting, code formatter, etc., saving some configuration and boot time. If you prefer an out-of-the-box setup, just fire up the editor, create a main.ts file, and start coding happily!

In addition, Deno also has its own toolset, such as distributed database Deno KV, JavaScript registry JSR, distributed deployment system Deno Deploy, Web framework Fresh designed for the edge, etc.!

As a relatively new runtime environment, Deno still needs time to build its ecosystem and community. Compared with Node.js, which already has a large community and rich ecology, Deno's community scale and ecological development are still insufficient, which limits its popularity.

Good

Bun is a modern JavaScript runtime built around WebKit's JavaScriptCore rather than the V8 engine like Node.js or Deno. Designed as a faster, leaner, more modern alternative to Node.js, Bun aims to be a full-featured runtime environment and toolkit with a focus on speed, packaging, testing and compatibility with Node.js packages . One of the biggest advantages is its performance. It turns out that Bun is faster than both Node.js and Deno. If Bun can accomplish these goals, it will become a very attractive option.

pictureBun has the following characteristics:

  • Integrated toolkit : Bun is not just a runtime environment, it also integrates Web API, packaging tools, testing framework and other functions to form a complete and integrated toolkit. This enables developers to develop, build, test and debug projects on a unified platform, improving work efficiency.
  • Based on JavaScriptCore : Bun is based on JavaScriptCore, the engine of Apple Safari browser, with fast startup time and better memory usage efficiency.
  • No external dependencies : Unlike Node.js, Bun does not depend on npm or external dependencies. It has a built-in standard library that provides functions for a variety of protocols and modules, including environment variables, HTTP, WebSocket, file systems, etc.
  • Built-in TypeScript support : Bun provides built-in support for TypeScript. It internally translates each JavaScript or TypeScript source file, allowing TypeScript files to be run directly without additional configuration or translation.
  • Powerful command line interface tool : Bun comes with a powerful command line interface tool (CLI) that can run, format, inspect, test and package code using simple commands.

It is worth mentioning that Bun is not currently supported on Windows systems, which disappoints many Windows users. The official release of the Windows version has been postponed many times. The latest testing progress shows that Bun’s Windows version has completed 94% of the development work, which means that it may not be far from its official release.

WinterJS

WinterJS is a new WinterCG-compatible runtime environment, written in Rust, and uses the SpiderMonkey engine and Tokio to handle HTTP requests. WinterJs will be much faster than Bun and Node. It also supports Next.js, React Server Components, Svelte and more.

pictureThe features of WinterJS are as follows:

  • Works seamlessly with Cloudflare : WinterJS is designed to work with Cloudflare’s tools like Workers and Pages to help speed up websites around the world.
  • Blazing-fast performance : WinterJS is capable of over 58,000 requests per second on a single CPU core, which is almost 2x faster than similar tools like Deno and Bun. This performance improvement is mainly due to the Wasmer technology it uses, making it almost as fast as running the application directly on your local computer.
  • WebAssembly compatibility : WinterJS supports working directly with WebAssembly modules, which allows developers to leverage languages ​​such as Rust to accelerate specific parts of the application for higher performance.
  • Applicable to React Server Components : WinterJS can be used with React Server Components so that the server can run React applications, thereby reducing the need to run JavaScript in the browser and further improving the speed of the website.

LLRT

LLRT(Low Latency Runtime,低延迟运行时)是亚马逊开源的一个轻量级的 JavaScript 运行时,其主要目标是为 Serverless 应用提供显著更快的启动时间和改进的效率。与在 AWS Lambda 上运行的其他JavaScript运行时相比,LLRT提供高达 10 倍以上的启动速度,总体成本降低高达2倍。

pictureLLRT has the following characteristics:

  • Faster startup times : LLRT boots up more than 10 times faster than other JavaScript runtimes running on AWS Lambda. This speed advantage is critical for serverless functions that need to respond quickly to incoming requests.
  • Cost Savings : The overall cost of LLRT is more than 2x lower than other runtimes. It helps minimize the cost of running serverless workloads by optimizing memory usage and reducing startup time.
  • Built on Rust : LLRT is implemented using Rust, a systems programming language known for its performance, security, and memory efficiency.
  • QuickJS engine : LLRT uses the QuickJS JavaScript engine. QuickJS is a small and embeddable engine written in C, ideal for lightweight runtimes like LLRT.

Unlike general-purpose runtimes like Node.js, Bun or Deno, LLRT focuses on the needs of serverless environments . Here are some key differences:

  • No JIT compiler : Unlike Node.js, which relies on just-in-time (JIT) compilation, LLRT does not include a JIT compiler. This design choice simplifies system complexity and reduces runtime size while conserving CPU and memory resources.
  • Packaging dependencies : To achieve speedup, LLRT requires developers to package their code and dependencies into a single .js file. This eliminates filesystem lookups during module resolution, a common bottleneck in other runtimes.
  • Precompile AWS SDK : LLRT prepackages and precompiles parts of the AWS SDK into bytecode. This approach further helps speed up your app's startup time.

LLRT can be used in the following situations:

  • Data Transformation : LLRT excels in data processing tasks that require low latency.
  • Real-time processing : For real-time workloads, such as event-driven processing or streaming data, LLRT’s fast startup time is invaluable.
  • AWS Service Integration : LLRT ensures fast response times when integrating with AWS services such as DynamoDB or S3.

Summarize

  • Node.js : Node.js is a JavaScript runtime based on the Google V8 engine, featuring non-blocking I/O and event-driven architecture, enabling full-stack development. It is cross-platform and has a rich ecosystem, but it also faces challenges such as security, TypeScript support, and performance.
  • Deno : Deno is a JavaScript runtime created by Ryan Dahl that emphasizes security and modern practices. It's safe by default, has built-in TypeScript support, and is compatible with Node.js. However, its community and ecosystem are still in the development stage.
  • Bun : Bun is a modern JavaScript runtime built on WebKit JavaScriptCore, designed to provide superior performance and an all-in-one toolkit. It has no external dependencies, built-in TypeScript support, and focuses on speed, packaging, testing, and compatibility with Node.js packages.
  • WinterJS : WinterJS is a JavaScript web server runtime that prides itself on speed, works seamlessly with Cloudflare, supports React Server Components, and excels at handling high concurrency and WebAssembly modules. Its goal is to provide fast and powerful web application solutions.
  • LLRT : LLRT is Amazon’s open source lightweight JavaScript runtime, designed for serverless applications. It is built on the Rust and QuickJS engines, takes advantage of fast startup time and cost savings, and is suitable for the needs of Serverless environments, requiring pre-compiled and packaged dependencies.