So, to compare them, I ported a simple FSharp shmup game to both scala and kotlin. I found that on Android, the Kotlin version starts stuttering while the Scala version continues fast and steady for as long as I fire bullets. So, for the first round, Scala is the clear winner. Kotlin just does not have the raw performance.
Next, I upgraded each to include using Overlap2D. This is more realistic, not to mention it's the reason I'm looking into libGDX. Here, I'm using Box2D physics to move objects, and the results are not conclusive, there is not a better performing version. So let's look at the language.
Kotlin touts interop with java. But I didn't find scala to be any slouch in that area. I think their perspective must be calling Kotlin vs Scala from Java, neither of which I plan on doing.
Kotlin compiles faster? Only if you don't use SBT (scala build tool).
Kotlin's syntax is almost identical to Scala's.
It uses the keyword 'fun' rather than 'def' to define methods.
Kotlin uses 'data class' where scala calls it 'case class'
Kotlin changes 'match' to 'when' and removes some functionality.
Kotlin has no 'new' operator. New objects and function calls look the same.
Kotlin exposes synthetic members - getWidth() and setWidth() are replace with a field reference to width.
Kotlin's weak pattern matching has to be replaced with complex if statements and manual destructuring.
Those may seems like change just to be different, but they actually have a negative impact on readability. New objects dont' stand out. Properties don't match the documetation. Pattern matching is spaghetti.
It seems to me that the main benefit of Kotlin is the one stated by IntelliJ - it helps them sell their IDE. But it doen't help me write my code. I've decided to go with scala.
Thumbs up
ReplyDelete