Choosing a Rust Web Framework

Sdílet
Vložit
  • čas přidán 23. 08. 2024
  • The Rust web ecosystem has a lot to offer, but a lot of it is in crates you'll have to discover and choose to use. In this video we cover the choice I made to build the new Rust Adventure API in: Axum.
    arewewebyet: www.arewewebye...

Komentáře • 71

  • @jaysistar2711
    @jaysistar2711 Před rokem +39

    If you go to other languages and frameworks, the Bevy ECS-like query that you're talking about is called "dependency injection" in this context. I like it as well.

    • @ValAllenSamonte
      @ValAllenSamonte Před rokem +4

      yeah i was like "isn't just dependency injection?"

    • @josearmas1511
      @josearmas1511 Před rokem +2

      I was looking for a nestJS-like framework in rust, thanks for the context

    • @usmanjamil3934
      @usmanjamil3934 Před rokem +1

      @@josearmas1511 have you find similar to nestjs in rust ?

  • @everestshadow
    @everestshadow Před rokem +33

    Most of the rust web frameworks are similar. They only have tiny difference on surface level api and under the hood they are mostly hyper/tokio.

  • @michaeljamescollins6800
    @michaeljamescollins6800 Před rokem +2

    thank you for your effort. love watching your vids and glad they will be recorded online for years to come

  • @altairbueno5637
    @altairbueno5637 Před rokem +13

    Axum is hands down the best web framework for rust. Its also fast to compile and iterate

    • @romanstingler435
      @romanstingler435 Před rokem +5

      Absolutely and David (developer) is a great guy

    • @LolLol-ig5tb
      @LolLol-ig5tb Před rokem

      why I should use Axum instead Actix-Web?

    • @altairbueno5637
      @altairbueno5637 Před rokem

      @@LolLol-ig5tb Compiles faster. No macro magic, just approachable (and clever) Rust code. Tokio ecosystem. 100% safe Rust. Great docs. Nice maintainers

    • @David-iq1kd
      @David-iq1kd Před rokem

      Is it actor based like Actix?

    • @CalifornianViking
      @CalifornianViking Před rokem +1

      What are the advantages over Rocket?

  • @AreQ212
    @AreQ212 Před rokem +4

    I've had opportunity to work with axum as well as with poem, and from those two, I prefer second option. Axum forced me to use trait objects, which is not ideal, as not every struct can be used in that way. Also poem supports open api, so creating documentation is as easy as rust docs ;)

    • @chrisbiscardi
      @chrisbiscardi  Před rokem

      it *is* nice that poem also chose to support Tower's Service trait

  • @SkegAudio
    @SkegAudio Před rokem +1

    Chris, ngl, if you had a thick golden Cuban on you, the thumbnail would have you looking like a real G haha

  • @Kragal0n
    @Kragal0n Před rokem +1

    Railway is my fav host, super simple to setup.

  • @irlshrek
    @irlshrek Před rokem +2

    id love a video on tower!

  • @akillersquirrel5880
    @akillersquirrel5880 Před rokem +1

    There's always Rust on Nails, if you want rails-like

  • @adamglass2599
    @adamglass2599 Před rokem +1

    i think i preferred the previous style of presentation. These last two seem to be in a hurry to get to the conclusion with lots of fast edits at the start. re: title. Is this about choosing a rust web framework or your choice of web framework for this project? More the latter.

  • @morgomi
    @morgomi Před rokem +3

    what a coincidence. Yesterday, I was going to start a project with my friend, and we were looking for a framework. We discussed a lot about Rocket, Actix, Gotham now we're going to discuss Axum then. 🤣

    • @altairbueno5637
      @altairbueno5637 Před rokem +2

      Imho axum is the best. Fast compile times, plain simple architecture and tokio integration (tracing, bytes, metalio, tower, hyper,…)

    • @morgomi
      @morgomi Před rokem +1

      ​@@altairbueno5637 I've just started from scratch using Axum. I hope their documentation is good.😄

    • @altairbueno5637
      @altairbueno5637 Před rokem +1

      @@morgomi top tier docs.rs. Also, lots of examples. Error handling examples were co-authored by me, so check them out!

    • @dealloc
      @dealloc Před rokem

      We went with warp (before Axum was born) and have been happy with it. However, what I like about axum is that it has much simpler types to work with. Both are very composable, unlike a lot of frameworks using proc macros.

    • @clivalycardoso8606
      @clivalycardoso8606 Před 7 měsíci

      Sorryz but, Poem > Tide > all

  • @darknetworld
    @darknetworld Před rokem +1

    Really I was looking using bevy and web interface. One reason is wanted to try it out as well remind of me of the old game using like ragnarok online and unreal tournament from rpg invasion mod game. It was fun days.

  • @NetherFX
    @NetherFX Před rokem +10

    Dependency Injection in Rust would be a dream. Imagine a project like Symfony, but completely in Rust :^)

    • @RogerValor
      @RogerValor Před rokem +3

      Dependency Injection is already possible in rust, as it is a general programming design pattern, just use e.g. boxed dyn trait as a passable argument in a constructor. I think what all you mean here is some sort of automatic dependency injection management.

  • @shitcoinsrus
    @shitcoinsrus Před rokem +1

    Love the videos and the channel chris! Are you planning to create a discord server in the near future?

    • @chrisbiscardi
      @chrisbiscardi  Před rokem

      yup! I have a discord server for Rust Adventure that I'm currently reworking for this purpose. I'll post about it when its open to the public.

    • @chrisbiscardi
      @chrisbiscardi  Před rokem

      Discord server invite link is in the description for tomorrow's video

  • @johnw.8782
    @johnw.8782 Před rokem

    Good video. I prefer Axum as well (compared to Rocket and Actix). It just makes more sense to me.

  • @chris.dillon
    @chris.dillon Před rokem +2

    I disagree with the YES on arewewebyet for the reason you stated in your opening. It doesn't have to be Rails but I think it essentially has to be Rails-like, which probably takes 10 years. If they ever crack this nut, this would be the first time in history a language would "work" from kernel to high-level domain. This would be exciting but I also wonder if it's possible. Go Buffalo is a good example. I like the creator, I appreciate the work but something just didn't pan out for me. I also have a similar take about microframeworks. But specifically about the language either technically enabling productivity or some kind of culture/sapir-whorf thing in the language community ... I'd really, really like to be eventually wrong on my take here like aged milk in the future. Low level language scaling where the machine is happy to high level complex projects where the human is happy. Two optimizations at once, pretty tough. 🤔

    • @chrisbiscardi
      @chrisbiscardi  Před rokem +1

      I think overall the Yes on arewewebyet is that there are multiple frameworks that exist and work for production use cases, not that Rust "has a Rails". That said, it *is* only a matter of someone building it I think. I tend to prefer a more piecemeal approach, so looking at the features Buffalo touts I think the only one I don't have a Rust answer for off the top of my head is background jobs.
      I definitely agree that seeing a Rails-level framework for a language used in developing the Kernel would be a huge accomplishment... and a lot of work

  • @jzmmm
    @jzmmm Před 10 měsíci

    nightowl.. nice. best theme

  • @johnwilliams7999
    @johnwilliams7999 Před rokem +1

    I enjoy warp for apis

  • @TwKgg
    @TwKgg Před měsícem +1

    How about Actix Web?

    • @chrisbiscardi
      @chrisbiscardi  Před měsícem

      its fine if it fits your wants/needs. I generally prefer and see more companies choosing Axum at the moment.

  • @jeanchindeko5477
    @jeanchindeko5477 Před rokem +2

    4:56 @chris Biscardi what is the CLI tool you’re using here?

  • @andres-hurtado-lopez
    @andres-hurtado-lopez Před rokem

    Have you considered warp ? Instead of evaluating extractors at runtime it es evaluated at compile time.

  • @artemivasyuk1699
    @artemivasyuk1699 Před rokem +1

    Hey Chris! What were you using to generated unique ids? Doesn't look like uuid.

    • @chrisbiscardi
      @chrisbiscardi  Před rokem

      In this project it was ksuid, so I continued using that. ulid would be another similar choice.

  • @verified_tinker1818
    @verified_tinker1818 Před rokem +1

    What's the sense in using Tower's load-balancing, rate-limiting, etc. when it's included in reverse proxies and load balancers? Does it reduce complexity? Genuine question.

    • @johnw.8782
      @johnw.8782 Před rokem

      Tower allows you to build networks applications. What so you think Reverse proxies and Load Balancers are? They're network applications. So you could use a framework like Tower to build those types of applications.

    • @khuiification
      @khuiification Před rokem +1

      @@johnw.8782 im pretty sure he meant in the context of a web framework, valid question

    • @johnw.8782
      @johnw.8782 Před rokem

      @@khuiification I didn't say it wasn't a valid question? I gave the usage of Tower.
      In the context of a web framework, the answer is still the same. Not all services sit behind http load balancers or proxies. Not all services are infinitely scalable in the cloud. Some are snowflakes. Those services can still fail. So you would want to be able to write backoff and load balancing functionality using Tower.
      Proxies and Load Balancers are no different than any other service that can be written with a web framework. they just handle traffic in specific ways.

    • @khuiification
      @khuiification Před rokem +1

      @@johnw.8782 well, your answer isnt relevant to the context. Also, maybe its just me but asking ”what do you think xxx and yyy are?”, insinuating that OP is in some way in the wrong for asking, is a bad way to put.
      It is also not the same at all in the context of axum. Existing libraries, middleware etc. is a major part of why this is bonus and why i believe it is mentioned. Really nothing in particular to do with load balancers and proxies.

    • @johnw.8782
      @johnw.8782 Před rokem

      @@khuiification Well then I'm sorry that your feelings were hurt when I was answering someone else's question, but it seems you have a very narrow understanding of web programming.
      If a service receives an http request and has either 1) and internal error or 2) a downstream error, the service can either decide to continue to serve requests or not. That is what rate limiting is. That is application that be built with axum using tower middleware.
      If a service receives an http request and has to rout that request amongst a defined set of downstreams, the service can decide which downstream to route to. That is load balancing. That is application that be built with axum using tower middleware.
      Both of these can be done in a reverse proxy fashion.
      I'm not sure why you don't think that this matters in the context when the OP asked what is the use of Tower's middlewares in comparison to external load balancers and proxies?

  • @charlesbcraig
    @charlesbcraig Před rokem +1

    I’d be curious to know about rust hosting options.
    Also, do you still put nginx in front of it and pass the request on to rust like you do with PHP?

    • @chrisbiscardi
      @chrisbiscardi  Před rokem +2

      I typically don't use something like nginx because I tend to prefer either serverless deployments or the newer generation of heroku-style container-based platforms (fly, render, etc).

    • @charlesbcraig
      @charlesbcraig Před rokem +2

      @@chrisbiscardi maybe this is in the works already since this video series is about web apps, but a video from basic web app with db to deployment would be cool.

    • @chrisbiscardi
      @chrisbiscardi  Před rokem +1

      @@charlesbcraig totally. When you say "basic web app" what kind of features does that have? The architecture for this series is roughly: one API + one UI server (axum/planetscale + axum/leptos), although we haven't made it to the UI yet

    • @charlesbcraig
      @charlesbcraig Před rokem +1

      @@chrisbiscardi oh I’m thinking something simple (maybe fancier than a todo list, but nothing wrong with them either) so your architecture for the series sounds perfect!

  • @Codeaholic1
    @Codeaholic1 Před rokem +2

    I generally enjoy your videos, but the single word on screen captions were very distracting.

  • @0xccd
    @0xccd Před rokem

    How do you get that "from json | get data" in the cli?

    • @chrisbiscardi
      @chrisbiscardi  Před rokem +2

      I use nushell: www.nushell.sh/

    • @0xccd
      @0xccd Před rokem

      @@chrisbiscardi That was fast (I was still reading the comments), thanks bro!

    • @chrisbiscardi
      @chrisbiscardi  Před rokem +2

      @@0xccd haha I just happened to be looking at the dashboard when you commented. It was like "37 seconds ago..."

  • @Kragal0n
    @Kragal0n Před rokem

    What about Dioxus?

    • @chrisbiscardi
      @chrisbiscardi  Před rokem

      Dioxus is a GUI layer so wouldn't work for the intended purpose here (which is a JSON API). A dioxus app could consume this API though

  • @daniel13021
    @daniel13021 Před rokem

    Actix will ever be in my mind as unstable repo :(

  • @gofudgeyourselves9024
    @gofudgeyourselves9024 Před rokem +1

    Rocket is deprecated

    • @johnw.8782
      @johnw.8782 Před rokem +1

      It's definitely not.

    • @altairbueno5637
      @altairbueno5637 Před rokem

      It is not. The project moves slow, but steady. Compile time is too slow for my taste tho

    • @everestshadow
      @everestshadow Před rokem +3

      You are right and wrong at the same time. It's not deprecated but at the same time the maintainer show zero interest in sharing the maintenance privilege with it's community. Don't get me wrong he has every right to do so but you should seriously consider avoid using a framework for any serious/long term project when it has a bus factor of 1.