Actix: A new actor system that will add some polish to Rust
Actix is a powerful, ultra-fast, lightweight framework for Rust with a few tricks up its sleeve. What are its features out of the box and what can it do for you?
Rust is proving that it shouldn’t be ignored. According to the 2018 StackOverflow developer survey results, Rust took first place in the most loved language category for the third year in a row. In the 2017 GitHub Octoverse report, Rust showed up as the fifth most-discussed repository as well as the eighth most reviewed project. And yet, it was nowhere to be seen on the top fifteen most popular languages. So, what’s the catch? Why aren’t more people coding with Rust?
One of the reasons Rust isn’t topping the charts might be the lack of tools. The 2017 Rust survey revealed that 10% of people who stopped using Rust felt the language did not have tools that were mature enough. Rust seems difficult, foreboding, and doesn’t come with the same amount of tools that other languages do.
Draw the curtains back, there’s a new actor in town. Actix is an actor framework for Rust that might just pull some new crew members on board to the programming language and is easily picked up by those who are already coding in Rust.
From the getting started guide, “An application developed with actix-web will expose an HTTP server contained within a native executable. You can put this behind another HTTP server like nginx or serve it up as such. Even in the complete absence of another HTTP server actix-web is powerful enough to provide HTTP 1 and HTTP 2 support as well as SSL/TLS. This makes it useful for building small services ready for distribution.”.
Its developers refer to Actix as a “microframework” but its features are anything but small. It is type safe, feature rich, responsive, extensible, and of course, seriously fast. Its small size keeps it lightweight, without any unnecessary bloating to affect performance.
By focusing on speed and ease of use, Actix doesn’t get bogged down with any extras that you’ll never find yourself using.
Rust’s actix-web used correctly is a really beautiful thing. This is the unmodified code from one of our services. pic.twitter.com/1AbuPYMYXr
— Armin Ronacher (@mitsuhiko) April 30, 2018
From the Actix homepage, here’s some features that let Actix speak for itself:
- Flexible responders
Handler functions in actix can return a wide range of objects that implement the
Respondertrait. This makes it a breeze to return consistent responses from your APIs.
- Powerful extractors
Actix comes with a powerful extractor system that extracts data from the incoming HTTP request and passes it to your view functions. Not only does this make for a convenient API but it also means that your view functions can be synchronous code and still benefit from asynchronous IO handling.
- Easy form handling
Handling multipart/urlencoded form data is easy. Just define a structure that can be deserialized and actix will handle the rest.
- Request routing
An actix app comes with a URL routing system that lets you match on URLs and invoke individual handlers. For extra flexibility, scopes can be used.
Here’s to a new tool for Rust and may many more be just over the horizon! Perhaps this language will no longer be pushed to the back-burner and the next usage poll will reflect people’s interests in learning it.