Contents

Learning Rust - Front End Developer’s Perspective

Jakub Antolak

15 Jan 2024.6 minutes read

Learning Rust - Front End Developer’s Perspective webp image

Rust has been named one of the most loved technologies by software developers in recent years, not without a reason. It is fast, well designed, and a well documented programming language, providing great developer experience. It gained support among many coders, especially those working with similar but older technologies like C or C++. Could it be worth learning for a front end developer? And, if so, why?

Well, for a couple of reasons.

Front End Tooling

Rust and other low-level languages have been present in the front end space for quite some time now. More and more frontend tools are written in languages coming outside of the JavaScript “bubble”. Popular bundlers like Webpack or Rollup have gained faster competitors like Esbuild (written in Go) or SWC (written in Rust). Vercel is developing a Rust-based “successor to Webpack”: Turbopack. Also, part of the Parcel is written in Rust.

And the list does not end here. Node.js, the main pillar of JavaScript backend for many years, has its Rust-based counterpart: Deno. Rome, Facebook’s big toolchain project, renamed to Biome, has been (re)written in Rust. Volta, a JavaScript tool manager, is also developed in this language.

Rust is here. The more front end developers will use newer and faster tools built with it, the more they may need to interact with the language these tools were written in. It might be simply useful to know Rust, at least on the basic level.

Front End Applications

Web Assembly opened the door to the web for compiled, low-level languages. Some popular apps like Photoshop or AutoCAD are available to use in the browser today. More and more products are being created with the web platform in mind.

Rust has a WASM compilation target, which means that you can run your code in the browser. That includes things reserved until fairly recently for JavaScript: accessing web APIs, DOM manipulation, etc. There are quite many Rust UI libraries aiming to outperform their JavaScript counterparts, like Egui, Yew, or Leptos. Many are being developed. There is also a Rust-based alternative for the Node-based desktop app platform Electron: Tauri.

You can write frontend in Rust, then. Of course, that does not mean that JavaScript will be forgotten. At least not in the foreseeable future. It still has the advantage of a rich, flourishing ecosystem, flexibility of expression, less steep learning curve, and ease of use. Also, in some cases JS libraries may still be faster than your WASM binary. But that will surely change over time.

Partner with Typesctript, React and Next.js experts to make an impact with beautiful and functional products built with rock-solid development practices. Explore the offer >>

Developer Experience

You probably heard about the JavaScript Fatigue. As it states on Quora:

It refers to the exhaustion and frustration experienced by developers when trying to keep up with the rapid pace of change and the sheer number of tools, frameworks, and libraries in the JavaScript ecosystem. This can include the pressure to constantly learn new technologies, the difficulty of choosing the right tools for a project, and the challenge of maintaining existing code in a landscape that is constantly evolving. This phenomenon has led to discussions about the need for stability and standardization within the JavaScript community.

That’s why, for me, Rust stands out. I’ve been working with complicated frontend projects that used different bundlers, linters, and formatters altogether, and there were many cases where conflicting module types, conventions, etc. were preventing me from completing simple tasks quickly.

Rust seems to be designed in a very thoughtful manner. There is a main tool you should use: Cargo. It’s a build tool and a package manager. It also provides linting and formatting mechanisms. And, it has a clippy command that can teach you some useful things.

This consolidation makes work much easier and doesn’t throw you into neverending debates about the superiority of one tool over another.

How to learn?

That said, you may ask: where to start?

If you began the programming journey with JavaScript, and it is your first language, you come from a place where, for the sake of flexibility, many things are done behind the scenes. The garbage collector takes care of freeing the memory from unused data. Numeric types are consolidated under one Number type. Strings are “just” strings, etc. Rust’s learning curve might become even more steep, then!

But don’t worry, with proper strategy, you can do it. Here’s a list of 10 things that helped me to jump from a total noob to quite a fluent beginner.

  1. Focus on the basics. Read the book “Rust Programming Language” by Steve Klabnik and Carol Nichols. Carefully study the first six chapters covering data types, functions, control flow, ownership, structs, and pattern matching.
  2. Try to write simple programs (the book encourages you to do so). You can try the Rustlings course, or any other course on the Internet. And when confused, check Rust by Example. Or ask Chat GPT. AI can be a great learning partner.
  3. Take breaks if your brain can’t take in more. Time off is crucial for organizing newly acquired knowledge.
  4. Don’t copy-paste, write code on your own. It will help you memorize keywords and become familiar with the language.
  5. Learn to read the docs. For me, getting to know traits helped a lot with understanding the structure of any library’s documentation. There is also a Rust Doc Book covering the topic. And again, AI assistants like Chat GPT can help you digest the documentation and get desired information.
  6. Find a field you’re interested in. Maybe you already have one. Try to write a program that does “your thing” or rewrite the one you already have in Rust. It will bring more battlefield knowledge to your arsenal! For me, such a thing was doing generative art to be drawn with a pen plotter.
  7. Contribute to open source projects, when you feel confident enough. From my experience, the Rust community is cheerful and welcoming. Helping with open source will bring experience of solving real world problems. Vsvg library was my starting point.
  8. Focus on the basics. Again. Yes, you read that correctly! In an era of short attention spans we tend to skip parts of the content that may seem uninteresting or not needed. This is error prone, therefore it’s good to iterate and revisit parts of the content you’ve consumed once upon a time.
    This was my case. After a few months, I came back to the chapter about ownership and borrowing. It made me realize that my knowledge was lacking some key parts. Re-reading it was insightful, and let me better understand the program I wrote a few days earlier, which brings us to the next part.
  9. Review your work. Apply regained knowledge. Rediscovered information might improve your code, where you would not even expect.
  10. Use Clippy. I mentioned it a few paragraphs above, but I want to highlight it. Clippy is a unique feature of Cargo, “a collection of lints to catch common mistakes and improve your Rust code”. It will become one of your best friends on the way.

The list could be longer, probably. You can shape it in a way that fits you the most. There are tons of programming learning resources, but when you start, it might be clever to stick close to the source.

But whatever way you will go, I keep my fingers crossed for your learning process and I hope you’ll have as much fun with it as I do!

Post Scriptum

For more awesome Rust-based, front end related things, check the following links:

Techreviewed by: Marcin Baraniecki, Tomasz Krawczyk, Krzysztof Grajek

Frontend

Blog Comments powered by Disqus.