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: https://github.com/flosse/rust-web-framework-comparison
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: https://www.arewewebyet.org/
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.