Here you define an interface and you say that you have a function which answers the ultimate question and you register this module. And again, the point is this function and this signature. The Cogen is able to understand that you are declaring a public API that you will use on your JavaScript word. And important information here is that there is an input which is a string and an output which is a number. From this information we can generate a lot of the boilerplate code that you don't have to write.
The thing is that web developers that work with React Native don't really like to write android and iOS code so we're trying to make this like as simple as possible. So how this will look like on Android. We are gonna generate some Java classes. So we'll have like an abstract class with the constructor and a method that respects the signature. So in this case this will be an abstract method that accepts a JavaString in input and returns a double. So we do all the type, we resolve the types to the platform specific types that every platform accepts. So on iOS, for example, you're going to have Objective-C protocol that accepts NSString and returns an NSNumber. Obviously at some point you need to write the business logic, like someone should answer the ultimate question, we can't answer that for you, but yeah, we're trying to simplify like a lot of boilerplate code that is not needed to be written anymore.
Okay, so yeah, like this new architecture required us to do a lot of changes across the board as you can imagine because now there is a code gen to run and there is yeah, a lot of moving parts. So, we took a stance at our build tools, so a lot of changes are actually coming on our integration with the underlying platform, and here there is a little bit of a challenge, because at Meta internally we use a build tool, which is called Buck, which is also open source, and the new architecture for us internally works on top of this, which is great, but we can't expect people outside of Meta to use Buck because it's, I mean it's open source, but we want to use the build tools which are specific to the platform you run on.
So on Android you will run on Gradle, and we took a lot of time to sort of make sure that everything integrates well. There will be some C++ code, so there will be also CMake files that are handled by Gradle. Little disclaimer, a lot of people told me I don't want to see C++ code, so we sort of encapsulated everything, web developers will not have to see CMake or C++ code at all, but it's under the hood and can be used for performance-specific applications. We wrote our Gradle plugin and effectively in React Native 71, this removes a lot of the legacy code and a lot of the build failures users were experiencing when creating your Android app, this logic has been completely rewritten. The TLDR here is that within your architecture, we're actually cleaning up a lot of the legacy code and legacy build infrastructure which built up on our open source code during the years.
On iOS, similarly we do have cocoa pods. And again, we took the stand here to clean up things a bit. We wrote a lot of the logic, now we have a full suite of Ruby scripts which are easier to use, they're smaller and they're fully tested. So hopefully you will see less build failures in the future.
Okay. So, another component that we actually, it's not necessarily part of the new architecture but we spend a lot of time on it and we envisioned the new architecture with these things bundled together is our JavaScript engine called Hermes. So, in the documentation for the new architecture you will actually find it recommended. And we can provide better support. Like if your app is crashing and you have Hermes we can know more what's going on. So, we invite users to use this engine and raise any issues you might have.
Comments