I'm currently evaluating possible options for technology stack for my mobile app. I would really like to try Rust for the backend, however I have some doubts that there are missing bits and pieces everywhere and I would have to develop a lot of stuff from scratch compared to if I chose a well-established platform like Firebase or Parse. If anyone has an experience of building mobile backends in Rust and difficulties you encountered, I would much appreciate it if you shared them here. Also if you think why Rust is or is not a good choice for building mobile app backends, please let me know too.
What is a "mobile" backend? A backend is a backend, regardless of who calls it.
Rust is a great language for writing backends, because it makes it a lot harder to make dumb mistakes that affect every user, including security vulnerabilities (memory safety or otherwise) and database misuse.
For specific questions on what is or isn't there in the ecosystem, see Are We Web Yet.
I assume you mean backend as a network server, not any code running on the mobile device.
In that case I'd be cautious. Rust is not always the best solution for that.
Rust would be a good choice if:
You're already familiar with Rust and have experienced Rust devs on the team. Network backend will require use of async Rust. On the technical side async is IMHO very good, but it does add a few more things to learn to an already steep Rust's learning curve. Rust can feel high level and be very productive once you know it, but if you're learning as you go, you might get stuck. You can get results faster in a higher-level garbage-collected language.
If you need to work with significant amounts of data and/or low-latency. If you e.g. need to process video streams in real time, generate images, or parse high volume of messages. Rust can be much faster and more memory efficient than server-side scripting languages. OTOH if all you do is fetch things from a database and serve them, you can do it with almost any language.
Or if you work in a domain that requires high level of correctness, where some unexpected
null field could cause more trouble than just refresh of a page in an app. Rust generally doesn't allow cutting corners, and its strict type system can catch more problems at compile time than you'd get from a more forgiving language.
Firebase is not comparable to a "Rust backend" per se. The former is a fully integrated cloud platform for developing mobile and web apps. I don't think there is a platform with comparable functionality that has a Rust client. So you'd definitely have to write more stuff from scratch. The pros I see of writing your own backend (in Rust or any other language) would be flexibility, no vendor-lock and you may safe some hosting costs in the long run (if your app goes through the roof—I don't think this will be true for smaller apps).
By "mobile" backend I mean a server that supports:
- REST API endpoints;
- Real time messaging (like chats);
- Push notifications (Apple and Android);
- File uploads;
- Integration with Database;