• Post Reply Bookmark Topic Watch Topic
  • New Topic

Kotlin, are you using it?  RSS feed

 
Pete Letkeman
Ranch Foreman
Posts: 839
25
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Kotlin or learning it? It does have some fairly neat features like "==" being the Java equivalent of the "equals" method, data classes, final classes by default and more.
From the documentation that I've read, the designers have tried to put into practice many of the concepts from the "Effective Java" books to make development better/easier.

I've used Kotlin for Android development on a project found in the "Android Programming: The Big Nerd Ranch Guide (3rd Edition)" book.
Hopefully within the next day or two I can use Kotlin as I try to learn how to use Spring Boot to create some web services.

If you are learning Kotlin then what are you plans for using it?
If you are using Kotlin then what are you using it for?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16048
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used it to write a small tool at work to analyze files that I'm working with. Not for Android programming, just for use on my development machine.

Kotlin has a lot of interesting language features. One of the features that I find quite useful is extension methods. With extension methods, you can, as it were, add extra methods to existing classes. For example, in Java we often use "utils" classes for utility methods - a number of libraries, including Apache Commons Lang and also Spring, have a StringUtils class with extra utility methods to work with strings. With Kotlin extension methods, you can write these as extension methods so that you can call them on String objects as if they are defined in class String itself. This makes these methods integrate much better with existing code, because you can use the same syntax to call them as any other method that is in class String itself.

But there's of course much more. If you are using Kotlin with Spring, then check out the newly released Spring Framework 5, which has official support for Kotlin.

Looking at the language, I can see that Kotlin has borrowed features from a range of different other programming languages - syntax that looks partly like Scala, extension methods from C#, data classes that look a lot like Scala's case classes, pattern matching, things that look like they come from JavaScript, etc.

It's worth it to take a look at if you are a Java developer, even if it's just to get a fresh view on programming languages and learn some new features and constructs that don't exist in Java, so that you get an idea of what's possible beyond Java.
 
Pete Letkeman
Ranch Foreman
Posts: 839
25
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:If you are using Kotlin with Spring, then check out the newly released Spring Framework 5, which has official support for Kotlin.

Thank you Jesper, I was not aware of that.
I have much to learn regarding both Kotlin and Spring.
 
Giovanni Montano
Ranch Hand
Posts: 426
7
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kotlin allows a gradual approach, is java under the hood. I am using it. But one thing is to use it, another one using idiomatic features..
 
Pete Letkeman
Ranch Foreman
Posts: 839
25
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giovanni Montano wrote:kotlin allows a gradual approach

I know, you can have both Java and Kotlin files in the same project and you can call you Java from Kotlin and you Kotlin from Java.
Giovanni Montano wrote:But one thing is to use it, another one using idiomatic features.

On of the features that I really like is Kotlin Data Classes. With only one or two lines you can setup a POKO which acts as a POJO that has all of your getters, setters, toString, equals, hashCode.
You can even provide default values to the data class which will show up as overloaded constructors if you use the @JvmOverloads annotation on the data class as noted here https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/
However you are not limited to what is created, you can create your own getters, setters etc if you need to have that fine of control.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!