pwshub.com

Deno 2.0 looks to backward compatibility to move forward

Deno, the runtime for JavaScript and TypeScript, reached version 2.0 on Wednesday, bringing with it baggage from the past in the form of broad Node.js compatibility.

The project debuted in May 2020 when Ryan Dahl attempted to address problems he saw with Node.js, the JavaScript runtime he released in May 2009 and which he later admitted included “design mistakes made that just cannot be corrected now because there's so much software there that uses it.”

JavaScript's traditional runtime environment was the web browser. Node.js is a runtime environment that allows JavaScript code to execute without a browser – on a server, for example.

Deno represents an attempt to address the shortcomings of Node.js and deliver "a modern, all-in-one, zero-config toolchain for JavaScript and TypeScript development," as described by Dahl, Bert Belder, Bartek Iwańczuk, and Andy Jiang, in a blog post.

Deno is written in Rust and based on the V8 engine that powers Chromium browsers. "Rust has been crucial to Deno’s development, especially with Rusty V8, recently stabilized," Dahl told The Register. "Rust's unified build system simplifies adding third-party functionality compared to C++, keeping Deno fast and reliable for server-side apps."

The long-awaited version 2.0 milestone is backward compatible with Node.js and npm – a feat prior versions did not achieve.

"Deno 2.0 understands package.json , the node_modules folder, and even npm workspaces, allowing you to run Deno in any Node project using ESM," explain Dahl, Belder, Iwańczuk, and Jiang.

The runtime also supports various popular web frameworks like Angular, Astro, Next.js, QwikCity, Remix, and SvelteKit.

  • Linus Torvalds declares war on the passive voice
  • AI godfather-turned-doomer shares Nobel with neural network pioneer
  • LinkedIn: If our AI gets something wrong, that's your problem
  • Incumbent congressman not turning up to debates? Train an AI on his press releases

Deno itself is now a package manager, along the lines of npm. Using the deno install command, developers can install project dependencies. For those using a package.json file, it will create a node_modules folder. Otherwise, it will store dependencies in the global cache. And as their names suggest, the deno add and deno remove commands allow packages to be added or removed from package.json or deno.json files.

Among other noteworthy features, Dahl pointed to the stabilized standard library, support for private npm registries, workspaces and monorepo support, long term support (LTS) release, and the JSR registry for sharing JavaScript libraries across runtimes.

He also called out Deno's speed, particularly in the context of cold starts when invoking functions in AWS Lambda.

While Deno adoption trails Node.js, Dahl said usage is growing. "With 2.0’s broader compatibility and new features, we expect growth to continue," he said. "It makes trying Deno easier for node developers while keeping a modern, secure experience."

Bun, a rival runtime, reached 1.0 last year, and Dahl said he welcomed the challenge.

"Bun is a competitor – but competition in this space is healthy," he said. "It pushes us all to improve the language and ecosystem. Unlike bun, Deno’s goal isn’t to be a node clone in Rust or a drop-in replacement – rather we aim to advance JavaScript beyond 2010-era CommonJS and narrow the gap between server-side and browser environments.

"We believe JavaScript can evolve beyond mismatched tooling and endless layers of transpilation. Our vision includes native TypeScript support, built on web standards like promises, top-level await, wasm, fetch, and ES modules, all in a single, dependency-free executable. Deno is secure by default, like the web." ®

Source: theregister.com

Related stories
1 month ago - If there's one thing we know about Big Red, it's being entirely reasonable JavaScript luminaries and at least 2,500 other interested parties have again asked Oracle to set the programming language free by walking away from the trademark...
Other stories
28 minutes ago - Here's today's NYT Mini Crossword answer. These answers will help you solve New York Times' popular crossword game, Mini Crossword, every day!
28 minutes ago - Here's today's Connections: Sports Edition answer and hints for groups. These clues will help you solve the New York Times' popular puzzle game, Connections: Sports Edition, every day.
28 minutes ago - Here's today's Connections answer and hints for groups. These clues will help you solve New York Times' popular puzzle game, Connections, every day!
28 minutes ago - Here's today's Strands answers and hints. These clues will help you solve The New York Times' popular puzzle game, Strands, every day.
28 minutes ago - Here's today's Wordle answer, plus a look at spoiler-free hints and past solutions. These clues will help you solve New York Times' popular puzzle game, Wordle, every day!