Live data from Hacker News

Is Rust Ready for the Web Yet? (2020)

blog.devgenius.io

51–60 of 69 posts

Re: Is Rust Ready for the Web Yet? (2020)

#51

Rust is pretty much the only language that runs well on all of front-end, back-end, iOS, Android, Windows & MacOS, with decent UI bindings. Javascript is the only real competition, but the needed shims are lossy at times. C++ is the closest, but Dioxus and Cacao are nicer than anything in the C++ ecosystem AFAICT. It's perhaps not the ideal language for any of those, but there's substantial benefit to having your who…

Java?

Do Java applets even work on the modern web?

Re: Is Rust Ready for the Web Yet? (2020)

#52
post #31

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.

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 c…

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.

Re: Is Rust Ready for the Web Yet? (2020)

#53

Earlier quoted context omitted.

My main gripe with QT is that apps created with it are, as a rule, ugly and non-native feeling. My suspicion is that this is because QT widgets sort of look like native widgets but aren’t quite there, causing it to fall into some kind of “uncanny valley” analogue.

From my experience, the same is true for most Rust frameworks. In fact, I don't think there's a single stable Rust GUI library that tries to accommodate system controls. You can use the win32 API on Windows and Gtk on GNOME, but for KDE and all else you'll need to use some kind of Qt wrapper that has the problems you encounter.

IME your rust apps should use native frameworks. Cacao for iOS, Dioxus for web, etc.

Re: Is Rust Ready for the Web Yet? (2020)

#54

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.

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 wa…

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.

Re: Is Rust Ready for the Web Yet? (2020)

#55
post #27

I've built all my web backends in either Flask or Django - what are the selling points/advantages of using Rust vs. Python in this context? Certainly not arguing against it but am very curious and unfamiliar with Rust. If anyone has moved from Python to Rust for this kind of work, can you speak on your experiences with doing so?

I have a very limited experience with Python (3 months of production experience), but vast Ruby experience and I think a lot of the things apply to both. For me these are reasons why I would choose Rust over Python or Ruby in most cases:

* it's relatively easy to write code that will pretty much never crash. yes, Rust will not prevent all of the bugs, but it will prevent almost all of the things that end up as a runtime exception in dynamic languages. So ou will not end up with an error tracker full of errors

* refactoring is so much easier in Rust - I can enter a new project, change a bunch of stuff and after I fix compile errors and tests my confidence that I didn't break anything is like 10 times higher than in Ruby or Python

* while most of the time speed is not a major concern for backend development, it sometimes is a huge bonus. There were cases in the past when I had to spend a lot of time to optimise Ruby code, because it was just too slow (imagine rendering a lot of HTML, doing computation that is hard to do on the DB side etc)

* handling JSON with serde is just on another level

* Rust is very versatile. When a company starts using a language, they will naturally try to fit as much stuff into the language as possible, after all if you have mostly Python devs, you will prefer Python. A lot of people say "just use the right tool for the job", but even if there was something like "the right tool for the job", in practice it's more like: if the downsides of using our primary tech are huge, let's consider introducing a new language, otherwise let's stick with what we have. I've seen it numerous times in the past. I feel like with Rust the downsides of using it for most of the stuff are much smaller than for example for most of the other languages

Re: Is Rust Ready for the Web Yet? (2020)

#56
post #14

Rust is pretty much the only language that runs well on all of front-end, back-end, iOS, Android, Windows & MacOS, with decent UI bindings. Javascript is the only real competition, but the needed shims are lossy at times. C++ is the closest, but Dioxus and Cacao are nicer than anything in the C++ ecosystem AFAICT. It's perhaps not the ideal language for any of those, but there's substantial benefit to having your who…

QT is still far ahead. This isn't a dig on Rust, but wherever Rust runs, so does C++. There are a lot of dimensions where Rust is better, but definitely not "runs everywhere" and "ecosystem".

C++ does not run as well on the browser.

Yes, QT on the desktop is very good. There are bindings for Rust too, as there are for most languages, but the most integrated one is C++. (I'd say the close integration is just not worth it.)

Anyway, I don't know why people want so badly a single language to run on every context. They are forfeiting a lot of value for that.

Re: Is Rust Ready for the Web Yet? (2020)

#57

Rust is pretty much the only language that runs well on all of front-end, back-end, iOS, Android, Windows & MacOS, with decent UI bindings. Javascript is the only real competition, but the needed shims are lossy at times. C++ is the closest, but Dioxus and Cacao are nicer than anything in the C++ ecosystem AFAICT. It's perhaps not the ideal language for any of those, but there's substantial benefit to having your who…

Runs well in a browser, with ergonomic integration with HTML, CSS, and other browser APIs?

Yes. It's new enough that you will find a bug or two, but it's about as closely integrated as Javascript.

Re: Is Rust Ready for the Web Yet? (2020)

#58
post #45

Earlier quoted context omitted.

Lunatic runtime for Rust to avoid the async parts might become quite nice in the future: https://github.com/lunatic-solutions/submillisecond Not sure what it might take for someone to write database connectors for it but it does look promising.

Looks nice. But I'm not sure why the router needs to be a macro. What's wrong with router.get("/foo", |req, res| -> Response { ... });

Sorry, a better link would have been https://lunatic.solutions/blog/rust-without-the-async-hard-p... Just wanted to comment on the async part that interesting solutions are being developed.
Post reply on HN