Hacker News new | ask | show | jobs
by the__alchemist 1312 days ago
I won't use it to build a website until we get something like Django, or at least something like Flask's ecosystem. I want automatic (or at least easy and without DRY problems) DB migrations. I want an auto-generated admin page; auth; email.

I will continue using Rust for embedded, 3D graphics, and desktop PC programs, but won't touch it for websites until this is solved.

3 comments

In terms of database and framework design there are several Rust libraries that come close. Diesel for database and migrations and something like Rocket for the backend itself should be enough for a quick JSON API or Thymeleaf based page renderer.

Auto generated admin stuff is pretty rare in anything outside Django I think, though I don't see why one couldn't make those for Rust. I suppose most devs would probably want their CRUD APIs to function on their own and use those for management if performance is critical enough that you'd prefer Rust over something like dotnet or Java.

> Auto generated admin stuff is pretty rare in anything outside Django I think

Just wanted to say that anywhere from Ruby on Rails, to Laravel, to Yii, to... Pretty much every major web framework in the most common language used for web dev (php, python, ruby) has a builtin admin (among tons of other stuff).

Edit:

> Diesel

Diesel doesn't come close to where the ORMs of Django or RoR stand. Not by chance. Having to write by hand SQL (according to Diesel's docs) is something that modern web frameworks solved years ago. And I'm not even talking about automatic mapping of models to tables, automatic migrations, etc... Diesel is simply not anywhere near what a web dev would expect. Not saying that Diesel is bad, just that it's not in the same category where current ORMs stand.

It’s really not that close IMO. Diesel is more analogous to SQLAlchemy. It doesn’t have the nice distinguishing features of the Django ORM like model-based schema generation and auto-generated migrations; it’s on you to ensure your struct lines up with the DB table, and you have to write the SQL for up/down migrations by hand.

The API layer options I have seen are more like Flask rather than generating full APIs from the model schema.

I’d love for this to be the case but Rust is not close to having a Django yet. Part of the problem is that structs are very inflexible; there is no equivalent of the metaclass manipulation that Django does.

You could perhaps build something equivalent with macros? But there is lots of syntactic sugar in Python like descriptors that let you generate really clean class-level APIs.

Rust database and migration story is really not that nice yet. SQLx is nice for pure SQL but doesn't have a good query builder story yet. Diesel is very clunky in comparison to Django ORM as soon as you get to anything beyond basic. Migrations are even less polished.

And in my experience going from Django to anything in Rust will be at least 10 times the boilerplate and some things will be very very annoying to handle, especially things like sharing parts of model, automating things like creation / update metadata for all models, and even sharing authentication mechanism for most routes can be annoying depending on the way you have to do authentication (in my case Firebase auth so authenticating sometimes does require making async calls... And that's a trouble).

We run https://FakeYou.com on Rust/Actix/sqlx, and I'm not missing the "batteries included" anymore. The type safety alone makes Python and Ruby a thing of the past for us. The tests being easy to refactor is really nice too.

Both sqlx and diesel have DB migrations. We use them. Sqlx is actually type checked too, which is awesome.

There are plenty of 3rd party auth and email packages (though we didn't use any, so I can't attest to them). It was quick enough to grow our own internal stuff, which we now reuse internally.

Rust is fantastic for working with audio or video on the server. We're starting work on rendering 3D workloads headlessly.

Another thing Rust can do that Python can't dream of - our servers have easy to manage background threads! We can launch async processes or have long-running background processes (infinite loops with periodic sleeps) that update singletons (Arc<Lock<T>>) of important caches, which is way faster and more durable than Redis in certain cases. Actix makes these a breeze to work with.

Not to take anything from Rust, but there are decent web frameworks that are fully type safe (modern ASP.NET is my favorite, although it's not the only one), with a fully-fledged ORM (build up some experience with LINQ and you'll be missing it on every other platform), background worker threads, etc. So there is middle ground for those unwilling to try Rust yet.
I am a longtime django user my self(since v0.95) and rocket comes pretty close to it.