November 23rd, 2024

Why am I writing a JavaScript toolchain in Zig?

The new JavaScript toolchain, Jam, is being developed in Zig to enhance developer tools with features like static analysis, formatting, and optimization, while supporting JSX and TypeScript for improved performance.

Read original articleLink Icon
Why am I writing a JavaScript toolchain in Zig?

The author is developing a new JavaScript toolchain named Jam using Zig, motivated by the potential for improvement in developer tooling. Jam aims to enhance the JavaScript ecosystem by providing a static analyzer, formatter, and code optimizer. The author critiques existing tools like ESLint for their limitations in analyzing source code and proposes that a more advanced open-source tool could significantly benefit developers. Key features of Jam include lossless, cache-efficient syntax trees, data-flow aware intermediate representation (IR) for code optimization, and compile-time AST query processing. The author emphasizes the importance of performance and aims to create a tool that minimizes overhead while maintaining usability. The roadmap includes adding JSX and TypeScript support, developing a source-to-source optimizer, and creating a TypeScript type checker. The author acknowledges the challenges of building Jam from scratch but believes that some ideas merit a fresh implementation. They also express a commitment to contributing to existing tools while pursuing their vision for Jam.

- The new JavaScript toolchain, Jam, is being developed in Zig to improve existing developer tools.

- Jam will feature a static analyzer, formatter, and code optimizer, addressing limitations in current JavaScript tooling.

- The tool aims to utilize advanced techniques like cache-efficient syntax trees and compile-time query processing for better performance.

- The roadmap includes support for JSX and TypeScript, along with a focus on creating a fast and efficient type checker.

- The author is committed to contributing to existing tools while pursuing their vision for Jam.

Link Icon 7 comments
By @nox101 - 4 months
Personally I hate tooling for one language written in another. I hate python used to generate C++. I hate go used to generate C++ or JavaScript. Every added language adds more knowledge needed to contribute.

For every 1000 JS developers and every 1000 Zig developers there are 25 that know both. Only those developers can modify the system.

Further, you double the dependencies. JS pulls in library to do X that requires 50 dependencies, Zig pulls in a library to do X that requires 50 dependencies.

You also have 2 toolchains to maintain.

And you have 2 dev environments to maintain. Get all your editors/IDEs to understand both language. Get double your checkers, double your testing, etc etc.

You effectively increase the tech debt exponentially.

By @hu3 - 5 months
Zig is becoming a strong ecosystem for JS/TS tooling.

Not sure if it started with Bun but there's good momentum.

By @lenkite - 5 months
The ECMAScript committee really need to address the core issues of JS performance - native integers, structs, linear layouts, stack allocation, SIMD, memory arenas, etc. Javascript should ideally be capable of superb performance for its own tools.
By @peutetre - 5 months
You might as well solve the whole problem and just compile to WebAssembly. Cut out JavaScript now as much as possible now and eventually altogether.
By @spiritplumber - 4 months
Why are you writing a JavaScript toolchain in Zig?

For great justice? You know what you doing.

By @tacitusarc - 5 months
Please just don’t make the opinionated formatted use two space indentation. That is one of the craziest recent trends in the JS ecosystem.