If the native speed DOM/Web API for Rust becomes a reality, would you be willing to build your web apps with Rust and HTML/CSS?

95 points andycall

Title Update to Clarify Scope:

If the native speed DOM/Web API for Rust becomes a reality, would you be willing to build an native speed flutter apps with Rust and HTML/CSS?

\------------------------------------------

Hello everyone, I'm the creator of the openwebf project, which enables you to build Flutter apps using HTML/CSS and JavaScript. It behaves like another Blink rendering engine, supporting the DOM API and Web APIs, and following the W3C/WhatWG standards.

The WebF project consists of a sets of C++ implementations for Web/DOM APIs and their bindings to JavaScript. alone with a collection of Dart codes that implements CSS parsing, styling and customized RenderObjects providing CSS layouts like \display: flex\\ or \position: absolute\\. This combination gives you the ability to utilize built-in HTML/CSS support and a JavaScript environment with API that function similarly to web browsers. For any flutter apps, if you import WebF as a dependency, you gain ablitites akin to a browser, but running natively aloneside your Flutter apps.

We all know that Rust for web application development relies on the WASM runtime in web browsers, and the DOM API was only available in JavaScript. Every access to the DOM API from Rust code incurs traffic costs between WASM and JavaScript, which can make your Rust web apps slower and may not provides significant performance improvements compared to standard web apps.

Every Rustaceans is waiting for the day when the WASM runtime in web browsers will have native support for the DOM API and other Web APIs, allowing them to build a web apps with Rust without binding to JavaScript and run them at native speed.

Instead of waiting for web browsers to support DOM API in WASM, I'm considering making the C++ DOM/Web API implements in WebF publicly available to Rust via directly FFI calls. This would make it possible to create and mutate any DOM elements or set styles in Rust code without any significant traffic loss. This approach could allow for the replacement of JavaScript with Rust, while HTML/CSS would still be available.

The communication from Rust to the DOM in the WebF environment is a directly access pathway from Rust to C++. It bypasses WASM and JavaScript, allowing your Rust application codes to be compiled into execute code instead of WASM format. This enables it to run at full speeed and offers the complete range of Rust debugging experiences.

Once the DOM/Web API is ready for Rust, existing rust web frameworks like Yew could be built on top of these APIs, and theoretically, the performance could be on par with native applications.

The core C++ DOM/API parts have been robustly designed, ready to support multiple JavaScript engines or other programming languages interfaces. It won't be takes much efforts and times to achieve this.

The combination of Rust, WebF, and Flutter can create applications with native speed for any screen, using HTML/CSS and Rust, and offer both productivity and safety thanks to Rust.

Before I really get started, I want to conduct a small survey about Rust in web application development. So, the question is:

If the native speed DOM/Web API for Rust becomes a reality, would you be willing to build your apps with Rust and HTML/CSS ?

​