Choosing a Rust Web Framework
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...
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.
yeah i was like "isn't just dependency injection?"
I was looking for a nestJS-like framework in rust, thanks for the context
@@josearmas1511 have you find similar to nestjs in rust ?
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.
thank you for your effort. love watching your vids and glad they will be recorded online for years to come
Axum is hands down the best web framework for rust. Its also fast to compile and iterate
Absolutely and David (developer) is a great guy
why I should use Axum instead Actix-Web?
@@LolLol-ig5tb Compiles faster. No macro magic, just approachable (and clever) Rust code. Tokio ecosystem. 100% safe Rust. Great docs. Nice maintainers
Is it actor based like Actix?
What are the advantages over Rocket?
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 ;)
it *is* nice that poem also chose to support Tower's Service trait
Chris, ngl, if you had a thick golden Cuban on you, the thumbnail would have you looking like a real G haha
Railway is my fav host, super simple to setup.
id love a video on tower!
There's always Rust on Nails, if you want rails-like
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.
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. 🤣
Imho axum is the best. Fast compile times, plain simple architecture and tokio integration (tracing, bytes, metalio, tower, hyper,…)
@@altairbueno5637 I've just started from scratch using Axum. I hope their documentation is good.😄
@@morgomi top tier docs.rs. Also, lots of examples. Error handling examples were co-authored by me, so check them out!
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.
Sorryz but, Poem > Tide > all
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.
Dependency Injection in Rust would be a dream. Imagine a project like Symfony, but completely in Rust :^)
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.
Love the videos and the channel chris! Are you planning to create a discord server in the near future?
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.
Discord server invite link is in the description for tomorrow's video
Good video. I prefer Axum as well (compared to Rocket and Actix). It just makes more sense to me.
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. 🤔
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
nightowl.. nice. best theme
I enjoy warp for apis
How about Actix Web?
its fine if it fits your wants/needs. I generally prefer and see more companies choosing Axum at the moment.
4:56 @chris Biscardi what is the CLI tool you’re using here?
It's nushell! www.nushell.sh/
@@chrisbiscardi thanks 🙏
Have you considered warp ? Instead of evaluating extractors at runtime it es evaluated at compile time.
Hey Chris! What were you using to generated unique ids? Doesn't look like uuid.
In this project it was ksuid, so I continued using that. ulid would be another similar choice.
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.
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.
@@johnw.8782 im pretty sure he meant in the context of a web framework, valid question
@@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.
@@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.
@@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?
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?
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).
@@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.
@@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
@@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!
I generally enjoy your videos, but the single word on screen captions were very distracting.
How do you get that "from json | get data" in the cli?
I use nushell: www.nushell.sh/
@@chrisbiscardi That was fast (I was still reading the comments), thanks bro!
@@0xccd haha I just happened to be looking at the dashboard when you commented. It was like "37 seconds ago..."
What about Dioxus?
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
Actix will ever be in my mind as unstable repo :(
Rocket is deprecated
It's definitely not.
It is not. The project moves slow, but steady. Compile time is too slow for my taste tho
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.