3 ms·
> Yes! And it's freaking fast! Going by these benchmarks (click around to find your own use case) Rust is definitely fast, but not (much) faster than many othe
by jeroenhd 5y ago
> Yes! And it's freaking fast!
Going by these benchmarks (click around to find your own use case) Rust is definitely fast, but not (much) faster than many other languages, including Javascript. https://www.techempower.com/benchmarks/#section=data-r20&hw=ph&test=composite https://www.techempower.com/benchmarks/#section=data-r20&hw=...
When it comes to JSON serializers, there is a Java framework that is faster than Rust, which is interesting to say the least. When you start comparing actual fully-features frameworks, many Rust libraries even lose their advantage!
There are definite benefits to Rust web frameworks (despite the minimal speed diff, Rocket or similar can have less than half the RAM requirements that other languages run into!) but just because Rust compiles to machine code doesn't mean it'll revolutionize your web application.
> These provide everything you’d expect from a web framework, from routing and middleware, to templating, and JSON/form handling.
One problem I've run into is that I wanted to give Rust a try for a basic CRUD application but the features just weren't built in or available in packages. Some frameworks were missing CSRF, others were missing multipart/form uploads, and so on. Online discussions often end up concluding that "it's easy to write the middleware yourself, see this hacky POC", but this type of code is easy to mess up and easy to break with API upgrades.
Tide and Warp seem to have matured quite well, so I guess I'll have to give them a go at some point, but I'm a little sceptical. The status of this issue (https://github.com/http-rs/tide/issues/852 https://github.com/http-rs/tide/issues/852) is a little disheartening...
- 41b696ef1113 5y agoNot that I think those metrics are all that relevant, but can someone explain to me how just-js ranks so highly? Very much defying my expectations in comparison with some of the top representatives of compiled languages.
- jeroenhd 5y agoI honestly don't know. It could be a consequence of the way the test is set up, or how the total score is calculated, or maybe the code was optimized better than other frameworks were. You read see the source of the tests here: https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/JavaScript/just https://github.com/TechEmpower/FrameworkBenchmarks/tree/mast... The SQL code seems quite optimized (manually compiling database packets instead of using a library). Most code seems quite static and very small, so it's probably very quick. I don't think you can actually use the framework like that in practice, though.
- tempest_ 5y agoA huge amount of time and money has been spent making JS as fast as it can be. Additionally a lot of these benchmarks focus on things that the JS engines are very good at. It isnt like they are running CPU intensive tasks in JS.
- NavinF 5y agoNot sure, but it’s pretty funny how the most popular frameworks (rails, Django, flask, laravel, etc) are way at the bottom with 3% the score of the winner. Apparently async db requests and batching transactions are the key to winning on that benchmark: https://news.ycombinator.com/item?id=24315512 https://news.ycombinator.com/item?id=24315512 I wish more benchmarks would produce latency vs requests/second curves in microseconds. I bet the latency is massive due to batching.
- ipaddr 5y agoThere fortune test is weight 1.5 while others are weighted at 1 or .75.
- ibraheemdev 5y agoIf you look at the techempower submission source code you'll quickly see why: https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/JavaScript/just/lib/connection.js https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast....
- dralley 5y agoI so deeply wish for a set of benchmarks that accepted only idiomatic, standard code that a slightly above average developer would plausibly write. Pretty much every set of benchmarks out there is ruined by monstrous unrealistic code that squeezes out 5% more performance than actually well written code. As a side note, one flaw of TechEmpower benchmarks is that to my knowledge they use the original "wrk" tool, which only supports HTTP 1.0 and is sensitive to "coordinated omission" [0]. This means it ends up being biased in favor of web frameworks that implement specific optimizations or have specific behaviors that aren't actually useful in a production context. [0] https://github.com/giltene/wrk2 https://github.com/giltene/wrk2
- igouy 5y agoPlease explain how we are to practically identify "idiomatic, standard code that a slightly above average developer would plausibly write." Or is it some Goldilocks not-unoptimised not-too-optimised I'll-know-it-when-I-see-it wishful-thinking thing?
- ______-_-______ 5y agoThose benchmarks are pretty heavily gamed. Think about things like hardcoding "Content-Length: 123" instead of computing the length at runtime.
- staticassertion 5y agoThe code used for it looks like someone ran a compiler over it and then dumped the output lol it's... extremely hard to read.
- cfu28 5y agoThe author of just-js did a write up about how he got that performance: https://just.billywhizz.io/blog/on-javascript-performance-01/ https://just.billywhizz.io/blog/on-javascript-performance-01...