6

The current state of Rust web frameworks

 3 years ago
source link: https://blog.logrocket.com/the-current-state-of-rust-web-frameworks/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Introduction

Rust is one of the most popular language for developers due to its open-source, fast, reliable and high-performance features. When building a new API in Rust, it is important to consider the benefits and drawbacks of web frameworks for front and backend development.

In this article, we will discuss what a web framework is and provide recommendations for which current frameworks to use for Rust in frontend and backend development.

What is a web framework ?

A web framework is a software tool that supports the development of web applications; a web framework can range from a small codebase for micro apps to a large codebase for enterprise apps, and everything in between.

The most extensive web frameworks provide libraries of support for databases, templating, sessions, migration, and other utilities to speed up the development process. More simplistic frameworks focus more acutely on frontend management for static content rendering. Whatever your project needs, web frameworks can provide the web services, web resources, and web APIs that development teams need to help bring their ideas to life.

When choosing the appropriate web framework for your project, your development team should consider the relative importance of the following:

  • Security
  • Flexibility
  • Community growth
  • Project size

Depending on your project priorities, different web frameworks will help you address the your most pressing development requirements. In this article, we will specifically discuss frameworks built with Rust.

What are the benefits of using a web framework?

Web frameworks make web development and building desktop applications easier for developers. By standardizing the building process and automating common activities and tasks, web frameworks can save developers time and even promote reusing code to increase efficiency.

In the following sections, we will review web frameworks in Rust as they pertain to front and backend development. We will then assess each framework phase in terms of stability, production-readiness, and project size.

Frontend web frameworks and Wasm

WebAssembly(Wasm) is a relatively new type of coding in low-level languages that can be run in modern web browsers. It supports languages including C/C++, C#, Golang, and Rust, with a target compilation for byte code so they can be run on the web with nearly-native performance. Wasm output is run alongside JS and can be published to npm and other packages.

Rust uses a tool called wasm-pack to assemble and package crates that target Wasm. Learn more about getting started with Wasm and Rust here.

The following are some of the frontend web frameworks designed for Rust (Wasm);

stdweb

stdweb is a frontend standard library that gives Rust the power to communicate directly with JavaScript web APIs. It was crafted to give developers the power to create full-fledged JavaScript apps in Rust by providing easy API binding between the languages to improve speed and performance.

stdweb support closures, arbitrary structure, and standard components of web APIs including DOM, events, and windows. Here’s a link to a few sample projects to get a grasp of how it works.

Overview:

  • Stable: yes
  • Production-ready: no
  • Project size: small

Yew

Yew is an improved version of stdweb. It is a components-based framework (similar to React and Elm) with support for multi-threading, component-based patterns, and other features similar to stdweb.

Overview:

  • Stable: yes
  • Production-ready: no
  • Project size: small, medium and large

Percy

Percy is a toolkit developed for building single-page apps (SPA) and managing UI, including optimization for specific browsers and screens (desktop, mobile). Percy is still a work in progress; improvements are needed for better structure, optimal boilerplate, and general bug fixes.

Overview:

  • Stable: no
  • Production-ready: no
  • Project size: small, medium and large

Sauron

Sauron is an outdated micro frontend framework that was inspired by The Elm Architecture. It has support for events, state management, and components. Sauron uses a library called html2sauron to convert html into sauron view code for rendering optimization.

Overview:

  • Stable: no
  • Production-ready: no
  • Project size: small

Seed

Seed is a frontend framework for creating performance-driven and reliable web apps that also has an Elm-like architecture. It has minimal configuration and boilerplate, and has clear documentation that makes it easy for anyone to start with.

Overview:

  • Stable: yes
  • Production-ready: no
  • Project size: small, medium and large

Smithy

Smithy is written in native Rust code, which makes for an easy learning curve for developers. It has support for interpolation and sub-component, events, state management, interaction with JavaScript, the smd! macro (inspired by React’s Jsx), and server support for deployment.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project size: small, medium and large

For the best documentation and impressive support for interpolation with JavaScript, I recommend Yew and Smithy for frontend development frameworks in Rust.

Backend web frameworks

Backend development refers to the server-side operation of a web app. It also describes the core operations of an app that usually control and handle its data and actions, such as submitting a form or logging into a web account. Backend development focuses primarily on data management, and the database, scripting, automation, and architecture necessary to handle it.

Rust provides various web frameworks for backend development, including a combination of tools, helpers, and libraries from different vendors that are each designed to provide a way to build, test, and run apps with efficiency, security, and flexibility.

Some of the most common features of a typical backend development framework includes:

  • Database management
  • Session
  • Templating
  • Object-relational mapping (ORM)
  • Migrations

Rocket

Rocket is a popular, mature web framework that makes it easy for developers to write fast web apps without skimping on security, flexibility, or function . It has support for testing library, cookies, streams, routes, template, database, ORM, boilerplate, and more. Rocket also has a large and active developer community.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project size: small, medium, large

Actix

Like Rocket, Actix is a powerful backend web framework. Actix features an architectural pattern based on Rust’s actor system, and is well-equipped for building writing services and micro apps. It has support for routing, middleware, testing, websocket, database, and automatic server reloading, and can be hosted on NGINX. Actix can be used to build a full-scale web app and API.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project size: small, medium

Gotham

Gotham is a flexible web framework built for stable Rust that promotes “stability, safety, security and speed.” It is statically typed, thereby ensuring that application is always correctly expressed at compile time. Gotham provides async support with the help of Tokio and hyper.

Gotham supports routing, extractors(type-safe data requests), middleware, state sharing, and testing. Gotham does not have structure, boilerplate, or database support.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project size: small, medium, large

Rouille

Rouille is a micro web framework that employs a linear request and response design via a listening socket that parses HTTP requests. It is built to be easy-to-learn for Rust users. Rouille has support for request through CGI, input(request headers and body), content encoding, proxy, sessions, and websocket.

Overview:

  • Stable: yes
  • Production-ready: no
  • Project size: small

Nickels

Nickels is a minimal, lightweight framework for web apps written in Rust. Its API is inspired by the popular Express framework for JavaScript. It provides flexible routing, middleware, JSON handling, custom error handler, templating, and boilerplate.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project-size: small, medium

Thruster

Thruster is a fast and reliable Rust web framework inspired by the layering and design of Koa and Express. It is SSL-ready, secure, intuitive, and testable. Thruster is built to accommodate async/await and provides support for middleware, error handling, database, and testing.

Overview:

  • Stable: no
  • Production-ready: no
  • Project-size: small

Iron

Iron is a web framework for Rust that is built in hyper with a focus on concurrency, extensibility, and minimal excess. It can scale horizontally across multiple machines, or run multiple threads on a more powerful machine. Because it was designed to be extensible and pluggable, Iron primarily addresses middleware, plugins, and modifiers (third-party extensions) as its main components.

Iron provides support for routing, JSON body parsing, URL encoded data parsing, session, and static file.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project-size: small

Tide

Tide is a minimal framework (similar to express(node), Sinatra(Ruby), and flask(python)) for rapid development that promotes building web apps in asynchronous version.

Tide provides support for routing, auth, listener, log, template engines, middleware, testing and other utilities.

Overview:

  • Stable: yes
  • Production-ready: yes
  • Project-size: small, medium, large

For backend web frameworks building advanced web apps, I recommend Rocket, Actix and Tide (for asynchronous support). They are all also accepted in the Rust community and each provides a large support library.

Conclusion

When choosing the correct web framework for your frontend or backend development project, it is important to consider the following: is the framework stable? Is it production-ready? It is right for the size of your project?

Depending on your answers, you will be on your way to using web frameworks to improve efficiency, speed, and productivity in Rust.

LogRocket: Full visibility into production Rust apps

Debugging Rust applications can be difficult, especially when users experience issues that are difficult to reproduce. If you’re interested in monitoring and tracking 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 apps, recording literally everything that happens on your Rust app. 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.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK