Something like Ruby on Rails for Rust

I am coming from Rails and I have to admit that the productivity of rails is amazing. However, it's slow like hell. This is where rust comes in the picture. Wouldn't be a good idea to start a framework like rails but in rust? I believe it would be incredibly fast and gain traction very fast. Any thoughts?

As with most things, the devil would be in the details for this. Rust and Ruby are very different programming languages, and the project’s success would probably hinge on how successfully the design manages to bridge that gap. It’s a lofty enough goal that anyone attempting it will gain a lot regardless of where things ultimately end up; I wish you the best of luck on your project.

I haven’t used any of them, but there are several Rust-based webapp frameworks already that you might look to for inspiration:

1 Like

From my perspective, there's only three in the world which is something like Ruby on Rails - the Rails itself, the Java on Spring, and the Python on Django. No other frameworks are fully featured all-in-one like Rails. But to be fair, the Django is the youngest in the three, which is 15 years old. Even older than the Rust v1.0 itself! Maybe frameworks currently we have can be the fourth of them after 15 years? Who knows!

There are a few web frameworks for Rust, some of which are high-level:

However, there are two issues:

  • Rust is a lower-level language than Ruby. Some of that amazing Rails productivity is thanks to Ruby having a lot of magic and hiding a lot of boring low-level details that Rust can't.

  • Rust is way faster than Ruby, but for web apps the bottleneck can be in the database layer. If the app is slow because of ActiveRecord like database access, it'll be slow in every language.


That's a good point kornel. Using object oriented in rust we could do better then Ruby. For Database layer, I wouldn't use an ORM as this slows down everything. If I would use an ORM, I would make a simple one with better performances if possible. However this is a huge project that will take years.

I think it might be a bit early for something like this in Rust. But I could see it being possible in a year or two. You could possibly build a fairly good mvc framework my integrating a few existing parts.

For the controllers, you could build on top of Rocket or just take inspiration from it. The macros make it very simple. By using convention and some macros, you could make something straightforward and easy to use.

For views there are many template engines available. ructe seems the most like irb.

For the models, you could use Diesel. The main problem I could see is that Rocket is moving to async and Diesel has not found an async api that they like. This could be solved by using an async database connection library like tokio-postgres and implementing traits on top of diesel that would use those connections rather than the connections from diesel itself. ORMs are slower but I think it is still worth it. An ORM in Rust will be a lot faster and memory efficient than an ORM in Ruby.

Most of the challenge in getting this right is integrating pre-existing libraries, coming up with good conventions, developing a good cli that can help bootstrap projects and generate boilerplate, writing great documentation, and providing tutorials. (This would be a lot of work but at least you wouldn't be starting from scratch)

Even if it isn't much faster because of a database bottleneck (inherit or accidental), I would think that it would still be worth it. My company has a Rails app in production and it is constantly using like 1 Gig of memory with 2 threads even though it is mostly just talking to DB. I think with Rust we could save a lot of money by having fewer, less expensive VMs. It would have also saved us a lot of time trying to fix bugs in the long run because of a strict type system.

I don't know if there would be a ton of interest for this though. Personal, I prefer to have a simpler api and then a separate front end instead of a full mvc framework. Rocket will probably end up being enough for me. Also, most of the work I have seen with web in Rust is to create super performance critical services. But maybe a good mvc framework would encourage more use of Rust on more common use cases as well.


I've been experimenting to see if it would be possible to reach the same productivity while keeping the performance.

I was able to create a router that looks like one that you get on rails using procedural macro.
Router looks like this:

router! {
    scope "/api" {
        scope "/v1" {
            get api::v1::get;
            post api::v1::create;
            delete api::v1::destroy;
    scope "/resource" {
        resource index::resource;

I think this is pathway is worth exploring. Rust is already very fast. And even if you implement in a way that sacrifices some performance for productivity, it shouldn't be that difficult to achieve good performance.

By the way, my router implementation is faster than that of the actix's; since the procedural macro will convert the input into a match statement.

Here is my github repo.
I'm planning to make few updates, so your welcome to put it in your watch list :slight_smile:

My thoghs:

The power of a framework comes from well-integrated fundamental parts and a bunch of conventions. For Django its settings, ORM (including managing migrations) and views. Once you have that, the rest is trivial to do.

For Rust, all but ORM are already done so it would be fairly simple to combine them into a framework, but the ORM is a tough one. The only contender - Diesel, is nowhere where I'd like ORM to be, when it comes to features and convenience.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.