Hacker News new | ask | show | jobs
by jeroenhd 1312 days ago
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.

3 comments

> 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).