We have Fabric, the new renderer. We have a new native module system, which we call the Turbo Module. We have a component which allows to generate code, which is the Cogent, and we also have the Bridgeless Mode.
So once all the pieces are together, we have the capability to essentially remove the bridge component, as I said before, this is called Bridgeless Mode. I want to zoom in a bit on the Cogent and give you a glimpse of what we envision is the developer experience on the new architecture.
So, as I mentioned before, type safety, and the whole idea behind the Cogent is, let's say the developer is writing a TypeScript file which defines the API of a native module. In this case, they will define a spec like an interface with a declaration of all the capabilities of this module. For example, this module is able to answer the ultimate question and takes in input a string and returns a number, and the user will then just register this to a module.
The Cogent works at this level. It focuses on this function and the input type and the return type. And from that it generates a lot of boilerplate code that in the past, developers will have to write manually for both Android and iOS. So let's take a look at that. On Android, we're going to generate an abstract class with constructor and a specific abstract method that adheres to the signature of the spec that we saw before. So we are going to have a function that takes an input, a string and returns a double. It's an abstract function, so it's up to you to implement it and provide the correct business logic. Similarly, on iOS, we are going to have an Objective-C protocol that takes in input on NSString and returns an NSNumber. So we do all the heavy lifting of all the typing from JavaScript layer to the underlying layer, and we generate code for you. So you just have to implement the business logic.
I also want to talk a little bit about the build tools, because as we worked on the developer experience and we introduced the CodeGen, we had to do a lot of changes on how things are built. Specifically, there's also a lot of C++ code that we need to build now, which previously we would have not need to. So there are some changes that you might see, and I want to clarify a little bit of topics.
As you probably know, the build world within Meta and outside is a bit different, because internally we use Buck to build a lot of our code, while externally we can't expect users to. We install Buck and use it for building everything. So we need to adapt to the platform standards. Specifically on Android, we have Gradle. So what we did, we did a lot of work around the C++ code. Users will find references to CMake files or Android.mk files, which will allow them to build their native code. So we don't have just Java and Kotlin code anymore, but we also have some C++ code to build. For Java and Kotlin instead, we spent a lot of time building the React Native Gradle plugin. This is a set of build logic and tools that allows to build essentially React Native application.
Comments