Simple Comparison of Java and Kotlin for Android Development

I have been working on different technologies from the start of my carrier. I had to build an android app which was using oauth1.0 to get data from the API. It was a very interesting app and anther android app I built which was kind of a remote app for wrist band. This was actually my FYP. But anyways I knew that android apps are built on Android Studio.

But I came to know from the documentation that there are two languages Android Studio is supporting. One of them was Java and other is Kotlin. Obviously the word Kotlin seemed very new to me as I never used it in my whole life. But Java is a very popular option. I tried Java before so I knew I could use that.

Until a few days ago I have been using Java for the development of android apps. That was a rough decision as I had deadlines and didn’t had time to learn a new language. But now I wanted to look deeper into the Android App Development so I started digging into Kotlin. I found a very easy to understand Kotlin Course actually designed by Google itself to help developers. I started taking that and after developing a couple of basic apps here is a comparison I can give about both languages according to different prospective.

Learning Curve

When I got into Java it had a lot of syntax and most of the things were difficult to understand. Java is pretty much similar to C++. As I learned C++ in my bachelors degree so it wasn’t a big problem to understand Java. But for a newbie as a programmer I think a lot of topics would be hard to understand.

Learning Java has a lot of advantages as it can be used in other form of applications but the learning curve is steep. The syntax is very detailed. For example, variables are defined with the data type in it.

As compared to that Kotlin has an advantage of being easy to learn. Specially when there is an interactive and easy course available by Google. When I was taking this course I was enjoying so much that I wanted to end the course in one day. The syntax for Kotlin is mush simpler that Java. I wish I tried the Kotlin before but It was still very new at that time.

Community Support

Java is much older than Kotlin. Java was first released in 1995 as compared to that Kotlin is very new and was released in 2016. The project started in 2010 but it took 6 years to get the first release of Kotlin as 1.0. Java has much more applications than Kotlin as it has been a very popular language since it’s release. So the community has been growing a lot for Java.

But Kotlin is weak in that because of it’s age. So if you have issues to solve even for android development you can find millions of developers for your help as compared for Kotlin the number is less.

Functions in Kotlin

This is one of the major differences between Kotlin and Java which is, in Java you cannot use functions directly. They are supposed be wrapped by a class to use them. While in Kotlin we can define functions directly and can use them when needed.

Global functions with availability all over the code with the use of class can be good for the programmers. But not much recommended because the name of functions can get matched and will cause trouble.

Semi Colons in Java

Semi Colors are something which can easily give you frustration to debug the code.

If you are not a fan of Semi Colons, Java is not for you. Kotlin is so good that just like Python semi colons are not required at the end of the statements. Also all modern languages do this to save the debugging time. This is because most developers face the problem with semi colons.

Code Size

The amount of code you write with Kotlin is much less than Java because Kotlin is much concise in syntax. As you know there are no semi colons in Java plus the variables are just defined with val or var term. Similarly for loop is replaced with concise repeat function. And function itself is defined with keyword “fun”. Constants and variables are separated by just two keywords which are val and var.

Similarly the variables can directly be placed into string with $ sign followed by curly braces around the variable or even statements. So there isn’t a need of string concatenation anymore with variables. This gives you a much cleaner code as compared to Java.

Conclusion

This is pretty much it for now. I will write more about it once I get deeper into it and have more experience with Kotlin. I will probably write tutorials to handle different kind of situations with Android Development. If you are looking to start your carrier as a freelancer checkout my posts for freelancing.

For more similar posts you can also checkout ASFABLOG having interesting articles posted frequently.