points by treyd 12 hours ago | 0 comments
This is a viable approach for many scenarios. Uniffi is a tool/library from Mozilla that makes this a lot easier across platforms.
After a few rounds of this though it might end up seeming like it's not worth the hassle and it's easier to build the whole application in Rust.
[–] Mawr 11 hours ago
Switching out the entire ecosystem, libraries, tooling; rewriting the entire codebase; learning the new language and its idioms; and then giving up the unknown benefits of the previous language that the new language lacks (for Go->Rust this could e.g. be compile times)—generally, trading known downsides of a language for unknown downsides of another—is a huge undertaking and therefore very unlikely to ever be worth the hassle.
[–] vatsachak 12 hours ago
[–] treyd 12 hours ago
[–] vatsachak 12 hours ago
For example,
- A field in a struct cannot borrow another field so now you'd have to create two structs. I guess you could write an impl to borrow that field instead of storing the borrow.
- In simulation software I wrote I found that mimalloc does just as good as bumpalo (within 5%) so carrying a bump everywhere was useless. Not really a rust issue but rather a loss of faith in manual memory management for me.
- Eventually over time you start adding Arc<Fn(Blah)->Foo> everywhere and Box, Arc and friends start coming in. But you can't have cyclical references there so you have to use Weak. And you have to use OnceCell or LazyCell or LazyLock for things that should run at start time.
Rust is really great for the crates, but ...
For applications which are not absolutely performance critical and cannot* be stated pretty easily in linear logic + clone + drop you can get away with Haskell