Learning Rust as a Front End Developer
Is the Rust programming language worth learning if you are a front-end developer? The article answers that question.
In recent years software developers have repeatedly voted Rust among the most loved technologies, and for good reason. It is a fast, thoughtfully designed and well documented programming language that offers an excellent developer experience. Many programmers have embraced it, particularly those used to comparable but older technologies such as C or C++. But is it worth learning for a front end developer? And if it is, why?
There are actually several reasons.
Front End Tooling
Rust and other low-level languages have had a place in the front end world for a while already. A growing number of frontend tools are written in languages from outside the JavaScript “bubble”. Well-known bundlers such as Webpack and Rollup now face faster rivals like Esbuild (written in Go) and SWC (written in Rust). Vercel is building a Rust-based “successor to Webpack” called Turbopack. Part of Parcel is written in Rust as well.
That is not the end of the list. Node.js, which has been the backbone of JavaScript on the backend for years, now has a Rust-based counterpart in Deno. Rome, Facebook’s large toolchain project, since renamed to Biome, has been (re)written in Rust. Volta, a JavaScript tool manager, is also built in this language.
Rust has arrived. As front end developers adopt more of the newer, faster tools built with it, they may increasingly need to deal with the language behind those tools. Simply knowing Rust, at least at a basic level, could turn out to be handy.
Front End Applications
Web Assembly brought compiled, low-level languages to the web. Well-known apps such as Photoshop and AutoCAD can already be used in the browser. A growing number of products are built with the web platform as their target.
Rust offers a WASM compilation target, so your code can run in the browser. This covers tasks that until quite recently belonged to JavaScript alone: calling web APIs, manipulating the DOM and so on. Quite a few Rust UI libraries aim to beat their JavaScript equivalents, for example Egui, Yew and Leptos. Many more are in development. There is even a Rust-based alternative to Electron, the Node-based platform for desktop apps: Tauri.
So yes, frontend can be written in Rust. That doesn’t mean JavaScript will fade away, of course – certainly not anytime soon. It still benefits from a rich, thriving ecosystem, expressive flexibility, a gentler learning curve and ease of use. In some situations JS libraries may also still run faster than your WASM binary. That will certainly shift over time, though.
Developer Experience
You have likely come across the term JavaScript Fatigue. Here is how Quora describes it:
It describes the weariness and frustration developers feel as they try to keep pace with how quickly the JavaScript ecosystem changes and with the enormous number of tools, frameworks and libraries in it. This may involve the pressure to keep learning new technologies, the struggle to pick the right tools for a project, and the difficulty of maintaining existing code in an environment that never stops changing. The phenomenon has sparked discussions about the JavaScript community’s need for stability and standardization.
This is exactly why Rust stands out to me. I have worked on complex frontend projects that combined several bundlers, linters and formatters, and on many occasions clashing module types, conventions and the like kept me from finishing simple tasks quickly.
Rust appears to have been designed with a lot of care. There is one main tool you are meant to use: Cargo. It serves as both a build tool and a package manager, and it also handles linting and formatting. On top of that, it offers a clippy command that can teach you a few useful things.
Having everything in one place makes work much simpler and spares you endless arguments over which tool is better than another.
How to learn?
Which raises the question: where do you begin?
If JavaScript was where your programming journey started and it is your first language, you are used to an environment where a lot happens behind the scenes for the sake of flexibility. The garbage collector frees memory taken by unused data. All numeric types are merged into a single Number type. Strings are “just” strings, and so on. For you, Rust’s learning curve may be even steeper!
Don’t worry, though – with the right approach, you’ll manage. Below are 10 things that took me from a complete noob to a fairly fluent beginner.
- Concentrate on the basics. Read “Rust Programming Language” by Steve Klabnik and Carol Nichols. Study the first six chapters thoroughly – they cover data types, functions, control flow, ownership, structs and pattern matching.
- Write simple programs (the book nudges you to do this anyway). Give the Rustlings course a try, or any other course available online. When something puzzles you, look at Rust by Example. Or ask Chat GPT – AI can make an excellent study buddy.
- Take a break when your brain can’t absorb any more. Rest is essential for putting newly gained knowledge in order.
- Avoid copy-pasting and type the code yourself. This helps you remember keywords and get comfortable with the language.
- Learn how to read the docs. In my case, understanding traits made it much easier to grasp how any library’s documentation is organized. The Rust Doc Book covers this topic too. And once more, AI assistants such as Chat GPT can help you digest documentation and find the information you need.
- Pick a field that interests you. You may already have one. Try writing a program that does “your thing”, or port one you already have to Rust. This will add hands-on, real-world knowledge to your toolkit! For me, that was creating generative art to be drawn by a pen plotter.
- Contribute to open source projects once you feel ready. In my experience, the Rust community is friendly and welcoming. Working on open source gives you experience in solving real world problems. My starting point was the Vsvg library.
- Concentrate on the basics. One more time. Yes, that’s not a typo! In times of short attention spans we often skip bits of content that look dull or unnecessary. That invites mistakes, so it pays to iterate and return to material you went through some time ago.
That’s what happened to me. A few months in, I went back to the chapter on ownership and borrowing and discovered that my understanding had some important gaps. Reading it again was eye-opening and helped me make better sense of a program I had written a few days before, which leads to the next point. - Revisit your work. Put the refreshed knowledge to use. What you rediscover may improve your code in places you would never expect.
- Use Clippy. I brought it up a few paragraphs earlier, but it deserves emphasis. Clippy is a distinctive feature of Cargo, “a set of lints that catch common mistakes and make your Rust code better”. It will turn into one of your best companions along the way.
The list could probably go on. Feel free to adapt it to whatever suits you best. Programming learning resources are countless, but when you are just starting, staying close to the source may be the smart move.
Whichever path you choose, I’m keeping my fingers crossed for your learning journey, and I hope you enjoy it as much as I do!
Post Scriptum
For more great Rust-based, front end related material, have a look at these links:
- Awesome JS Tooling in Rust
- Awesome Rust
- Awesome Rust and Web Assembly
- Rust front end framework comparison