Rust has come a great way and it’s great to see the language hit 1.0! Unfortunately, us mobile developers aren’t able to share in this awesomeness as easily as our desktop and server counterparts.
Mobile development today is somewhat of a siloed experience, which makes it harder to share code across platforms. One solution is to use a cross-platform framework. Unfortunately, this can have a lot of downsides, requiring licensing of proprietary tools and poor integration with existing tools, and the extra abstractions can have a bad impact on performance and development overhead. For those of us that want to create quality apps without abstractions getting in the way, these options are a non-starter.
Another option is to share code in C and C++. This is a popular option for games, and some apps (including Dropbox) do this as well. The problems with this approach are already well-known by the group here, hence the demand for new languages like Rust. There’s a lot of demand for a better way! As an example, there’s Silver, an implementation of Swift that seeks to make it possible to write Swift code on other platforms. Developers want to be able to write code for different mobile platforms without necessarily using web technologies or dropping down to C/C++.
From what I can see, Rust does technically support Android and iOS today, but on a second-class level and with a lot of hoops to jump through. When I looked it up, I could only find some scattered information on blog posts here and there, and on a Wiki backup on the Rust site and ultimately I ran into some problems and didn’t get it working at all. It may be possible to get it working right now with enough hacking and poking around, but it’s certainly not easy or fun to use.
Here’s what would make me feel a lot more comfortable as a mobile developer:
To start with, it would be really helpful to have some official documentation on the main Rust site on how to setup the Rust compiler for cross-compiling to iOS and Android, with detailed integration steps and instructions on how to integrate things into the build process.
Down the road, it would be super-nice to have prebuilt binaries and scripts that can be plugged into an existing build framework. I don’t know how much work this would take as I’m really unfamiliar with the compiler side of things, but as a user I can say that it would be really great to be able to download some compilers and just start using them! I can worry about FFI but having a working compiler to go with is already a big step!
Having a story for FFI would be very useful for easier integration into existing codebases. I believe there are already scripts that exist here? They would just need to be adapted to make it easy to generate JNI bindings, C wrappers that can be easily called from Swift, and so on. First-class support for Emscripten would also be a big boost, as it would allow targeting platforms that don’t allow native code, including the web and Firefox OS.
So I really hope I’m not coming across as demanding or complaining here, as that’s not my intention at all. I appreciate all of the effort the team and all of the volunteers have put into this and I would do it myself if I knew anything about working on a compiler. I just want to open the discussion with the hope that Rust can be a strong option for us one day, and I’m curious to see if there are any plans for this now or in the future.