Kotlin and Java: Where Do They Fit In?
With Kotlin getting a huge bump at Google I/O this year, let's see how it will impact Java. Let's see how the languages stack up why you should check Kotlin out.
Join the DZone community and get the full member experience.Join For Free
On May 17th of this year at the Google I/O keynote, the Google Android team announced that Kotlin is now the official Language for Android development. Developers have been using Kotlin to build Android apps in previous years but Google just announced first-class support for it. Now let me give a brief history of Kotlin.
Kotlin is basically a statically typed programming language that runs on the JVM that was first announced in July 2011 but was released to the public in February 2016. It was called "Project Kotlin," and it was created by a team of JetBrains programmers based in Saint Petersburg, Russia. In fact, the name Kotlin comes from Kotlin Island in Saint Petersburg.
What Makes Kotlin Better?
Both Kotlin and Java can be used to build Android apps, but since the release of Kotlin, you might be wondering why you should switch programming languages. Well, Kotlin was designed to fix some issues Java had and makes learning to code easier. These are some of the issues Kolin helped fix:
- Kotlin's typed system eliminates
NullPointerExceptions from code.
- Kolin is designed to be flexible and easy. Remember, even Java code can be called from it.
- There is an Array class with a get and set functions alongside a few other functions.
- A function can accept another function as a parameter.
- There are no checked exceptions on Kolin.
- Kotlin code is concise and portable compared to Java.
- You can use existing Java libraries for JVMs, browsers, and Android development on Kotlin.
What Other Applications Can You Build With Kotlin?
- JVM: You can develop server-side applications with Kotlin just as you can do with Java, with frameworks like Spring, Vert.x, Ktor, etc. Projects can also be deployed by any host application that supports Java web applications like Amazon web applications, Heroku, and Google Cloud Platform.
- Native applications: Kotlin can build native applications with existing Java code. You couldn't build native applications with Kotlin until recently.
What Happens to Java? Should You Switch to Kotlin?
Java is not going anywhere at all, even though Kotlin now has first class support for Android development. There is more to Java than just Android, and if you want to be an Android developer or you're new to programming in general, I would still suggest you start with Java. Once you feel comfortable enough, you can then move to Kotlin. That way you will have a much deeper understanding of the language(s), and if you run into Java code inside a Kotlin project, you'll be more familiar with how to react.
In conclusion, Kotlin is a great programming language that was built to resolve many problems in Java and other object-oriented programming languages. It's reliable, flexible, compatible and very easy to learn — and if you're using Java for Android development, then you should definitely consider it. It's the future.
Published at DZone with permission of Anthony Awuzie. See the original article here.
Opinions expressed by DZone contributors are their own.