3 ms·
I agree that Express/Slim/Flask is a better comparison. But, to answer your core question, there are a few different reasons: * Performance. The simple, strai
by steveklabnik 6y ago
I agree that Express/Slim/Flask is a better comparison.
But, to answer your core question, there are a few different reasons:
* Performance. The simple, straightforward Rust code will often be much faster than the usual suspects here. Sometimes, I/O is your bottleneck, but sometimes it's not. Maybe you only move some backend services over. npm is an example of a company that did this; some high performance services were implemented in Rust because Node was struggling.
* Consistency. Resource usage tends to be very flat. This helps with things like capacity planning, but also reliability (which is a later bullet point).
* Cost. This is directly related to performance, but also on a different axis: memory usage. We've seen people switch code to Rust, and while the performance doesn't change things for end users, the extra overhead means smaller servers, or less servers, which translates directly into $$$. There are some big, not super public success stories here I wish I could tell you about, but a public example is Rubygems. They had a lambda doing some log processing, and the performance benefit of Rust made things fast enough to move it onto lambda's free tier. Infinity savings! (Though of course it was actually from $12,000/year -> $0)
* Reliability. Back to the npm use-case, they had a lot of ops issues with Node. The Rust code ran for something like a year, year and a half, before ever having a single production issue. Static typing helps here, less variable resource usage helps here.
* Static types. Some people have come to prefer developing in a language with static types. Rust doesn't have a monopoly here, but it is among very few languages that have many of its features, and many of them don't check those previous boxes.
Of course, things aren't a panacea either. The ecosystem isn't as mature, even if this web page says it is. Async is great, but not perfect. Some people really do not like static types. Etc.
- 40four 6y agoI'll admit, the performance benchmarks on actix-web are very impressive! Thanks for the detailed response, I have an eyebrow raised :)
- MaxBarraclough 6y agoDoes Rust significantly outperform Java and C#?
- steveklabnik 6y agoGenerally. As always, devil is in the details. Rust usually has a very similar performance profile to C and C++. The memory usage part is where Rust is clearly at a stark advantage in that comparison.
- stjohnswarts 6y agoYes, probably by a factor of 2-10x in most situations. Also memory footprint is going to be far lower too, so cheaper servers/leasing of resources. It's great for webapps (or restful backends) on embedded systems in particular. As always though I've seen people far more likely to be bottlenecked on I/O and database requests than on raw computing power. Usually even python and ruby are waiting on something else :) . Amdahl's Law is always worth keeping in mind.