5 ms·
Does anyone know how Kotlin bridges the differences between the JVM and JS? For example, the demo video that prints an ArrayList of Integers raises more questi
by dgreensp 13y ago
Does anyone know how Kotlin bridges the differences between the JVM and JS?
For example, the demo video that prints an ArrayList of Integers raises more questions than it answers, given that JavaScript doesn't have Integers or ArrayLists and has different built-in stringification (which is always idiosyncratic from language to language). Can I write portable code that uses arrays?
Some quick poking around indicates that Kotlin is pretty JVM-centric for someone who works in the web world. (I used to write a lot of Java and Scala and even wrote a mini JVM once, but these days JavaScript is my go-to platform.) There's good old byte/short/int/long and there's boxing of primitives. They don't even bother to mention that arrays have immutable size (like Java and unlike JS), presumably because they assume it's obvious.
Inexplicably, the English words "and" and "or" are used for bitwise operations while && and || are unchanged. Hate to criticize but it all just seems rather strange.
- hhariri 13y agoThe demo (I'm the author of the video) is showing JVM, not JavaScript target. For JavaScript, check out: http://blog.jetbrains.com/kotlin/2013/10/writing-kotlin-in-the-browser/ http://blog.jetbrains.com/kotlin/2013/10/writing-kotlin-in-t...
- camus2 13y agoFirst thanks for your excellent products. JetBrains rocks and i bought 2 ides from your business. Now my question : Why didnt you chose an existing language like Dart for instance?which would have been closer to java and still compile down to javascript. I think dart on the jvm would be a great idea.
- dgreensp 13y agoGreat, I have an expert here! So how does Kotlin bridge the differences between Java and JS? Can I write portable code that manipulates arrays? Does Kotlin use JavaScript's number semantics when it targets JavaScript, or does it emulate Java's? I'm starting to suspect Kotlin is a unified syntax but doesn't actually have any unified semantics, or considers all heap objects to be "foreign" and owned by either Java or JS. I was expecting to hear one of a few reasonable approaches to making code portable across Java and JS. For example, Kotlin has its own concept of an array which happens be backed by an ArrayList in Java land. Or, classes like ArrayList are emulated in JS by a runtime library.