Kotlin Programming Language : Ask Your Queries Here

TheSloth

The Slowest One
This thread should be used to ask Kotlin related queries, be it a general query, related to a particular topic or any code in which you need any help or guidance.
 
OP
TheSloth

TheSloth

The Slowest One
So let me start with a general query here.

People learning Kotlin, is it really worth investing time to learn the new Syntax of this language even though its very similar to Java? If yes, please mention the reason as well.
What is the learning curve? What do you think about the future aspect of this language, will this become more common than Java or at least as much common as Java?
@thetechfreak and @Desmond David please give your inputs
 

Desmond

Destroy Erase Improve
Staff member
Admin
People learning Kotlin, is it really worth investing time to learn the new Syntax of this language even though its very similar to Java?
Kotlin syntax is not similar to Java, it is actually similar to Scala. But compared to Java it is less verbose, which reduces the effort on the developer. Plus it interoperates with Java classes, so you can use Java libraries with it as well.

What is the learning curve?
Not very difficult, but you have to use it to get a feel for it.
What do you think about the future aspect of this language, will this become more common than Java or at least as much common as Java?
Google has announced first class support for Kotlin, especially since the Oracle lawsuit. So, I see that it will be more common for Android apps (Arogya Setu app is written in Kotlin for example). But it is also good as a general purpose replacement for Java. Whether it gets more popular than Java that remains to be seen.
 
OP
TheSloth

TheSloth

The Slowest One
Kotlin syntax is not similar to Java, it is actually similar to Scala. But compared to Java it is less verbose, which reduces the effort on the developer. Plus it interoperates with Java classes, so you can use Java libraries with it as well.
I am still not convinced about the verbose part. It seems like several steps are combined in a single step where as each line in java has a distinct purpose. and then its becomes easy to give one look and know what the program is going to do. I am obviously biased and so much used to Java that I found Kotlin shortcuts bit more difficult to remember.

Not very difficult, but you have to use it to get a feel for it.
I see.

Google has announced first class support for Kotlin, especially since the Oracle lawsuit. So, I see that it will be more common for Android apps (Arogya Setu app is written in Kotlin for example). But it is also good as a general purpose replacement for Java. Whether it gets more popular than Java that remains to be seen.
Nice. I didn't know this.
 

Desmond

Destroy Erase Improve
Staff member
Admin
It seems like several steps are combined in a single step where as each line in java has a distinct purpose. and then its becomes easy to give one look and know what the program is going to do. I am obviously biased and so much used to Java that I found Kotlin shortcuts bit more difficult to remember.
TBH at this moment, you will need to have some understanding of Java to effectively work with Kotlin. Technically you can still write verbose code with Kotlin if you wish for the original Java experience, but as you learn the shortcuts, you will find that coding in Kotlin is faster since you don't have to think about constructors, getters, setters, etc.
 

thetechfreak

Legend Never Ends
Definitely worth learning Kotlin as Google will phase out Java eventually.

However as someone familiar with older Android development I'm yet to pick up Kotlin. Just too lazy to be honest. Found learning React Native more convenient as it can cover both platforms

Sent via Tapatalk
 

pkkumarcool

Game & anime Lover
Will try to learn Kotlin will be my next task as i am trying to learn Android Development again.

Before used to do that with Java making calculator type apps.

One query How is Kotlin different from Java i mean is it less complicated than Java in syntax and all?
 

Desmond

Destroy Erase Improve
Staff member
Admin
One query How is Kotlin different from Java i mean is it less complicated than Java in syntax and all?
The best feature of Kotlin I think is that it reduces the verbosity of Java. The syntax is kinda different as well, but you can get used to it is as you write code. I personally find it much easier to write in Kotlin than Java because of the reduction of effort.

However, note that Kotlin is still a JVM language like Scala and Clojure. So, it still runs on top of the JVM. The advantage of this is that you can use Java libraries in your Kotlin project and vice versa.

Kotlin also has a Kotlin-native compiler that compiles directly to system executables rather than JVM bytecode, so it's not necessary to depend on Java all the time.
 

Nerevarine

Incarnate
Kotlin syntax is not similar to Java, it is actually similar to Scala. But compared to Java it is less verbose, which reduces the effort on the developer. Plus it interoperates with Java classes, so you can use Java libraries with it as well.
Java is fucking verbose, i hate a lot.. but its my goto language to use in coding interviews if i need complex data structures like hashmap. Kotlin usage isnt very widespread but you make it sound useful if it can use java classes natively.. Maybe I should try it
 
OP
TheSloth

TheSloth

The Slowest One
Alright. Why verbose is a problem? I like that each statement in Java convey a clear message to the developer what exactly it does. It helps in understanding what previous dev has coded, a bit quicker. I am repeating this point again here I know. And of course a Kotlin dev will understand Kotlin code easily. But why verbose is a problem.
I want to know, how much time a dev saves by coding same logic in Kotlin instead of Java,
@Desmond David had you coded that CTC app in Java, how much extra time it would have consumed? Will you be able so save significant amount of time when you start adding complex features which involves lots and lots of coding??
 

Nerevarine

Incarnate
Alright. Why verbose is a problem? I like that each statement in Java convey a clear message to the developer what exactly it does. It helps in understanding what previous dev has coded, a bit quicker. I am repeating this point again here I know. And of course a Kotlin dev will understand Kotlin code easily. But why verbose is a problem.
I want to know, how much time a dev saves by coding same logic in Kotlin instead of Java,
@Desmond David had you coded that CTC app in Java, how much extra time it would have consumed? Will you be able so save significant amount of time when you start adding complex features which involves lots and lots of coding??

One example is, until java 10, there was no equivalent of auto from cpp, i.e. type inference.
You had to manually declare the variable type and fill in the fields. In java 10, they introduced var keyword that does the same.

most modern programming languages come with equivalent of auto.

You wouldnt need to do this :
String[] listOfStrings = {"Abc","Def","sdf"};
vs
var listOfStrings = {"Abc", "Def", "sdf"};

var is automatically type inferred from rvalue.
 
OP
TheSloth

TheSloth

The Slowest One
Earlier Java did adopt type safety and adhered to it very hard but last few versions have been really good especially bringing in lambda expressions, stream's map filter and reduce. No one back then would have imagined passing a function as a argument back then. Java will adopt all the best techniques required by devs as the time changes.

Anyway I better try to learn and find out myself why many people are learning this language. First time I noticed this while surfing through reddit then while seeing spring documentation. But did not feel like looking into it cause "its such a drag". But when I started seeing forum members discussing about this, I became curious. Should i invest time in learning new features of java :boink:or go with Kotlin. Sigh ...
 

Vyom

The Power of x480
Staff member
Admin
A query from someone who know nothing about Kotlin: How it is compared to Python?
Wasn't Python a de facto language used in Google services? Is the demand of Kotlin more than Python now?

PS: I want to learn Python and my target for this year is to deliver some projects in Python both personally and at my workplace.
 

Nerevarine

Incarnate
Earlier Java did adopt type safety and adhered to it very hard but last few versions have been really good especially bringing in lambda expressions, stream's map filter and reduce. No one back then would have imagined passing a function as a argument back then. Java will adopt all the best techniques required by devs as the time changes.

Anyway I better try to learn and find out myself why many people are learning this language. First time I noticed this while surfing through reddit then while seeing spring documentation. But did not feel like looking into it cause "its such a drag". But when I started seeing forum members discussing about this, I became curious. Should i invest time in learning new features of java :boink:or go with Kotlin. Sigh ...
No one can answer that but you. I only learn new language when I need to, or my job demands me to. My primary work language is objective c but soon, I'll have to learn swift
 

thetechfreak

Legend Never Ends
A query from someone who know nothing about Kotlin: How it is compared to Python?
Wasn't Python a de facto language used in Google services? Is the demand of Kotlin more than Python now?

Completely different languages to the point that learning python will give you little to no help on Kotlin. Something like C# is more along the lines of Kotlin.

Python I feel is probably the #1 most used language currently. Been that way since 4-5 years. Kotlin won't even be top 5(or top 10)

Sent via Tapatalk
 

Desmond

Destroy Erase Improve
Staff member
Admin
But why verbose is a problem.
Waste of time and energy :)

Verbosity is the biggest complaint everyone has of Java. In recent years though Java has been adding features to reduce boilerplate. Stream API, Lambdas, implicit types (using var keyword) and the recently released record classes (which are same as Kotlin data classes).

Should i invest time in learning new features of java :boink:or go with Kotlin. Sigh ...
Note that Kotlin is still not very common in the enterprise software development domain. That is why I always suggest learning Java and learn Kotlin as a side gig. But you can't go wrong with pure Kotlin if you are going into Android app development.

First time I noticed this while surfing through reddit then while seeing spring documentation.
Spring has been officially supporting Kotlin since Spring 5 I think. You have the choice of either creating a Java or Kotlin project at start.spring.io.

A query from someone who know nothing about Kotlin: How it is compared to Python?
Wasn't Python a de facto language used in Google services? Is the demand of Kotlin more than Python now?

PS: I want to learn Python and my target for this year is to deliver some projects in Python both personally and at my workplace.
Most of the differences are discussed in above posts. The goal of the Kotlin team was to create a language that has flexibility like Java but simplify it by removing boilerplate code and introducing features that make it more concise. Currently, Kotlin requires Java to run, so it's kind of like coding in Scala or Clojure (which also require Java), but since Java is the language with the largest number of libraries, you can use those libraries in your Kotlin, Scala or Clojure projects.

Python on the other hand would be a completely different ecosystem. Otherwise, the biggest difference between Kotlin and Python is the syntax. Kotlin has a Scala-like syntax.
 
Top Bottom