BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Vercel Labs Open-Sources Zero-Native: A Zig-Based Cross-Platform Native Application Framework

Vercel Labs Open-Sources Zero-Native: A Zig-Based Cross-Platform Native Application Framework

Listen to this article -  0:00

Vercel Labs recently open-sourced zero-native, a cross-platform framework for native desktop applications (with mobile applications planned in future releases). Zero-native bypasses the Electron runtime in favor of native OS WebViews and claims to achieve smaller, more efficient native apps with minimal overhead. Zero-native is written in Zig, thus directly interoperating with native C libraries, and features fast incremental compilation times.

Zero-native allows developers to pair web front-ends (Next.js, React, Vue, Svelte) with a Zig back-end.

It aims to provide lightweight binaries and a small memory footprint by avoiding the massive memory overhead typical of cross-platform frameworks that ship the entire browser runtime (e.g., Electron) with the application. As an escape hatch, developers can nonetheless configure the app.zon manifest file to bundle Chromium via the Chromium Embedded Framework (CEF).

Zig is reported to feature faster incremental compilation times compared to Rust. Richard Feldman, the creator of the Roc programming language, announced last year a full rewrite of their compiler from Rust to Zig, citing Rust’s slower compile times as one of the major pain points:

Rust’s compile times are slow. Zig’s compile times are fast. This is not the only reason, but it’s a big reason.

Having a slow feedback loop has been a major drain on both our productivity and also our enjoyment when working on the code base. Waiting several seconds to build a single test, before it has even started running, is not enjoyable.

Incremental compilation is key for application development, a highly iterative process. Web developers, for instance, are accustomed to fast or instant hot-reloading development environments.

Zig additionally interacts directly with the C Application Binary Interface (ABI). As such, no foreign function interface is required to reuse native local C libraries. Developers thus do not pay the build-time cost of generating foreign function interface bindings or managing interface definition languages. Instead, they include a system header and invoke platform SDKs or audio codecs directly. This further contributes to keeping incremental compilation down.

Security-wise, zero-native uses a capability-based system (like Deno and Tauri), thus restricting the front-end from arbitrarily reading local files or triggering native platform APIs outright. Instead, Zig code must explicitly register the native commands that it wishes to use, and the app.zon manifest must explicitly grant the related permissions.

Zero-native enters a highly active ecosystem of Electron alternatives aiming to reduce cross-platform app bloat (e.g., WebUI, LynxJS, Tauri).

WebUI leverages existing OS browsers and webviews to act as the GUI for backend languages like C/C++ or Nim without bundling Chromium. Tauri similarly uses the operating system’s native webview with a Rust back-end and inter-process communications bridging the front-end and the back-end.

Lynx is a Rust-powered framework that compiles a front-end (Web markup, CSS, and JavaScript) into truly native UI primitives via a dual-threaded engine separating UI rendering from business logic. Lynx compiles to Huawei’s HarmonyOS, which features Cangjie, a new open-source compiled language with native effect handlers and algebraic data types.

While relying on native webviews for rendering reduces the size of the shipped application, it also exposes the user to incompatibility issues and rendering differences between OSes. More importantly, applications may break or fail to start if the native webview is not present/found or has an unsupported version.

One developer on Reddit commented on the lack of detailed information on the newly open sourced framework:

It’s very cool TBH. […] Out of curiosity, did Vercel people build something with it? Hard to tell how it compares to other frameworks like Tauri or Electron without a comparison.

Zero-native is still an experimental tool in active development. It currently targets macOS and Linux desktops, with Windows and mobile support described as work in progress.

About the Author

Rate this Article

Adoption
Style

BT