Is Rust Ready for Web Front-End?

Is Rust ready to replace Javascript to build a client web application?

Table of contents

Rationale

I love Rust's strong type system and magical error message. I want to have the same experience building client web application as I do in the backend world. I tried Seed, Sycamore with Parseus, and Dioxus.

Yew is the most popular, but I don't like React approach. I went with Seed and built Crabtail with it. Then I try Parseus. I stopped because the function signature is too cluttered. After a long pause, Dioxus pops up and gives me the confidence to try Rust for the front-end again. Its function signature is cleaner than the latter. It is the main reason I picked it even though it is React-inspired.

After falling in love with Dioxus, I plan to build a "production" grade front-end application with it. Then I look for inspiration. Unfortunately, I can't find any popular open-source web applications that use Rust in their front-end stack. I investigate the situation by building the same application1 in both Rust and popular Javascript frameworks. This way I will get to see how large the third-party ecosystem and its community are.

This time I pick three frameworks, one from Rust and two from Javascript. This is not a general comparison, I only pick a framework that I will be comfortable using it. They are Dioxus, Vue, and Svelte. But in some parts, I also mention React and Yew.

Usage

It is very common for a framework or library to be picked up based on its usage. The metrics can be Github stargazer and weekly downloads from the package registry. Both data are raw, some users don't star it on Github and CI contributes to the weekly download. But at least it gives us a glimpse of the usage.

People tend to pick the one with the highest usage. It is related to the job opening, third-party support, tutorial, the number of active maintainers, how fast you can get a reply to your issue, and so on.

If the project is built for personal business, jobs opening can be ignored. Otherwise, React would be the clear winner. Some companies are using Vue even though not much as React usage. Hiring a Vue developer is not a hard thing to do. Svelte is also being used by Apple, Google, and several popular companies. But the job opening is still pretty low compared to Vue. Dioxus on the other hand currently hadn't been adopted by any popular companies. The same fate is true for Yew.

NPM trends: Vue vs Svelte.
NPM trends: Vue vs Svelte.

The trends also confirm the adoptions. The gap between Vue and Svelte is huge. Don't add React there as both will become tiny.

FrameworkWeekly DownloadStargazers
Vue3,146,540199k
Svelte350,22461.6k
Dioxus2,496 (Monthly)24.6k

Weekly download and Github stargazers also contribute to usage metrics. We can easily ignore the company adoptions and job openings. But it is hard to ignore the community size.

Community

The most deciding factor for me here is the public figure. Such as David Peter (sharkdp) and Andrew Gallant (BurntSushi) of Rust CLI, and Anthony Fu (antfu) of Vue3. I see Dioxus still lack those lovely popular figures. I know this can be opinionated.

A public figure in this term is a non-founder that produces popular "third-party" packages or applications. The package can be used as a building block, making building things easier. The application serves as a boilerplate to learn the best practice and the unknown of unknown4.

I see boilerplate as a God send for me. Digging a thousand lines of application to find the best practice is a non-trivial task. We need to cycle through each feature commit to get the insight. This is not the case for boilerplate. It is a place to dump every best-opinionated practice that the author had learned the hard way. Boilerplate teaches how to do things effectively, code structure, and a whole new approach we never think of before. The latter is what I called the unknown of unknown.

Other than building things fast, we also need to consider fixing things fast. With only a couple of active people in the forum, your questions likely need days before any answer arrived. The response time in the Vue forum is much faster than in the two. Although, the Svelte forum is not as slow as Dioxus.

A one-man show will likely make your bug issue sits for weeks if he is on vacation or busy with other things. The bus factor also needs to take into account.

Experience

This is the factor that overrides all previous things mentioned if your project is not tied to any kind of time or budget. Purely for fun. If you are mad at the null pointer you will pick Dioxus. if you want less code and snappy application but are OK with less ecosystem and community, pick Svelte. Otherwise, pick Vue.

I love writings things with Rust. Many people had brags about how good the language is. But my simplest happiness comes when my code compiles and it doesn't crash on runtime. It gives me huge confidence to refactor and add things. But wasm frameworks in Rust are not mature enough. A couple of core features are still unimplemented, Some macro need to be formatted manually, several packages are not maintained, asking things need days to be answered, and even the core building block is on the verge of abandonment5. I take this as a reason why applications that use Rust as their backed still prefer the Typescript/Javascript framework for the front-end.

Writing templates and script is easier in Svelte. The resulting code is also smaller compared to Vue. But many of its third-party code is unmaintained. The community always said that writing them manually is easy. Maybe it is. But if you are tight with time, Vue had a richer ecosystem and bigger community.

At this point, I hesitate to pick Vue because of how easy it is to write things in Svelte. But as many features that (potentially) inspired by Svelte have arrived. I can write less code and have fewer ceremonies in Vue.

Conclusion

Given the reasons and comparison above. I will pick Vue as my primary framework. In meantime, I will keep using Dioxus, reporting its bugs, and interacting with the community. Otherwise, if everyone picks the big things and ditches the all small. What we always have is a faster horse6.

This doesn't mean that Svelte is bad. I don't want to put myself into a box. I will try it again later and get new inspiration.

Is Rust ready to replace Javascript to build a client web application? Currently, it is not. But it will get there eventually.


Thanks to Ricky Irfandi for reading drafts of this.


Footnotes

2

Crates.io doesn't provide either monthly or weekly downloads. I got the number from lib.rs.

5

Trunk, find other related issues with the "maintain" keyword. Seed

3

I can't name any from the Svelte community. One name pops up, but his popularity is not come from producing the Svelte code.

4

Choose Boring Technology by Dan McKinley

6

Rust is not a faster horse by No Boilerplate

Comments