When can a Rust's version of Django be expected?

I know about http://www.arewewebyet.org/ - and I know we're not there, but given the speed of progress that Rust is making in terms of libraries, packages and tools, in your opinion, where can a release of a Django-scale web framework can be expected?

Is it likely to be built on Actix, Nickel or some other project?

2 Likes

When someone will make it. What's under the hood is really minor detail.

One issue is with async, as lot of people would want it in modern framework, while ecosystem is not there yet, and won't be a while.

What I'd like to have:

  • ORM and schema management. Diesel is the only option at the moment, but its not something I'd use in a framework as it is. Usability is definitely not where it should be (it can't generate migrations, works with types defined by database protocol instead of the content, requires lot of repetition when defining your models). Something on top of it maybe would be usable.

  • configuration support. I want framework to be opinionated here, so that its components have something to rely on.

  • good deployment story

  • solid frontend support. Either provided, or easy to add.

I think there are three major components that makes Django awesome: The first is of course the web request handling, routing, etc. But there is also the template languge and, perhaps the most awsome part, the database ORM.

The primary property making those three things awesome is how well they are mapped to the python language. So of course, a Rust web framework as awesome as Django would not look that much like Django.

My current favorite web framework consists of warp, ructe, and diesel. All are very different from their Django counterparts, but i think that reflects the difference between python and rust in a good way.

1 Like

Askama (there is also tera, which I haven't used) implements jinja2 templates, so that part looks exactly like Django. I rewrote one of my Django apps in Rust, the code related to templates is identical, with benefit of type verification. Every web framework out there can do routing, and you could easily add whatever syntax/conventions you want to have. I wouldn't design it the way Django does it today, but you easily could do that.

If you want Django as it is today, the only missing part is ORM and migrations.
The only working option here is Diesel (which I am not big fan of, at least using it as it is now).
For migrations there is barrel, so this probably could be done as well fairly easily.

However there are few things that changed since Django was created, so exact copy is not the ideal option.

  1. People use Angular/React/Vue and generally handle frontend with js tools. I don't do frontend work so I am not sure how would that affect design of web framework, but it probably does.
  2. Async is far more popular, and even Django has plans for that. However Rust async doesn't really exist atm (99.99% of library authors don't care about that and won't for near future).
  3. Django doesn't care about deployment story, leaving many things to docker/uwsgi/nginx and others.
    I don't think new framework today could leave it that way.

Also Django relies on Python being interpreted language. Your authentication backend is defined as class name in configuration. You woudn't want that in Rust.
And I run manage.py shell very often to test code or check/fix db issue. I miss that a lot with Rust.

I much prefer diesel's approach to databases over django.

I think that that ORM and schema management is complex enough to warrant to make a transpiler, i.e. From SQL + toml configuration file to Rust code.

Problem is that each database use SQL that are a little bit different, but extra bonus with a transpiler, is that simplified code is zero cost at runtime, and can shave a lot of code off that an appllication would otherwise has to go through, compared to an ORM that runs at runtime.

This could be an interesting read for some:

There is a web page here: Simple is better -Template Engines that compares different types of Python template engines.

There are benchmarks (with comments) of the template engines on that web page, and even further down the page there is a comparison of the template engines.

Actix has always been async and master has moved to the new async api. Looks like async Rocket is also making good progress.

They both rely on Diesel though, which is not async.