5

React Native recently introduced experimental support for Turbo Modules, which allow developers to write code in C++ and call it directly from Javascript.

Is it possible to write a Turbo Module in Rust instead of C++? Generally Rust has good interoperability with C / C++ so I expect it is possible, but I couldn't find any examples of it after searching Google, StackOverflow, GitHub, etc.

If it is possible, are there any downsides to doing so? Do you losing typing information for instance?

justinmoon
  • 443
  • 5
  • 11
  • 2
    @Miiao I think your answer is both opinionated as well as misinformed. Sure, you can do everything with everything. But the actual question is probably how hard it is, and I would say it depends. Given the fact that the turbo modules homepage says "codegen", "experimental" and the C++ is some C++.net dialect or similar, I'm not sure if it's quite as simple as you make it seem. Also, if you don't want people to hate the 'Rust elitists', don't express hate for their languages. – Finomnis Jan 01 '23 at 23:07

1 Answers1

2

You can use bridge between C++ and Rust https://cxx.rs/ Follow this thread to get an example of Rust integration https://twitter.com/_va_run/status/1493699146552803329

Kirill Novikov
  • 2,576
  • 4
  • 20
  • 33