Hi everyone,<p>I've been "funemployed" for a few months and with all that free time and idle hands I wrote a full web framework (think Rails, not Flask) for Rust.<p>It's boring old MVC, has its own ORM, templates, background jobs, auth, websockets, migrations and more. If you're keen but don't feel like rewriting your app in a different language, Rwf has a WSGI server to run Django (or Flask) inside Rust [1], letting you migrate to Rust at your own pace without disrupting your website.<p>I think Rust makes a great prototyping and deploy straight to production language. Now it has yet another framework for y'all to play with.<p>Cheers!<p>[1] <a href="https://levkk.github.io/rwf/migrating-from-python/" rel="nofollow">https://levkk.github.io/rwf/migrating-from-python/</a>
Nice, congratulations. It must feel so surreal launching this!<p>One of my biggest learnings from doing a bunch of web MVC through Rails over the years is that the framework should heavily discourage business logic in the model layer.<p>Some suggestions:<p>- Don't allow "callbacks" (what AR calls them) ie hooks like afterCreate in the data model. I know you don't have these yet in your ORM, but in case those are on the roadmap, my opinion is that they should not be.<p>- That only really works though if you not strongly encourage a service aka business logic layer. Most of my Rails app tend to have all of these as command aka service objects using a gem (library/package) like Interactor.*<p>* It's my view that MVC (and therefore Rails otb) is not ideal by itself to write a production-ready app, because of the missing service layer.<p>Also, curious why existing ORMs or query builders from the community weren't leveraged?<p>Disclaimer: I haven't written a line of Rust yet (more curious as the days go by). I'm more curious than ever now, thanks to you!
I would kinda expect REST framework to be able to generate Swagger (aka OpenAPI) definitions out of the box. That's one of the killer features of FastAPI in my opinion.<p>Also, I don't really understand what is the reason for creating your own ORM instead of integrating with, let's say diesel.rs [0] and what is the reason for inventing your own template language instead of just picking one of the most popular existing template engines [1].<p>Other than that this project looks really interesting and I will definitely keep an eye on it.<p>[0] <a href="https://diesel.rs/" rel="nofollow">https://diesel.rs/</a><p>[1] <a href="https://crates.io/categories/template-engine" rel="nofollow">https://crates.io/categories/template-engine</a>
As SRE, I got interested in <a href="https://levkk.github.io/rwf/migrating-from-python/" rel="nofollow">https://levkk.github.io/rwf/migrating-from-python/</a>. On one hand, this is crazy neat you were able to pull it off. On the stability SRE hand, I'm internally screaming. At scale, this should be handled by Reverse Proxy (Caddy, Nginx, Traefik, whatever)
What an amazing name choice, certainly one way to end up at the top of search results :P<p>To be serious, good job!! Building a good framework is a shockingly large task, and it’s always nice to see people exploring the design space and trying for new ideas.
Well done! You could try to get mentioned on <a href="https://www.arewewebyet.org/" rel="nofollow">https://www.arewewebyet.org/</a>
Based! Django/Rails in a god tier language!<p>my suggestions:<p>- async-trait should be stabilized now, so you shouldn't need the macro anymore<p>- Add opentelemetry integration so we get metrics and tracing out of the box<p>- use jemalloc for linux targets<p>Good work! Keep it up!
I've tried to learn Rust but gave up early. Coming from C#, C/C++, Java, Python, Rust seems weird to me.<p>And it's not the weirdness that discouraged me, is the slowness of accomplishing one task comparing with languages like C#, Java or Python.<p>And since I mostly do web development these days, ease of use and productivity is paramount for me. True, with Rust there might be a bit more throughput and speed, but judging from latest web frameworks benchmarks both C# and Java tend to do very well in this regard.<p>Please, don't read this as a critique of Rust, or me trying to take away such a great accomplishment such as writing a MVC framework from scratch, but more of a "proper tool for the proper job" type of post.
Nice got rustpilled myself recently through ditching webpack js loaders and using rust ones which are 50x faster, rust is so preformance enhancing, c++ and rust are my favourite languages atm.
I've been evaluating and building out small prototypes with all the usual suspects for backend Rust work. So far I've reluctantly agreed with the hive mind that Axum on balance is the best choice, despite being lower-level than I'd like.<p>Other contenders were Loco (but was TOO much like Rails) and Rocket (whose macros only started to bother me after writing more Rust).<p>Your framework seems to perfectly match my criteria of "batteries-included, but not too prescriptive". Great addition to the ecosystem!
Sounds nice, years of Django dev (with some other dev sprinkled in) has really taught me the value of boring old MVC and the rest of the ingredients, will def be having a look.
Congrats! I have a question: I used to have a job as a Rails developer, and one thing i struggled with was knowing which options/hash keys were possible to pass into various functions, due to the lack of typing. Would it be the case that your framework, based in a type-safe language, would give precise autocompletion of all such options? Or does advanced usage of Rust macros remove some of this ability? Thanks!
Honestly, including an ORM as a built-in 'feature' of a web framework seems like a quaintly reasonable idea at first, but I'm 90% certain that eventually it's going to become either (or both):<p>* it's own project because maintaining it will take up so much of your time.<p>* be decoupled from the web framework because users will want to use another because your own doesn't have abc feature.<p>From observing the ecosystems in .NET, Java and PHP, lots of people have lots of opinions on how ORMs should work.
I just noticed that REST framework returns 501 - Not Implemented [0] if the method is not implemented, which I think is really weird. I think that most frameworks return 405 Method Not Allowed in such cases.<p>Also, it is typically assumed that 5xx return codes are retryable while 4xx are not. So, I don't think that not implemented method should return 5xx, because it is pointless to retry it.<p>[0] <a href="https://github.com/levkk/rwf/tree/main/examples/rest#restcontroller">https://github.com/levkk/rwf/tree/main/examples/rest#restcon...</a>
Another related submission from today:<p><i>Ryde: A Rust Web Framework</i> - <a href="https://github.com/swlkr/ryde">https://github.com/swlkr/ryde</a> (October 2024, 5 comments)
Thanks for this. I've been looking for a Django-esque web-framework for Rust for a while now, and it would seem I'm not the only one[1].<p>Also, if you're open to suggestions, use SemVar, and have releases on GH so we get email notifications.<p>[1] <a href="https://news.ycombinator.com/item?id=41760421">https://news.ycombinator.com/item?id=41760421</a>
Thanks for sharing!<p>As a heads-up, The Pages documentation page is blank.<p><a href="https://levkk.github.io/rwf/controllers/pages/" rel="nofollow">https://levkk.github.io/rwf/controllers/pages/</a>
Cool! Since I learned Rust I've wanted a Django replacement that has the functionality of a batteries included Web Framework + the speed/footprint of Rust. I'll check it out!
> boring old MVC<p>> Written using the classic MVC pattern (model-view-controller)<p>well, the "classic web" version I assume. I've never seen a web context in which the original MVC model was used.
Awesome, looking forward to testing it out. I really like that idea of being able to gradually migrate WSGI (Django) apps, or even support running both at the same time.
I can already hear people asking "Did you aRWF already?" Seriously, the migration option is precisely how I think migration for years. Great job!
Does Rust have any DSL for web use (e.g. Rails in someways is a DSL to Ruby)?<p>I ask because I imagine a simplified (Rust) syntax would be more inviting to newcomers.
> I think Rust makes a great prototyping and deploy straight to production language<p>Sorry what? Isn't Rusts whole thing is that it prevents you from prototyping wild ideas, in the name of memory safety?
After years of working with web frameworks in Python and Java, and then picking up Go along the way, I've come to appreciate Go's approach much more. That is, with a rich and capable standard library, you really don't need traditional frameworks. Need an HTTP server, router, etc.? Use stdlib. Need templates? Use stdlib. Need an ORM? You don't, but you may want to consider a small 3rd party query builder library of your choice. And so on.<p>This avoids depending on a complex framework that may or may not exist in a few years, improves security by minimizing the amount of 3rd party dependencies, keeps the learning curve low for any new developers joining the project, and is more flexible and easier to maintain. I don't have experience with Rust, and judging by the comments here, web frameworks might still be useful for it. Which is a shame, since the batteries included stdlib approach is far superior IME.<p>Anyway, I don't want to shoot down your efforts. Congrats on the launch and good luck!
Lately I've been following <a href="https://loco.rs/" rel="nofollow">https://loco.rs/</a> as it aims for a rails-like experience, complete with generators for workers, controllers, etc. I've only had time to experiment but it's the closest I've gotten to feeling rails-y in rust.