Originally published by TYLER CHARBONEAU at nordicapis.com
Originally a personal project of Mozilla’s Graydon Hoare, Rust’s development began in 2006. It first said Hello World
following its official announcement by Mozilla in 2010. Though Rust hasn’t enjoyed Python’s colossal growth, users love the language immensely. Rust topped Stack Overflow’s “most loved programming languages” ranking list in 2016, 2017, and 2018. We only expect it to grow more popular — especially since it’s continually being refined.
We previously assessed the various pros and cons of Rust, and find it incredibly useful. The language shares many similarities with C and C++, while offering essential syntax modifications of its own. Accordingly, developers praise Rust for its open-source development and performance. This makes it a prime candidate for API creation. Below, we’ll review three superb frameworks for building APIs using Rust.
“rust’s powerful actor system and most fun web framework”
Built for speed and supportive of modern features, Actix-web is a framework focused on safe API creation. It was built to be usable and lightweight. Initially released in October of 2017 and maintained by Nikolay Kim, Actix-web supports the Actix actor framework. It has active Gitter and Reddit communities, and GitHub contributions are always welcomed. Actix-web is open source and has 108 contributors on GitHub. With over 2,500 commits and 89 releases, the framework is continually in development. Microsoft uses Actix-web in some applications, though additional details are murky.
unsafe
code instances to allow for improved performance, though this has been mitigated in recent versions“Rocket is a web framework for Rust that makes it simple to write fast, secure web applications”
Built using Rust’s core principles, Rocket is an excellent open-source framework for developers seeking a comprehensive toolset. Rocket includes a plethora of pre-packaged features, yet is quite extensible. Sergio Benitez publicly released Rocket in December of 2016, and remains a key contributor to date. Rocket doesn’t appear to have a bustling community via IRC, or stemming from its website. However, Rocket’s news blog helps developers keep abreast of ongoing changes. Accordingly, its development effort is strong. At the time of writing, 128 GitHub contributors have aided Rocket’s development since launch, and there have been over 1,250 commits. Having been updated 45 times following initial release, the current build of Rust is v0.4. On average, a new version of Rocket is released approximately every 18 days.
Serialize
or Deserialize
. Using the FromData
trait ensures easy value creation by typeApiKey
guards prevent unneeded sensitive operations, enforcing both type and API-header validationsTower Web is a fast web framework that aims to remove boilerplate.
With a focus on simplifying API development via boilerplate removal, Tower Web is a lean-yet-powerful Rust framework. It’s built upon Tower, a complimentary library containing useful network components. Much like Actix-web leans on Actix, Tower Web does the same with Tower. It’s also built upon Tokio and Hyper – a non-blocking I/O platform and HTTP client, respectively. As a result, Tower Web is a well-rounded platform ready to tackle Rust API development. It’s also relatively new – Carl Lerche released Tower Web in August of 2018. He currently spearheads development efforts on GitHub, alongside 24 contributors. Since inception, it has been updated 11 times, approximately one release every 22 days. Its current version is v0.3.6.
Actix-web’s big advantages lie in two areas: actor management and speed. If you’re building out a web application based around accounts (email, web services with SOAP endpoints), the framework truly shines. This actor support is available in other frameworks like Rocket, though Actix-web’s implementation is more elegant. API builds reliant on the WebSockets protocol will mesh harmoniously with Actix-web. If you’re trying to squeeze as much performance out of your web servers as possible, the protocol’s low overhead will facilitate that.
If you want to be on the bleeding edge and design web applications in compliance with emerging standards, Rocket is a great choice. That’s not saying the framework falters in other scenarios, but its current reliance on nightly Rust does raise stability concerns. Because Rocket isn’t asynchronous, it can only handle so many connections at any given time. Consequently, it may be better suited to smaller projects, or at least to web applications where active requests are minimized. However, Rocket is quite adept at handling large quantities of data. As the framework matures, it may very well power some large, high-profile projects. Rocket takes much of the guesswork out of the equation for newer users.
For developers looking to write the leanest code possible, Tower Web is a fantastic option. Boilerplate code has been placed on the chopping block, cutting down on production time. Code written within Tower Web has purpose, which can truly help with larger projects. It’s also straightforward to incorporate middleware into Tower Web – simplifying API creation and promoting a better experience for the end user. Fully asynchronous, the framework can also handle a massive amount of requests in parallel. Popular services built around numerous sessions will benefit significantly from this.
Originally published by TYLER CHARBONEAU at nordicapis.com
========================================
Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter
☞ The Rust Programming Language
☞ Rust: Building Reusable Code with Rust from Scratch
☞ Programming in Rust: the good, the bad, the ugly.
☞ An introduction to Web Development with Rust for Node.js Developers
☞ Intro to Web Development with Rust for NodeJS Developers
☞ Introducing the Rust Crash Course
#rust #web-development