4 ms·
I'd be very interested to see if this works out well in practice. We had the same hope for Scala - the idea being that the developers who were interested in us
by hiram112 9y ago
I'd be very interested to see if this works out well in practice.
We had the same hope for Scala - the idea being that the developers who were interested in using it functionally could do so in the more complicated parts of our application, but the 'rest' of the developers, many who were honestly either not capable or just not interested in picking it up, would be able to still use traditional Java.
Unfortunately, Scala just had too many incompatibilities: things like Options instead of null or to call a Scala method in Java would require some confusing method call like
new Function0<String> because that is how Scala converts to bytecode.
And collections and immutable types never really worked back and forth very well.
The final straw was when we had Thrift interfaces that simply broke if a project moved from Scala 2.10 to 2.11 without recompiling all the dependencies.
But if Kotlin really is completely compatible with Java without too many show stoppers dragging down productivity, this could be helpful for a lot of larger enterprise shops which contain a small subset of engineers who want and can use the language to improve things (or simply don't want to work with old Java code and will jump ship if forced to do so), but still need to keep things simple enough so that the rest of the team can still be productive.
- nevi-me 9y agoI learnt Kotlin by taking an Android app which I had written in Java, and gradually converting it i to Kotlin, this was just after 1.0. I'm a solo developer, and I use K and J together on most codebases (about 10), and at this point I only ever create K files. Regarding interop, I think it's a valid claim that K is 100% J compatible. I think instead of arbitrarily mixing the two, maybe start with a single module, or with testing. I write a lot of JS, and have been planning on trying out Kotlin with JS, because at this point, taking a JS function and converting it to Kotlin results in code that's between 70-80% Kotlin (const to val, add return types, etc.) I'm personally convinced that Kotlin is a good language to learn if you know Java.
- eropple 9y agoKotlin is Java in a way that Scala isn't, so, yeah, it works a lot better. The edges can be a bit strange for the Java user but usually in positive ways--for example, passing a null parameter into a Kotlin method that does not accept a null parameter will cause an exception at the call site. `val` in Kotlin creates an (inaccessible, except via reflection) backing field and a bean-compatible getter. `var` the same, but with a setter. Stuff like that. It works incredibly well.
- orclev 9y agoBy way of analogy I'll compare languages to languages, specifically spoken and programming. Going from Java to Kotlin is like going from French to Spanish. Going from Java to Scala, is like going from French to Klingon. More concretely, Scala actually had very little in common with Java. Yes it ran on the JVM, but that was where the similarities stopped, its functional layer and type system were effectively incompatible with Java or the Java standard library. Actually Scala was so badly made, its functional pieces weren't even really compatible with its own OO pieces, if you tried to mix and match the two it caused all kinds of problems. Kotlin in contrast is almost entirely compatible with Java. There are a couple rough spots, mostly around when frameworks depend very heavily on reflection and bytecode manipulation (particularly around annotations), but those can be worked around from both sides without too much trouble, and the rest of the time it's pretty much completely transparent.