[HN Gopher] Announcing Actix Web v4.0
       ___________________________________________________________________
        
       Announcing Actix Web v4.0
        
       Author : robjtede
       Score  : 141 points
       Date   : 2022-02-25 18:59 UTC (4 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | kevincox wrote:
       | I've been using the pre-releases for my web service and it has
       | been rock-solid. I'm happy that it finally has been marked
       | stable. That will definitely help a bit with dll-hell that you
       | often see for unstable releases.
        
       | Dowwie wrote:
       | For those who have been considering Rust for your next web dev
       | project, it is a great time to give it a try. Actix Web is a
       | mature offering with ecosystem, community and learning materials,
       | including a few major book publications in the pipeline.
        
         | JeremyNT wrote:
         | I love working with rust for personal/toy projects, and I've
         | been really itching to find a good use case on the web!
         | 
         | The last I investigated, there were many gaps where one had to
         | "roll their own x" - as compared to something like Rails, which
         | comes with a lot of functionality (and has a huge ecosystem of
         | libraries to support it for stuff that's missing).
         | 
         | If you're familiar with Rails as well... can you speak to what
         | I'll be missing when I work with Actix? Some things I know I
         | take for granted are the ActiveRecord ORM, the session
         | framework, the availability of gems to handle various
         | authentication systems, caching, and a ready "out of the box"
         | browser testing framework.
         | 
         | I know I shouldn't expect anything close to what Rails has to
         | offer, and for hobby projects I don't have an issue with that,
         | but I'm curious about just how far things have come.
        
         | msoad wrote:
         | I always wondered if the safety and correctness that Rust
         | offers is needed in a CRUD application? Do you think it pays
         | off to work in the extremely strict system where you can't just
         | cast to any and move on with your product features?
        
           | Dowwie wrote:
           | Once you acquire the capabilities to do the work efficiently
           | with Rust, it's hard not to use it even for smaller CRUD
           | applications. You'll have a stronger, faster system that uses
           | resources efficiently. It's a good tool for team development
           | efforts, too, as you refactor each other's code and quickly
           | find out what requires fixing (way before releasing to
           | production).
        
           | andrewjf wrote:
           | If you're writing software that will be long-lived with
           | multiple developers, the safety, correctness and strict type
           | system is absolutely necessary for maintainability and
           | refactoring purposes alone. Even for a CRUD app (maybe
           | especially for a CRUD app as you're marshaling objects of
           | different types around, usually), and even when runtime speed
           | is a secondary concern.
        
             | simion314 wrote:
             | But a higher level language with a GC and good types would
             | be more productive , I would suggest to also check the
             | ecosystem not only the language, the access to
             | documentation, and developers (if you need to build a
             | team). From my experience big projects suffer not because
             | of the language but because of bad architecture caused by
             | inexperienced developers.
        
               | andrewjf wrote:
               | I don't disagree with the ecosystem argument, nor the
               | argument that poorly thought out architecture is a big
               | cause, as well. I don't think having a GC de facto makes
               | you more productive and that's worth arguing about
               | itself.
               | 
               | My point was that having the ability to perform "fearless
               | refactoring" to improve architecture and adapt to
               | changing needs of the software needs ruthless type system
               | support to catch the non-obvious areas that you just
               | broke and make sure that API contracts are still correct
               | and to make sure you're not deserializing random stuff
               | into `interface{}` or worse, `Any`, `Value` or `void *`.
        
           | woile wrote:
           | I think there are quite some macros that accelerate a CRUD
           | creation app, for example, take a look at sqlx with ormx:
           | https://github.com/NyxCode/ormx
        
           | stjohnswarts wrote:
           | Any web (or any RPC) facing app that needs high performance
           | and security should consider using Rust frameworks (or go).
           | They are far more efficient than the interpreted languages
           | and 1 server can usually replace several in such cases. It's
           | well worth converting 1 or 2 "small" microservices that
           | require "significant" server side "work" in comparison to
           | interpreted stuff like rails and python.
        
           | tasn wrote:
           | This is something I thought about a lot before switching to
           | Rust at Svix[0]. What I came to realize though, that there
           | are no "casts to any and move on", but rather there are
           | silencing real bugs and praying you won't hit them.
           | 
           | Almost every time I've ever tried to silence the type checker
           | (in any other language) it resulted in a bug.
           | 
           | Does it make you slower? Definitely at times, but it's mostly
           | OK, and the code is pretty damn clean. You can check out our
           | repo to see how it looks[1].
           | 
           | Edit: we don't use Actix, we use Axum, but the same holds for
           | Actix too.
           | 
           | [0] https://www.svix.com
           | 
           | [1] https://github.com/svix/svix-webhooks
        
             | Thaxll wrote:
             | > Almost every time I've ever tried to silence the type
             | checker (in any other language) it resulted in a bug.
             | 
             | What does it even mean? You can't silence a type checker.
        
               | HideousKojima wrote:
               | You can in JS/TS and Python. Technically you could even
               | do it in a language with a fairly strong type system like
               | C# or Java by casting to object or dynamic, though the
               | code using the cast object after that will probably be
               | very unidiomatic.
        
               | Thaxll wrote:
               | Can't you cast to any in Rust as well?
        
               | fzzzy wrote:
               | No. Rust does not have the equivalent of Object or void
               | *.
        
               | sondr3 wrote:
               | To expand on the others, unlike in TS/JS, Python etc you
               | can cast to the `Any`-trait but cannot use it as if it is
               | any value, you need to convert it to the type you want
               | and then handle the errors. A function that accepts
               | `&str` will never accept a `Any` value, unlike in TS
               | where you can override the type checker using `as`. Worth
               | noting that TypeScript's type system is unsound [0] too.
               | 
               | [0]: https://www.typescriptlang.org/docs/handbook/type-
               | compatibil...
        
               | vladvasiliu wrote:
               | There's the Any trait [0]. Not sure if this is exactly
               | like void* in C, but this doesn't look particularly
               | ergonomic to use.
               | 
               | [0] https://doc.rust-lang.org/std/any/index.html
        
               | tasn wrote:
               | Exactly what the sibling comment said, you can do it in
               | many languages. Also, the comment I replied to suggested
               | just that ("cast to any"), which is the context. :)
        
             | shepmaster wrote:
             | +1 for Axum. I recently moved [1] the Rust Playground's
             | backend to Axum and have been very happy with it and the
             | team producing it.
             | 
             | [1]: https://github.com/integer32llc/rust-
             | playground/pull/777
        
           | mamcx wrote:
           | I work on CRUD for life.
           | 
           | Rust is GREAT for that.
           | 
           | Is not the safety (borrow checker) but the combination of:
           | Bare structs, enums, pattern matching and some traits (like
           | Into) that make a breeze modeling business rules.
        
             | pjmlp wrote:
             | Basically any ML derived language, with the added value of
             | automatic memory management.
        
       | Valodim wrote:
       | Anyone got experience using actix web vs rocket? My rough
       | impression is that actix is focused more on performance, rocket
       | on stability and developer ergonomics?
        
         | vladvasiliu wrote:
         | To me, rocket seems much more "batteries included" than actix,
         | which requires you to look around or build your own things if
         | you want to build a bigger app. I'm thinking about
         | authentication, templates, etc.
         | 
         | I'm not really a web dev, though, so I may be wrong, or missing
         | something.
        
           | darkr wrote:
           | Rocket development has stalled for a while now due to the
           | project owner stepping back as he has some real world stuff
           | to deal with.
        
           | Klonoar wrote:
           | My usual reminder that I have a Django-ish template for
           | actix-web that I maintain:
           | https://github.com/secretkeysio/jelly-actix-web-starter
           | 
           | Now that actix-web 4.0 is out I should be able to finally
           | resolve one of the open issues/PRs, which I was waiting on
           | 4.0 for.
        
       | liquid153 wrote:
       | ActiveX
        
       | dang wrote:
       | Related:
       | 
       |  _Actix Web 3.0_ - https://news.ycombinator.com/item?id=24514212
       | - Sept 2020 (108 comments)
       | 
       |  _ExpressJS vs. Actix-Web: performance and running cost
       | comparison_ - https://news.ycombinator.com/item?id=22456796 -
       | March 2020 (53 comments)
       | 
       |  _Actix - Actor Framework for Rust_ -
       | https://news.ycombinator.com/item?id=22316491 - Feb 2020 (126
       | comments)
       | 
       |  _Actix Web - Project Future_ -
       | https://news.ycombinator.com/item?id=22099335 - Jan 2020 (38
       | comments)
       | 
       |  _Rust framework actix and actix-web are dead_ -
       | https://news.ycombinator.com/item?id=22096616 - Jan 2020 (35
       | comments)
       | 
       |  _A Sad Day for Rust_ -
       | https://news.ycombinator.com/item?id=22075076 - Jan 2020 (991
       | comments)
       | 
       |  _Actix project postmortem_ -
       | https://news.ycombinator.com/item?id=22073908 - Jan 2020 (397
       | comments)
       | 
       |  _Actix Web: Optimization Amongst Optimizations_ -
       | https://news.ycombinator.com/item?id=21962195 - Jan 2020 (14
       | comments)
       | 
       |  _Actix-web 1.0 - A small, pragmatic, and fast web framework for
       | Rust_ - https://news.ycombinator.com/item?id=20104619 - June 2019
       | (147 comments)
       | 
       |  _Actix: a small, pragmatic, and fast Rust web framework_ -
       | https://news.ycombinator.com/item?id=17190705 - May 2018 (123
       | comments)
        
       | woile wrote:
       | Thanks a lot for this! actix-web is an amazing framework so far.
       | I've started with the book zero2prod in rust, and using some type
       | driven designed, rust's errors handling, actix-web's extractors
       | and web::data feels like super good ergonomics.
       | 
       | I do feel like the docs could be expanded a bit more, I got stuck
       | when trying to write a middleware for example.
       | 
       | Congrats for the release!
        
       | lambda_dn wrote:
       | With the latest C++ features (lambdas, co routines, smart
       | pointers) it seems Rust is a gratuitous effort to solve a problem
       | that is already solved.
       | 
       | Seriously look at modern C++ it is very easy to develop high
       | performance software in a modern language.
        
         | tele_ski wrote:
         | I've used both very extensively and while I like the direction
         | c++ is headed, I know a lot of people don't, I couldn't
         | disagree with you more. Writing reasonably fast rust that
         | doesn't crash is far easier than writing any kind of c++ that
         | doesn't crash. Copies are a real problem in rust though, they
         | are definitely difficult to avoid without jumping through hoops
         | sometimes but I haven't hit any yet that are a real world show
         | stopper with good upfront design and architecture. C++ just has
         | too much baggage and footguns to make it truly productive on
         | larger teams osit
        
       | lambda_dn wrote:
       | Nearly 100 open issues on Github. It's not something you want to
       | use in production.
        
       | echelon wrote:
       | Actix is amazing!
       | 
       | I'm using actix-web for https://fakeyou.com and their websocket
       | support for upcoming features.
       | 
       | It's incredibly productive and resilient. I've built proxies and
       | other stuff with it too, and it performs swimmingly.
        
         | masterof0 wrote:
         | Do you have in your road map, to add Trump's voice?, I will use
         | your app everyday, lol
        
       | rizzaxc wrote:
       | Is it the time to consider Actix (or any other rust web
       | framework) for production?
       | 
       | I'm planning for a rather ambitious project, but not sure if I
       | should choose rust (the new shiny thing) or stick to good ol Go
       | (while I do have some issues with it)
        
         | dralley wrote:
         | Plenty of companies (including Microsoft IIRC) are using Actix
         | in production. At this point it's not _that_ shiny and new.
         | 
         | Actix is the most mature of the Rust web frameworks. Axum is
         | new but very promising. Rocket is popular but development is
         | stalled at the moment since the main developer has been going
         | through some rough times.
        
           | lambda_dn wrote:
           | Evidence that Microsoft use Actix? Im sure if they did you
           | would have posted a link.
        
             | pjmlp wrote:
             | I remember reading somewhere that the original author was
             | using it for some use cases at Azure, but I doubt it is
             | anything public facing.
        
         | lambda_dn wrote:
         | We looked into Rust at our company (top 100) and it's clear
         | it's not ready for production systems. It just puts developers
         | into a huge tar pit fighting with the compiler for anything
         | more than a simple hello world app. If it actually lived up to
         | it's hype it would have been used to rewrite browsers, servers,
         | OSes etc. But C/C++ are still the kings of system programming.
        
           | ylk wrote:
           | Off the top of my head...
           | 
           | Firecracker, the software AWS Lambda runs on, is written in
           | Rust: https://github.com/firecracker-microvm/firecracker
           | 
           | Mozilla wrote Servo, a browser engine, in Rust. Part of it
           | has been integrated into Firefox a while ago:
           | 
           | > Mozilla incorporated the Servo CSS Style engine in release
           | 57 of its Firefox Quantum browser.
           | 
           | https://research.mozilla.org/servo-engines/
           | 
           | It'll be used in Android:
           | https://security.googleblog.com/2021/04/rust-in-android-
           | plat...
           | 
           | It'll probably find it's way into the Linux kernel:
           | https://news.ycombinator.com/item?id=29485465
        
             | lambda_dn wrote:
             | The whole reason for Rust's existence was for Servo so
             | using it as an example of its use is disingenuous at best.
             | 
             | Ok one bit of AWS runs on Rust.
             | 
             | C/C++ runs 99% of the the worlds software including
             | OS's/browsers/GUI's/Compilers/Virtual
             | machines/Games/Aircraft/Spacecraft etc etc etc.
             | 
             | "It'll be" same was said of Java
        
               | RussianCow wrote:
               | > The whole reason for Rust's existence was for Servo so
               | using it as an example of its use is disingenuous at
               | best.
               | 
               | Mozilla wanted to push the boundaries of what's possible
               | with a browser rendering engine and they felt like they
               | couldn't do it safely with the existing languages, so
               | they created their own. Doesn't that, alone, speak
               | volumes for how useful Rust is?
               | 
               | > C/C++ runs 99% of the the worlds software including
               | OS's/browsers/GUI's/Compilers/Virtual
               | machines/Games/Aircraft/Spacecraft etc etc etc.
               | 
               | Now you're being disingenuous. Rust is still so young
               | compared to those languages! Not to mention that the
               | industries best served by Rust move glacially slowly
               | compared to, say, the web. I bet we'll see significantly
               | more adoption of Rust in 10-15 years.
        
               | ylk wrote:
               | It is and will continued to be used in areas where
               | security is important.
               | 
               | This is from November 2020, I'd expect them to use it
               | even more by now:
               | 
               | > But we also use Rust to deliver services such as Amazon
               | Simple Storage Service (Amazon S3), Amazon Elastic
               | Compute Cloud (Amazon EC2), Amazon CloudFront, Amazon
               | Route 53, and more. Recently we launched Bottlerocket, a
               | Linux-based container operating system written in Rust.
               | Our Amazon EC2 team uses Rust as the language of choice
               | for new AWS Nitro System components, including sensitive
               | applications such as Nitro Enclaves.
               | 
               | https://aws.amazon.com/blogs/opensource/why-aws-loves-
               | rust-a...
        
             | pjmlp wrote:
             | While Rust is being used on the system level for Android,
             | there are no plans for the time being, to ever support it
             | for app development on the Android NDK or AGK.
        
         | nicoburns wrote:
         | Rust is plenty ready for production. Choosing between Go and
         | Rust for web backends is really choosing between a more complex
         | language that allows you to have powerful abstractions and has
         | a focus on correctness vs. A simpler language that is looser
         | and prefers "verbose but simple" code.
        
           | lambda_dn wrote:
           | Google and most other software kings chooses C++ for backend.
           | If you think you know better than them feel free to use the
           | hype lang of the day. Rust will be gone in a few years.
        
         | tele_ski wrote:
         | Anecdotal but my company is using it for a new project and we
         | just hit production about a month ago. So far it's been great
         | with 10+ million requests handled per day. Looking forward to
         | upgrading to 4.0
        
         | JSGdev wrote:
         | My company currently runs Actix-web in production and is happy.
         | Good tooling, fast, low resource costs, well-supported.
        
           | lambda_dn wrote:
        
       | capableweb wrote:
       | That's great to finally hear!
       | 
       | I started learning Rust recently and usually start learning new
       | languages by building different kinds of Hacker News clients with
       | the language. This time I focused on a offline-first desktop HN
       | client, that fetches items periodically and allows the user to
       | browse it in a desktop app built with Tauri.
       | 
       | While developing this, I started writing a API with Actix Web at
       | the same time, so the same service could be used directly in the
       | browser, not just with the desktop app. So I found Actix Web to
       | be the most supported.
       | 
       | However, I jumped into the RC versions (in order to use tokio >v1
       | which I was already using for other things, and you can't mix
       | versions), while most human-written documentation (website, Stack
       | Overflow, forums and such) were written for the pre-4 version. So
       | I'm glad to see it finally released, and can't wait for all the
       | documentation to/web resources to be properly updated as well so
       | I can learn more about Actix Web.
       | 
       | Great work on creating a nice library folks! :)
        
         | lambda_dn wrote:
         | "Actix was found by third parties abusing unsafe and when they
         | were auditing most libraries found for Rust on the internet.
         | When the unsafe code was audited it was found that on misuse,
         | it can lead to serious vulnerabilities. So they opened a bunch
         | of issues and added a lot of patches and PR's in GitHub."
         | 
         | Good luck though
        
           | gilrain wrote:
           | Hey bud, you are being really aggressive and disagreeable in
           | here. At this point, I think everyone is aware that you,
           | personally, would not recommend Rust or Actix. Loud and clear
           | my dude.
        
             | lambda_dn wrote:
        
           | nextaccountic wrote:
           | They have since fixed those issues in actix 3.0
        
             | lambda_dn wrote:
             | Evidence of that? Or is the whole software world to believe
             | the words of nextaccountic?
        
               | rackjack wrote:
               | Why don't you provide evidence of extant misused `unsafe`
               | first? Or is the whole software world to believe the
               | words of lambda_dn?
        
           | kibwen wrote:
           | This is an easy mistake to make, but actix-web isn't actix,
           | it's a web framework that uses actix. And while actix once
           | had a controversial reputation regarding unsafety, the
           | project has reversed its stance in the years since that quote
           | was relevant and now appears to treat soundness violations
           | with seriousness.
        
       | deutschewelle wrote:
       | Can we get some benchmarks to get a rough ball park estimate of
       | performance/$ ?
       | 
       | Is it say possible to run a production quality server that can
       | handle hundreds of thousands of concurrent users on digital ocean
       | lets say?
       | 
       | It's not clear to me as a "buyer" what its selling points are and
       | what makes it uniquely different from other Rust frameworks
        
         | Xevi wrote:
         | There are lots of benchmarks of Actix if you search for it.
         | It's also one of the top frameworks in the TechEmpower
         | benchmarks.
        
         | nicoburns wrote:
         | The truth is there isn't an awful lot of difference between the
         | artist frameworks. Actix-web was one of the first though, so
         | the reason to choose it over others would be that it's a bit
         | more built out feature wise.
        
           | ibraheemdev wrote:
           | Actix-Web actually differentiates itself from most other Rust
           | servers in that it runs multiple per-thread runtimes as
           | opposed to a single work-stealing runtime. This probably
           | doesn't matter to most, but if you really care about latency,
           | it might be a factor to consider.
        
         | sciurus wrote:
         | > Is it say possible to run a production quality server that
         | can handle hundreds of thousands of concurrent users on digital
         | ocean lets say?
         | 
         | Absolutely. I used to work as an SRE on Mozilla's WebPush
         | infrastructure. Every running Firefox in the world establishes
         | a connection to it; that means it peaks at tens of millions of
         | concurrent connections every day. We could easily handle
         | hundreds of thousands of connections on a couple CPU cores and
         | gigs of RAM.
         | 
         | Although most connections were usually idle, we also regularly
         | pushed messages to every connected client (e.g. when a
         | collection in our remote settings service was updated).
         | 
         | It's written in Rust using Actix.
         | 
         | https://github.com/mozilla-services/autopush-rs
        
         | capableweb wrote:
         | What libraries like this could you really extract
         | "performance/$" from? Sounds like a mostly financial metric.
         | 
         | It's so situational that you cannot say outright exactly how
         | much something cost in different scenarios. Doing so requires
         | strict metrics about other things at the same time, and could
         | only be done as an analysis of what happened, not what will
         | happen in the future. Subtle bugs and things like just using a
         | different data structure would impact the performance, down to
         | the tiniest detail.
         | 
         | If you're so adamant to see metrics, you could use
         | TechEmpower's framework tests, latest one placing 5th Actix in
         | the "Composite score" (https://www.techempower.com/benchmarks/#
         | section=data-r20&hw=...), as a result of being pretty high up
         | in the specific benchmarks. But even with that information, it
         | doesn't mean it'll be the 5th fastest framework when you use
         | it.
         | 
         | I guess the point is: do you own benchmarks for the specific
         | areas where you need it to be fast, calculate what _your_ costs
         | would be for hosting it, and you 'll have your "performance/$".
        
         | lambda_dn wrote:
        
       ___________________________________________________________________
       (page generated 2022-02-25 23:00 UTC)