Developers can use frameworks with Rust to build fast, highly scaleable, memory-efficient software. Whether you’re building a CLI tool, web apps for the server or client, network services, embedded systems software or desktop software, Rust is robust enough to cater to all your programming needs.
A framework is typically a combination of tools, helpers, and libraries that provide a way to (quickly and effortlessly) build, test, and run applications. It lays out a foundation for building software. Key aspects to look out for when choosing a framework are its architecture and features (such as support for customization, flexibility, extensibility, security, compatibility with other libraries, etc).
This article aims to showcase several Rust frameworks across different niches, highlighting their strengths and shortcomings. By the end, you should be able to make informed decisions regarding the Rust framework suitable for your needs.
With 8k stars on GitHub, Rocket is one of the most mature, production-ready, full-stack web frameworks. Its major strong point is that it doesn’t make you sacrifice speed for a productive environment and vice-versa like many frameworks do. It helps write fast, secure web applications and doesn’t sacrifice flexibility, usability or type safety.
Other cool things to note include:
My favorite feature is not having to worry about boilerplate code. Rocket makes extensive use of Rust’s code generation tools to provide a clean API, so if you want to build a server-rendered web app, Rocket is a great tool. See more on the super easy-to-understand documentation.
Actix a server-rendered framework. The architecture is based on Rust’s very powerful actor system and touts itself to be a fun web framework to work with. According to this benchmark, Actix is the fastest web framework. It’s well suited for writing services with hard logic and components. You get to also use these services in an async way.
It also provides a lot of features (like logging, http/2, etc.) out of the box. Depending on your preference, it’s boilerplate code could help you get started quickly or be overkill if you’re writing a simple app. It is a great framework with proper documentation. Learn how to get started here. It’s approachable even for the absolute beginner.
Nickel is also a web framework for building server-rendered web applications. It is a simple and lightweight foundation for web applications written in Rust. Its API is inspired by the popular express framework for JavaScript.
It is non-opinionated about how you should write your code which means it does not come with a template or give specific methods of doing things and has a more gradual learning curve. Nickel supports defining templates with mustache.rs, all you need is to create the template.
Nickel makes it easy to map JSON data directly right onto your struct
, and by default, Nickel catches all errors with its default ErrorHandler
and tries to take reasonable actions. So no need to write your own custom errorHandler.
Routes can be as simple as /fizzBuzz, use parameters, wildcards or even double wildcards. Middleware are the extensibility points of Nickel. It comes right out of the box with existing Middleware which you can extend should you wish to. The getting started guide can help you right away.
Inspired by Elm and React, Yew is a modern framework for building multi-threaded web-client apps with WebAssembly commonly referred to as WASM. It packs a number of great features like:
Some of the cons include:
Very similar to JavaScript’s Electron, Azul is a free, functional, immediate-mode GUI framework for the rapid development of desktop applications written in Rust, supported by the Mozilla WebRender rendering engine. It packs a lot of useful features:
Cons include:
Get started here.
Conrod is a portable, 2D, GUI library for Rust. It provides an immediate-mode API that wraps a retained-mode widget state graph, allowing for the exposure of a simple, robust and reactive interface while approaching the performance of traditional, retained GUI frameworks.
Intermediate-mode refers to a style of user interface API, where GUI widgets are instantiated using functions in an update or draw loop which is quite different from the more traditional “retained mode”, where widget types are constructed during the setup stage.
Features include:
Get started here.
Based on Qt which is a very mature cross-platform user interface library. There exists a wrapper for most languages out there and of course, Rust isn’t going to be an exception.
It enjoys all the immense benefit of Qt and of course the small binary sizes which is a trademark feature of rust. These features include:
Cons include:
With Qt being a proven framework for cross-platform app development being supercharged with Rust makes this framework formidable and probably the most mature GUI Rust framework. You won’t have to worry about huge builds and interface complexity since the Rust Qt Binding Generator was rewritten in Rust and now available as a cargo crate. This makes development in the common case significantly simpler.
As a low-level language, Rust is perfectly suitable for making user interfaces the old fashioned way, with native APIs. Sadly, in today’s world, which typically involves supporting many platforms, using native APIs is an unattractive option for many.
However, Rust’s expressiveness and high-level abstractions make it ideal for building intricate and complex user interfaces. Unfortunately, there is little consensus on what the best abstractions are especially with the uniqueness of the web. Use what works for your use case and iterate as the need arises.
There are many more Rust based web and GUI frameworks that are in their infancy like core foundation, druid, Iced, relm, and web renderer to mention a few. You can check them out, contribute or even spin up your own framework.
For the an assessment of Rust frameworks in 2020 and beyond, check out the current state of Rust web frameworks.
Happy coding 😀.
Debugging Rust applications can be difficult, especially when users experience issues that are hard to reproduce. If you’re interested in monitoring and tracking the performance of your Rust apps, automatically surfacing errors, and tracking slow network requests and load time, try LogRocket.
LogRocket is like a DVR for web and mobile apps, recording literally everything that happens on your Rust application. Instead of guessing why problems happen, you can aggregate and report on what state your application was in when an issue occurred. LogRocket also monitors your app’s performance, reporting metrics like client CPU load, client memory usage, and more.
Modernize how you debug your Rust apps — start monitoring for free.
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up nowFrom basic syntax and advanced techniques to practical applications and error handling, here’s how to use node-cron.
The Angular tree view can be hard to get right, but once you understand it, it can be quite a powerful visual representation.
Build a fast, real-time app with Relay 17 to leverage features like optimistic UI updates, GraphQL subscriptions, and seamless data syncing.
Simplify component interaction and dynamic theming in Vue 3 with defineExpose and for better control and flexibility.
One Reply to "The best Rust frameworks for web dev and desktop apps"
Thanks for this article. Very useful.