Kotlin vs. Java
Michael Spencer
A.I. Writer, researcher and curator - full-time Newsletter publication manager.
Editor's Note: As part of Utopia Press, I'm going to sometimes publish articles on programming, software development, and software engineering trends.
The Veteran vs. the Upstart Challenger of Android Programing is a Hot Debate.
There is some consensus that Kotlin fixes a series of issues that Java suffers. As the Kotlin mobile app development community is continuing to grow, I think we need to rehash this debate.
Back in 2017, Google acknowledged Kotlin by making it the second official language of Android app development. We have to remember what Kotlin is. Kotlin is designed to interoperate fully with Java, as well as being a cross-platform, statically typed, general-purpose programming language with type inference.
Now, at the midpoint of 2019, Kotlin has seen a monumental rise in demand in both the developer and the enterprise community. If you’re a mobile app developer, Java is probably your go-to language for building Android apps. If you want to develop Android apps, step one is picking a language.
For performing the same operation that the Java class does, a Kotlin class necessitates less code. One major difference between Java and Kotlin is that the latter has no provision for checked exceptions. Therefore there is no need to catch or declare any exceptions.
When Google announced Kotlin was its preferred language for android development, we have to give props to the newcomer. This occurred in January, 2019. Formerly, at I/O 2017, Google announced support for Kotlin in its Android Studio IDE.
Aside from Java, Kotlin is one of the languages for which every company is racing to rent a coder for android app development. Kotlin is ranked just 37th on the TIOBE index of September, 2019. Kotlin is also likely easier to learn than Java if you want to get into programming in android apps.
Obviously Java has one of the most important and largest communities in the world. However against the vet is the kid, with more than 50% of professional Android developers now using the language to develop their apps. Kotlin is also one of the most loved programming languages.
Source: Stack Overflow.
- In the above survey Kotlin was 4th most loved and Java was 18th.
- Usually when you are a popular programming language it means you are easy to use.
I think what this means, as Google stated, is that Android development will become increasingly Kotlin-first. Over time many new Jetpack APIs and features will be offered first in Kotlin. So that’s definitely an advantage (note: I have no Kotlin affiliates).
The newcomer also appears to offer a better way of managing intensive operations known as coroutines. Coroutines are stackless, which means they demand lower memory usage as compared to threads. Thus with Kotlin and this feature, it enables or allows the creation of non-blocking asynchronous code that appears to be synchronous.
To understand Kotlin you must go back to 2010, when Oracle, then new owner of Sun Microsystems, filed a lawsuit against Google for copying the Java API for building the Android OS. Just nine years later, it’s not by accident that Google is pushing Kotlin.
Technically we can think of Kotlin as a better thought out version of Java functionally for Android apps. If we compare the two head-to-head on some features we have to see that Kotlin is likely more progressive.
The Big Seven of Android Programming
It’s really easy to think of it when we consider there are just seven major programming languages commonly associated with programming for Android apps.
- Java — Java is the official language for Android development and is supported by Android Studio. It has a steep learning curve, however.
- Kotlin — Kotlin is the most recently introduced Android language and the secondary official Java language; it is similar to Java but in many ways a little easier to get your head around.
- C/C++ — Android Studio supports C++ with the use of the Java NDK. This allows for native coding, which can be handy for things like games. C++ is more complicated, though.
- C# — C# is a slightly more beginner-friendly alternative to C or C++ that obfuscates more code. It’s supported by some very handy tools like Unity and Xamarin, which are great for game development and cross-platform development.
- BASIC — A bonus option is to learn BASIC and try the B4S IDE from Anywhere Software. This is an easy but also really powerful tool, though definitely much more niche!
- Corona/LUA — Another cross-platform tool build on LUA, it massively simplifies the app-building process and allows you to call native libraries.
- PhoneGap (HTML, CSS, JavaScript) — If you already know how to build interactive web pages, then you can use this knowledge with PhoneGap to build a more basic cross-platform app.
Obviously Java is ubiquitous. On Medium in software programming, it even has its own topic. So in this article, I’ve tried to focus more on Kotlin.
TL;DR Although it is safe to say Kotlin is constantly being developed and improved, it is already considered a mature ecosystem and its popularity is growing rapidly, especially on the mobile development scene, in 2019 and most likely beyond.
While Java is a platform-independent language that allows you to create modular programs and reusable code with network-centric programming, along with security features and high-performance that is robust, dynamic and a programmer efficient language, Kotlin is definitely the new kid on the block.
Some programmers and software engineers even believe Kotlin is an answer to the Swift language used by iOS app developers. Java is a near-universal programming language, so its only progress that there could be even better options.
The Aim of Heightened Programmer Productivity
Kotlin is a statistically typed programming language that is primarily employed for JavaScript and Java Virtual Machine (JVM). Kotlin is one of those more efficient programming languages that could replace Java due to productivity benefits. For instance, it introduces several functional features that assist in supporting Java interoperability.
This goal of heightened productivity in programming is really interesting. Its ultimate objective is to enhance the coding experience to make it look practical and useful.
Kotlin’s job is just to be a fun-to-use alternative to Java. Think about it, nothing will replace Java any time soon. A language that is more fun to use than Java and a language that is interoperable with it begs to be a valid alternative and in 2019 that is Kotlin.
Kotlin was designed by the programmers from JetBrains (the guys behind integrated development environments) seeking to add some modern features to Java mobile development. I think they achieved that and then some.
Kotlin is a Win-Win Java Alternative
Kotlin managed to introduce enhanced syntax along with precise expressions and abstractions whereby, using Kotlin with Java, it is possible to reduce excessive boilerplate code. This way, it provides a win-win situation for Android developers.
I think that, in a nutshell, is why Kotlin is such a well-loved programming language in 2019.
A lot can change in software engineering and development in just two years. Think of all the code that has been created since 2017. Since Google introduced Kotlin in 2017, the programming language has seen a vast amount of growth in Android development.
I have no affiliation with Kotlin or Google, obviously.
The reality is that Kotlin never received the recognition it deserved until Google introduced Kotlin as an official language for android app development along with Java and C++ at its annual I/O in 2017 (see above video).
Kotlin Appears Tethered to Mobile App Scalability
Android developers can today employ a single integrated development environment (IDE) to develop Kotlin on all platforms. The latest release provides more mobile app scalability.
Obviously, some features are better in Kotlin while for others Java is advantageous to use. While open-source ethics rule the paradigm of programming language evolution, the fact that JetBrains, the company behind Kotlin, also built the core of Android Studio, i.e., IntelliJ is clear.
Clearly the pros of Kotlin are numerous. It is open source & costs nothing to adopt. Switching from Java to Kotlin is easy — just install the Kotlin plugin, add it to the Gradle build files and click ‘Convert’.
I’m covering future trends in programming and Kotlin has definitely caught my attention as being one of the future programming languages to watch. If interoperability is one of the core use cases of Kotlin, I think we have found a winner. Developers can simply write modules in Kotlin that work perfectly within the existing Java code.
Many programmers, android developers and software engineers say that Kotlin class as compared to Java class is more concise in a majority of cases when they are performing the same task.
The Future of Code
Convenience, higher productivity and alternatives are trying an innovation in programming and the future of code. Both Java and Kotlin compile to bytecode. This means it is possible to call Java code from Kotlin and vice-versa. Kotlin alternatives, in many ways, make more sense to use in the future of android app development than Java.
Since both languages can be used simultaneously in any Android application development project, however, it’s not an us vs. them type scenario. It’s a what can we do together type scenario for the interoperability of software development in apps.
Related reading: Why AI is Becoming Dangerous to Global Order.
Follow a Futurist, sign up to receive blog-rolls about breaking news in Business and Technology & related Op-Eds.
Android Engineer Kotlin | Java
3 年Very good post. Just what the doctor ordered! I am currently working on a mobile project that leverages the power of java and Kotlin and I couldn't agree more with you. Kotlin helps you avoid a lot of boilerplate code and Java's robustness is a massive plus.
Office 365 Solution Adoption Specialist (Including SharePoint, Teams roll out & training) Bsc (Hons) Computing
5 年Interesting post.
Sr. Project&Agile/Scrum Manager | Organizational Change&Transformation Strategist Leader | AI&ML | LGPD & GDPR Expert | BU&Channel Mgmt | M.Sc. ?? Driving Business Success through Strategic Leadership & Innovation ??
5 年Thank you for your nice article. Very elucidative with a direct and clear comparison between both languages. As I am not a developer/coder, I haven't noticed Kotlin or its features and advantages, but already hear and read the most common complaints about to Java. Now I am going to taste Kotlin and start to use in my small projects. Regards.