DEV Community

andythedishwasher
andythedishwasher

Posted on

Yew can do it!

So I've only been exploring Rust seriously for the past couple of weeks, but I already see some pretty amazing things happening. I've started learning about how it works server-side with Actix Web and how it can run game scripts with Godot or even whole new Rust engines like Bevy (though those are still in beta for the most part).

What I've been the most excited about, however, is the possibility of using Rust for web development. Javascript has, to put it mildly, invoked a lot of ire in the web development community over the years. Its dynamic type system is notorious for creating runtime errors that the compiler doesn't have the necessary information to catch prior to a deployment. These errors are one of the major reasons that large-scale Javascript teams often have to spend almost as much time, energy, and manpower on testing as they do on the development itself.

Rust, on the other hand, has a beautiful set of features collectively known in The Rust Book as Ownership and Lifetimes. These concepts work together to form Rust's highly specific rules surrounding memory management of variables. These rules, without diving too deep into the ampersands and double colons, serve to ensure that if any variables are accessed at a time when they may not contain the expected value, the compiler will be aware of the fact and request a confirmation in the form of some identifier for the unsafe behavior or suggest an alternate approach to retrieving the value, all before the code ever actually runs incorrectly!

And now, we may finally be to the point where we can get these guarantees for web development! While Yew is still in beta and as such isn't stable enough for production builds yet, it appears to be an extremely smooth workflow. Build times are extremely reasonable. The directory sizes are entirely manageable. The only slight performance issue seems to be the time required to build the initial page content from the web assembly and Javascript, but once it is built, everything operates at excellent speeds as one would expect from memory-safe Rust code.

Below are links to a hosted demo of a calculator I built with Yew and a Github repo for it. While it is unfortunately not production ready, my hope is to generate more interest in Yew's development and external support so that it has an easier time getting off the ground. It will be a great relief to leave web development in Javascript behind, but until then, thanks Web Assembly!

Rust Calculator Built With Yew
Github Repo

πŸ‘‹ Take one minute to check this out

Tired of spending so much on your side projects? πŸ˜’

We have created a membership program that helps cap your costs so you can build and experiment for less. And we currently have early-bird pricing which makes it an even better value! πŸ₯

Just one of many great perks of being part of the network ❀️

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay