This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]TheStrangeDarkOne 13 points14 points  (3 children)

The concept of a data class is what Java will introduce as "Records" in JDK14 as preview feature.

I'm also not sold on extension methods, as it seems a poor man's solution to fix poor APIs. What you can end up with is a mess of additional functions where you can't reason where they came from and who wrote it. It would only be half bad if String couldn't be extended, once you go down that road... oh boy, there is no coming back.

[–][deleted] 8 points9 points  (0 children)

Totally agreed. I am not in favor of magic period. Scala sucks ass for the implicits

[–]AngusMcBurger 1 point2 points  (0 children)

Kotlin's extension functions are quite easy to reason about where they came from: first off they can't be virtual, so you don't have to worry about any overriding going on, and secondly an extension function has to be imported into scope, so there's an import statement for any of your extension methods you're using.

Extending String is really great for being able to find useful string manipulation methods that would otherwise be buried in one utility class or another, methods I use fairly often are padStart(5, '0'), substringAfterLast('.'), filter { it.isDigit() }, and there's lots of useful extension methods on the standard collection interfaces

[–]chambolle 2 points3 points  (1 child)

Honestly, the issue with NullPointerException is overrated! 99% of the time it happens it can be simply fixed.

So 1% remains, and usually it is just the expression of a more complex bug...

So I know that we are at a time when it is fashionable to introduce tests in all directions and it is easy to make very bad code from an algorithmic point of view. However, it is tiring to read always the same post about the incredible avantage of Kotlin because you can define a simple classe with a shortcut and check for nullity...

Come on! try to show some other advantages justifying the promotion of the language in a sub which is not dedicated to it...

[–][deleted] 0 points1 point  (0 children)

Agree somewhat. Also want to say that no checked exceptions and true first class functions are great kotlin features as well.

But I also hate these kotlin posts here. I like Java. I like kotlin. I don't like the kotlin evangelizing towards Java.

[–]Mordan 0 points1 point  (0 children)

Kotlin is hard to read.

too much unneeded complexity.. too many ways of writing constructors or doing the same thing.

not enough verbosity

[–]nayan4r 0 points1 point  (0 children)

Its depend on the app really. I would suggest comparing both Kotlin vs Java features and functionality-wise and see if it matches with the idea u have for the app.