Archives
- Newer posts
- November 2024
- April 2024
- November 2023
- October 2023
- August 2023
- May 2023
- February 2023
- October 2022
- August 2022
- July 2022
- May 2022
- April 2022
- March 2022
- February 2022
- June 2020
- March 2020
- February 2020
- January 2020
- December 2019
- November 2019
- October 2019
- September 2019
- August 2019
- July 2019
- June 2019
- May 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- June 2018
- May 2018
- April 2018
- March 2018
- February 2018
- January 2018
- December 2017
- November 2017
- October 2017
- September 2017
- August 2017
- July 2017
- June 2017
- May 2017
- April 2017
- March 2017
- February 2017
- January 2017
- August 2016
- June 2016
- April 2016
- March 2016
- February 2016
- January 2016
- July 2015
- June 2015
- Older posts
Kotlin – The next step for android
Android…, No, I’m not talking about an AI Robot, but that mobile OS that has different candy versions. It was founded by 4 people, and like all great things, it usually comes with a difficult beginning. It’s intention at the time of inception in 2003 with just about $10,000 wasn’t at all for mobile phones or TVs but rather for digital cameras. But that didn’t work out too well and that’s when they switched over to mobile devices.
Google saw the potential that android had to offer and bought it in 2005 for a whopping $50 million. Android is based on a modified Linux kernel. So why am I telling you this? Because to know where you are heading, you should know what has led you to it.
To build a functional app that can run on Android, the primary language used is Java. What’s Java you say? Well, in short, its a very powerful class-based, object-oriented programming language … another topic for another day. Java, had been the reigning language used to develop applications for Android until 2017. And like all the great ones, they have a prodigy, namely Kotlin which was born out of the aspiration of heightened productivity at Google. For the past 2 years, those geeky developers at Google, much like you and me, have been creating support to be able to ease the transition with cross compatibility of Java and Kotlin being used together. And now Kotlin is all grown up and has taken over the mantle to be able to develop applications for Android.
So what’s the prodigy got that makes it better to use than an already existing powerful programming language? Well here are some of them:
• Brevity
In simple words, it would actually mean using simple words, It would be concise. A piece of code that would take Java about 20 lines of code could be accomplished in half with Kotlin.
• Interoperability
Kotlin’s core purpose is Interoperability. Using everything that is already known, the developers aim was to create modules that would work flawlessly with existing Java code. A Kotlin compiler allows it’s own code along with Java code to work in unison.
• Inbuilt Null Safety
If you’ve developed an android app using Java, you could have probably frequently encountered a lot of Null Pointer Exceptions. Android relies on a Null value to represent an absence of a non-null value. But null, if not handled, can usually be the start to many problems that cause your app to crash. Kotlin solves this problem by inherently incorporating null safety. This in turn, saves the developer a lot of coding time that can be used elsewhere.
• No RAW types
RAW types used to be used for backward compatibility, but again, the problem would be that it would sometimes throw a CastClassException Error that would occur only during runtime and not compile time. Generics are now being used to overcome this limitation.
• No Checked Exceptions
Checked Exceptions are basically exceptions when the compiler forces the caller of a function to catch or re-throw an exception. In simple terms, they are empty catch blocks sometimes. So Kotlin has removed them entirely which in turn provides verbosity and improves type-safety.
The above mentioned points are some of many benefits of using Kotlin, So should you switch over to it right now? If you are already well versed with Java, then the transition should be relatively easy. There are mixed opinions in the developer community where Java will gradually not be used any more and will be replaced by Kotlin altogether.
In my opinion, I’d say, go for the switch, because I can see two key benefits that would majorly help me as a developer especially on large projects. The first being, reduced project timelines. If you’ve paid attention to anything I’ve written, you’d have deduced that fewer lines of code would need to be written which would help you solve more problems with lesser time. The second being, fewer app crashes, which is also linked to the first point because, reduced development time would also mean more time with support for maintenance. With simplified code and enhanced readability, it would be easier to debug and find bugs if any.
There are roughly about 3 Million developers already on board with using Kotlin for developing apps for Android. And it doesn’t look like Kotlin will be disappearing anytime soon. If you are interested in finding out more about Kotlin, visit the Android website.