React-native — transpiled , pure native or hybrid ? — part 2

Sahil Sharma
2 min readMay 12, 2016

--

In the previous blogpost here, I discussed about two approaches, one involving writing pure native apps, the second one writing pure hybrid.

Now another approach is that you write the code for an app in a language ( common for all the platforms ) and the same code gets transpiled into different languages depending upon the platform ( eg java in android and objective C in case of iOS). One popular tool that uses this approach is Xamarin ( recently Microsoft open sourced after acquiring the company). In Xamarin, the developer writes code in C# ( actually there is a lot of user friendly drag and drop features available as well) . And at the end, the same code runs in iOS as well as android. So let me clarify, in the end, the components being rendered are pure native components and not in webview. But a drawback in using Xamarin is that you are always catching up with the technology i.e. you will need to keep updating the transpiling tools as Java or objective C change.

Finally, lets talk about react-native. Whether it is android or iOS, every phone does have a javascript engine, so why not take advantage of that to solve this dilemma of choosing technologies for mobile apps. So, as you guys might have guessed already, ( don’t worry if you did not) react native is written in javascript and instead of being transpiled to the native language , or using a web view , it uses the javascript code to call the native methods provided by the platform. In a nutshell , react-native will call the components exposed by the platform. As a result you can separate out all the business logic ( that can be upto 70% of the code of your app) and reuse it. Hence you will need to write only the remaining platform specific code again. React-native’s motto is “LEARN ONCE, WRITE ANYWHERE”.

--

--