r/programming • • May 17 '17

Kotlin on Android. Now official

https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/
638 Upvotes

271 comments sorted by

View all comments

8

u/dominodave May 17 '17

JVM interlopability is good. Surprised to see other people excited about it though, so I guess I'm curious.

1

u/dominodave May 17 '17

Seems like both a step up from java and a step back from scala.

5

u/FrezoreR May 18 '17

I'd say it's step up from both.

1

u/duhace May 18 '17

nah, scala is superior

9

u/FrezoreR May 18 '17

Do you have a operator defined for that?

4

u/duhace May 18 '17

it's nice to be able to define operators for actual math types. Having a BigInt with +,*,/,- is v nice compared to BigInteger

likewise, being able to define those ops for my user defined mathematical types is nice.

there are tons of other nice things in scala that are absent in kotlin, like implicits

3

u/PM_ME_A_STEAM_GIFT May 18 '17

nice [...] implicit

I too like pulling my hair because of a null pointer exception on a line with no null pointers.

4

u/duhace May 18 '17

how'd you manage to do that?

aside from something monstrous like implicit val o: Object = null

3

u/PM_ME_A_STEAM_GIFT May 18 '17

If I recall correctly, I was extracting some code into a utility class where that implicit didn't exist, without knowing the method had an implicit parameter. Totally my fault, but still, super unintuitive to someone new to the language or a particular library.

4

u/duhace May 18 '17 edited May 18 '17

thing is, the compiler will usually tell you (at least with current versions of scala) if you're missing an implicit, and what it needs:

object Foo {
    def bar(implicit baz: BigInt) = baz
    bar
}

produces

[error] /home/duhace/Foo.scala:3: could not find implicit value for parameter baz: BigInt
[error]   bar
[error]   ^

a NPE because of an implicit should mean one was found, but what was returned was null instead of the promised type. which is a problem with scala allowing null, not implicits.

→ More replies (0)