So glad to see 0.5 out of release candidacy! I really appreciated how async functions and event streams were handled in 0.5, and just seeing this version land will make it so much easier to justify using Rocket in production.
I still think Rocket is the most concise web framework for Rust after 5 years now of using it in projects and even newer frameworks, and also is one of the best examples of how ergonomic you can make frameworks and DSLs in-general using Rust's type system.
For those wondering what makes it so different, the "batteries included" approach really differentiates it from other web frameworks in Rust, and it reduces the total amount of boilerplate you need to setup for simple middleware, streams, and security just about everything you need to do for simple web services.
I was developing a fairly large web app with Rocket 0.4 (released 2018!) and it started as a good experience, but then I was burned by the lack of support for multipart forms (i.e. file uploads), poor async, no option to listen on unix socket (required by my hosting provider's proxy) and long compilation times (not fully fault of Rocket, Rust compiler team has done a lot to speed up compilation since then). In the end, I found hacky solutions for all these issues, but I learned that perhaps Rust is not the right choice to make full-stack web apps and rewrote everything to Laravel (PHP) and Vue (JS).
Past me would have loved this update. Thank you in his name!
I tried rocket back then and reached similar conclusions - then I just picked the most popular choice (actix at the time). Actix had its highs and lows but always delivered.
Nowadays I'm on axum (mainly because the API is nice and because it feels like the community is moving in that direction) and the experience is great.
I'm working to rewrite my node.js and python service to Rust to simplify my stack and take care of unreliability and hard to debug occasional bugs.
And I'm also adopting leptos to do frontend development (moving from solid.js - which is already pretty nice)
> I learned that perhaps Rust is not the right choice to make full-stack web apps and rewrote everything to Laravel (PHP) and Vue (JS).
I fully agree with you on this one and people have been saying this for a long time now, Rust and its kind has its place. Full stack web framework is not one of them.
> perhaps Rust is not the right choice to make full-stack web apps
This is a good step, but I still wonder if this is the case. I do like some aspects of writing webapps in Rust, but the ecosystem for serious web apps is still woefully immature. There just aren't battle-tested and well-supported solutions for many critical things, including tracing, monitoring, security, etc.
Hate to say that but I’d be happier if this never happened.
I think many newcomers think that Rocket is “the web framework” in Rust. And if author goes silent again they will be let down. It casts kinda bad shadow on Rust community but we have better alternatives.
I'm not sure I understand this - I think having different options for web frameworks is great for Rust! Actually, it's probably more useful for Rust than other languages because Rust ends up being used by such a different range of developers and applications, and each framework ends up having such different opinions and providing different levels of abstractions.
This is the kind of problem that can solve itself, if enough people adopt a project and depend on it, its maintenance can be organized. It helps if the original author is willing to help with the transition to a community-maintained project, which seems to be the case with Rocket.
I like the idea of Rust, its technical merits etc, but good lord this language has some crazy weird and intimidating syntax. I read the code snippets and am just confused as heck.
Once you get over the initial hurdle, the syntax is extremely consistent and "guessable." By which I mean, once you know the basics you can guess how to do things that you have never done before - and if it doesn't work there's probably a pending RFC that matches your expectations.
For example, you might learn that you can do `if let Some(foo) = option` to check if some option is Some, but to also extract the value from it. Now you might guess that the let conditionals might work elsewhere, and you'd be right! `while let Some(line) = reader.read()` totally works.
Now compare this to the likes of C, where for example `break` appears in a `switch` for some bizarre reason (yes, I know the actual reason) and `case`s don't have braces.
This is definitely not helped by Rocket. Even I, knowing Rust well, don't enjoy the way Rocket puts so much logic into attribute macros and function signatures.
It really depends on where you're coming from and if you understand the problems Rust is trying to solve. Rust is a strongly typed language that promotes explicitness over ambiguity, making actual application code look quite different from JS or Python which provide a lot of shortcuts but also have plenty of hidden trapdoors.
Some say that Rust naming conventions actually uses snake_case in variables because each underscore is a little trapdoor that's made apparent so you don't fall in it!
Being mainly imperative with some functional and OO niceties, it's also much less weird than many other languages. Try reading some Haskell or Erlang before judging how weird a language looks...
I'd be curious how you rewrite the syntax to have the same features but less syntax choices. Especially if it was made in the same way, organic evolution over the years.
I suspect it might look different. Not better or worse, just.. different. Same core complaints.
Now what if it was written from scratch today? That would prob miss a lot of the warts you don't like. But it still represents a lot of complexity in all the features the language presents, so it wouldn't be Python - for sure.
Very cool to see this finally go out, and especially the new Foundation. I have to wonder though if it's too late though. I gave up waiting for a new Rocket release years ago and have been doing what Rust web work I've been doing on Axum instead - the integration with Tower is very nice.
Agreed. When I first considered porting small APIs over to Rust, Rocket appeared to be the most popular besides Actix. Axum hadn't even came out (it came out a month later and we ended up using it even though it was in its infancy). It's pretty unfortunate because Rocket could be amazing but the lack of updates killed it. See you guys in 5 years when v0.6 comes out.
Maybe one day I'll use Rust for backend dev. Everyone wants something different, but I'll use Django, and deal with Python's messiness until we get a Rust framework that has a high-level ORM, built in auth, admin, etc. And would prefer no Async.
Coming from normal dev work myself, I’m drawn to dotnet nowadays. If you ever make the chance, it’s real easy to get started and do what Python does in aspnet, scripting, whatever.
Looking forward to this hopefully final big upgrade on my 20k LOC web service[1]. The upgrade from 0.4 to the first rc of 0.5 was a slog, but I've already upgraded to 0.5-rc.4 so this should hopefully be comparatively painless.
It's sad that it took to long to reach this state, a few years in beta and now it's out, if it didn't were for this it would been my framework of choice for web development in rust, it is very nice and all, but the support and lack of ways for the community to contribute killed the project for me.
Now that Actix and Axum are there, I would not go back to Rocket. But still kudos to the maintainers and the new direction of the project being now in process to be owned by a non-profit. I'd hope that the community is still interested in it and grow, we need more options in the space and Rocket being different that the others is also a good thing.
I'd say it's more of an opinionated approach to a web framework, which reduces boilerplate on a lot of simpler applications. In order to facilitate this, it ends up creating more of a Domain Specific Language (DSL) using macros and types for Rocket, which can be harder to manipulate in ways you might expect as a Rust developer.
Axum on the other hand tends to avoid macros and uses the type system in "more composable" way with other Rust crates, and while still providing a concise way to create web apps, has resulted in more boilerplate to hit the ground running in my experience.
*axum
I migrated a rocket project to axum 1~2 years ago, due to rocket being dead at the time.
Both frameworks contain all you need to build an API really.
But personally I found that:
Rocket is easier for beginners, and once you know what you're doing, Axum is cleaner and better integrated in the ecosystem.
It probably feels more familiar if you are coming from the world of Python’s Django or Flask. Other than that Axum is very likely a better choice for all use cases.
Wow, I'd honestly assumed Rocket was dead. Glad to see it continue! It takes a pretty different approach from the other Rust web frameworks (much more opinionated and all-inclusive), so it's great to have more diversity in the space
Qwuke|2 years ago
I still think Rocket is the most concise web framework for Rust after 5 years now of using it in projects and even newer frameworks, and also is one of the best examples of how ergonomic you can make frameworks and DSLs in-general using Rust's type system.
For those wondering what makes it so different, the "batteries included" approach really differentiates it from other web frameworks in Rust, and it reduces the total amount of boilerplate you need to setup for simple middleware, streams, and security just about everything you need to do for simple web services.
alberth|2 years ago
Rocket seems like a lot of visual noise vs. Laravel/Rails/Django.
pzmarzly|2 years ago
Past me would have loved this update. Thank you in his name!
jokethrowaway|2 years ago
Nowadays I'm on axum (mainly because the API is nice and because it feels like the community is moving in that direction) and the experience is great.
I'm working to rewrite my node.js and python service to Rust to simplify my stack and take care of unreliability and hard to debug occasional bugs.
And I'm also adopting leptos to do frontend development (moving from solid.js - which is already pretty nice)
Alifatisk|2 years ago
I fully agree with you on this one and people have been saying this for a long time now, Rust and its kind has its place. Full stack web framework is not one of them.
ufmace|2 years ago
This is a good step, but I still wonder if this is the case. I do like some aspects of writing webapps in Rust, but the ecosystem for serious web apps is still woefully immature. There just aren't battle-tested and well-supported solutions for many critical things, including tracing, monitoring, security, etc.
Hamuko|2 years ago
I also need to hack around a bit to ship templates, since I want to distribute my app (with a Rocket server in it) as a single executable.
tomas789|2 years ago
I think many newcomers think that Rocket is “the web framework” in Rust. And if author goes silent again they will be let down. It casts kinda bad shadow on Rust community but we have better alternatives.
Qwuke|2 years ago
__s|2 years ago
They address your concern, a foundation is being created
speed_spread|2 years ago
felipellrocha|2 years ago
Dig1t|2 years ago
Did it really have to look like this?
duped|2 years ago
For example this:
Is not valid Rust code. The `for await message in ws` is particularly egregious.zamalek|2 years ago
For example, you might learn that you can do `if let Some(foo) = option` to check if some option is Some, but to also extract the value from it. Now you might guess that the let conditionals might work elsewhere, and you'd be right! `while let Some(line) = reader.read()` totally works.
Now compare this to the likes of C, where for example `break` appears in a `switch` for some bizarre reason (yes, I know the actual reason) and `case`s don't have braces.
drewtato|2 years ago
speed_spread|2 years ago
Some say that Rust naming conventions actually uses snake_case in variables because each underscore is a little trapdoor that's made apparent so you don't fall in it!
Being mainly imperative with some functional and OO niceties, it's also much less weird than many other languages. Try reading some Haskell or Erlang before judging how weird a language looks...
unshavedyak|2 years ago
I suspect it might look different. Not better or worse, just.. different. Same core complaints.
Now what if it was written from scratch today? That would prob miss a lot of the warts you don't like. But it still represents a lot of complexity in all the features the language presents, so it wouldn't be Python - for sure.
Personally i love the syntax, but /shrug
ufmace|2 years ago
dkryptr|2 years ago
the__alchemist|2 years ago
belmont_sup|2 years ago
bsnnkv|2 years ago
[1]: https://notado.app
norman784|2 years ago
Now that Actix and Axum are there, I would not go back to Rocket. But still kudos to the maintainers and the new direction of the project being now in process to be owned by a non-profit. I'd hope that the community is still interested in it and grow, we need more options in the space and Rocket being different that the others is also a good thing.
lrx|2 years ago
imachine1980_|2 years ago
Qwuke|2 years ago
Axum on the other hand tends to avoid macros and uses the type system in "more composable" way with other Rust crates, and while still providing a concise way to create web apps, has resulted in more boilerplate to hit the ground running in my experience.
awoimbee|2 years ago
tomas789|2 years ago
jaafwasd|2 years ago
brundolf|2 years ago
dkryptr|2 years ago
Dowwie|2 years ago
pjmlp|2 years ago
A major pain in Rust ecosystem, where few libraries feel like actually having a 1.0.