Kotlin vs. React Native: Which Is Better?
Let's take a look at the basics of Kotlin and an honest comparison of the pros and cons of Kotlin and React Native for mobile applications.
Join the DZone community and get the full member experience.
Join For FreeThe world of tech is host to no single language. Too much choice is a head scratcher in itself.
Kotlin, a programming language, pitched against React Native, a JavaScript library - let's see what sticks and what slips.
What Is Kotlin?
Kotlin is a new powerful language created by JetBrains. It is a statically typed, general purpose and an open source programming language that combines object-oriented and functional programming features.
After being endorsed by Google as the official language for Android Studio, Kotlin has garnered quite a lot of popularity. A JVM (Java Virtual Machine) based language so a great contender to java. It is fully interoperable with Java, provides great safety with strong tooling support.
Given the fact it is fairly new, most people frown on its community support BUT the official documentation from Jet Brains (the developers behind Kotlin) is very thorough and well-constructed. That makes it easy to learn for any willing mind.
But is Kotlin better than React Native? Lets take a look at React Native first.
What Is React Native?
A next-gen member of the React family, React Native is a JavaScript library used for creating User Interfaces. It is created by Facebook along with Instagram and the community.
Its been 5 years since it was first released. A new stable version came out on Nov 28th '2017. With React Native, you can create Android, iOS, and UWP native apps. What's great about React Native is that there are very little differences between a finished app built in Objective-C or Java and one built using React Native. So you could use it as an alternate to Kotlin as well.
But just like any other language that is out there, there are some pros and cons to all.
React Native gives quick prototyping and a very high initial velocity, but is it great enough to use instead of Kotlin for Android applications?
Let's weigh in the pros and cons of Kotlin and React Native.
Kotlin Pros
Maintainability: Kotlin is backed by a great company which is responsible for creating some of the very best IDE tools brought to light. There is no chance JetBrains will neglect to provide tool support for Kotlin. Already, Kotlin has phenomenal support on various Development environments including Android Studio. So if you are choosing Kotlin, know you are choosing a potential giant that could be used across multiple tools and IDEs.
Less code: Think about coding. It is basically just writing and with any writing, one golden rule always applies: "The less you write, the fewer mistakes you make." Kotlin code is not only concise but it has a very clear codebase. That leaves less room for errors (unless you are a complete noob) and more room for stable code in production. You have to write less number of lines of code to achieve the same functionality.
Reliability: Kotlin is a mature language which first appeared in 2011, it has gone through multiple testing stages before the final release. It is a programming language created by programmers and they catered to a lot of issues with a developer's perspective. One of which is they made the latest release reversely compatible with the previous versions as well. Working on Android and having to deal with different versions is one of the biggest pain points that I have come across, so believe you me when I say, Kotlin's reliability is a blessing.
Compatible with existing code: Java interoperability is yet another Pro I would vouch for in Kotlin. The language works well with Java itself, including all related tools and frameworks, which provides a rich ecosystem.
How does that help with a Kotlin vs React Native comparison?
Well, for starters, Java learning material and online help is a huge sea. Anything you can't do in Kotlin, you probably can in Java. Some say it's a new learning curve, I say its a great potential for Kotlin to build a great developer community soon.
Why? Because people who are seasoned in Java will have no problem shifting over to Kotlin and thus contribute to the Kotlin community flawlessly! Since Java and Kotlin code is interoperable, you won't get completely stuck.
For React Native, you don't have this luxury.
Kotlin Cons
Team training: Okay, so the people who are not well versed in Java (because a lot of you think you are, but aren't!) - I think this will be a Con for them. There is some difference in Java and Kotlin after all, so yea there will be a learning curve for them. Such a developer will have some resistance switching languages. I say that with the foresight that it will call for investments in training and require more time in shifting your Android development team over to Kotlin.
Slow compilation: Some developers report slower compilation speed as one of the main drawbacks of Kotlin. In some cases, Kotlin is faster in compilation speed, but sometimes it is significantly slower.
Smaller community: No matter the potential, even though Kotlin is rapidly growing as a strong language, it still has a small developer community, at present. That means there are limited resources for learning the language and there will be a lot of questions that will turn up unanswered, even with the Java pool of learning.
If you search for Kotlin on StackOverflow, it returns just over 3,600 posts tagged with Kotlin, at the time of this writing.
Over to REACT NATIVE - let'smap out the Pros and Cons of React Native.
React Native Pros
Faster to build: The major selling point of React Native is shorter development time. So I would say that is React 1 and Kotlin 0. How is it faster? There are numerous ready-to-apply components that beat having to create such functionality from scratch BUT they are limited. Some solution are still missing in React Native, so you would be back to square one - building them from scratch. So it basically boils down to two things:
If you find your desired components in React Native, then you are all good for a fast build.
If you don't, it would mean the same as developing in Kotlin.
If you didnt skip the RN intro I wrote, then you know it is a Facebook product. They do have a great community and to top it off, The guys at Facebook are busy bees when it comes to introducing new and regular updates. Up till now, React Native has been getting monthly updates so the light at the end of this tunnel feels really strong.
Same app quality: This might not mean anything to some of you, but apps developed in React Native vs. apps developed in Kotlin feel the same. That is so because React Native renders using native components. So you get the same look and feel of the app. That's just like two people using the same pen to write.
Shoot two platforms with one framework: The obvious pro, I think - you get to target multiple platforms with one Framework, mainly iOS and Android. Not all features will be available in apt packages, you will need to be write your own versions for the ones missing, but you will have two applications with the effort for making one.
Hot reloading: One of the best things about React Native - The hot reloading feature. You get a 'LIVE' feedback of whatever changes you make to the app, WHILE the app is running. That eliminates a lot of pain points in having to work with UI. TEST AND SEE TEST AND SEE, That's how it works and it works perfectly. Saves time in compilation, concentration and productivity.
Smaller teams: Native development requires two separate teams for Android and iOS. It can hold back communication between developers and, thus, slow down the development. If you choose React Native, you will at most need a good JavaScript developer who can write the code for both platforms. Obviously, apps with more native features will require help from native developers as well. Not denying this fact, in most cases, the team will be smaller in size, and thus, easier to manage. One developer can code for both iOS and Android. Reducing team size, expenses and generally reducing the time it takes to develop. This is a big advantage since there is no need to learn two different languages and platforms, it is enough to know only one.
A web-full taste: The JavaScript edge finally pays off here. For web developer out there, if you are ever thinking of transitioning to mobile development, React Native could make the shift easier. JavaScript is relatively common in web development and React Native is a JavaScript Library. It will make Mobile development seem a bit familiar and easy to adapt to.
React Native Cons
Struggles on the performance: It’s known fact that JavaScript code is lacks on the efficiency for calculation-intensive tasks, and then there is an overhead as well when JavaScript is put to controlling native elements. If you compare an optimized Kotlin app with a React Native app, React Native will fall behind.
Less smooth navigation: React Native still lacks navigation components to provide users with seamless UX. There is no ideal solution, up till now, in React Native for navigation between displays.
Lack of some custom modules: React Native lacks some very basic components. Chances are you won’t have a problem with that, as the majority of custom modules you need are available, well-documented and working properly, but if you do, you will have to use a native component written from scratch.
Native but not native: So React Native does not have all the native modules covered, that's clear by now. But why is that a CON? Because for the parts which you have to write yourself, you will have to code separately for Android and iOS. That kills a lot of benefits React Native brings - The small team, Less time to develop etc. If your developer does not have apt knowledge about the native language (iOS or Android), which is something (he/she) was probably avoiding in the first place by choosing React Native, this will be a major problem.
Facebook rules: Now comes the bane to all that is React Native. If you ever got in a lawsuit battle with Facebook, (trust me, its not that unlikely), you can't win with react native code in your app against Facebook. Under their license, you do not own React Native code in you app. So, you will either have to leave the option open for them stealing your code or not use it!
Using React Native for its intended tasks performs quite well - but I think, this JavaScript library, with all its goods and glory, cannot outweigh Kotlin as a language.
What did you decide? Which is better, Kotlin or React Native?
Opinions expressed by DZone contributors are their own.
Comments