Platform independent code and import java.*


#1

Hi!

I wonder what the policy is for importing classes from java.* et al in projects intended not only for the JVM?

Take a look at this commit, which I believe is not correct: https://github.com/JetBrains/kotlin/commit/be7989af36197879774e55335216ca0fa4b6df5d

As you can see in the comment section below the commits, despite there being an import java.util.StringBuilder the resulting Javscript code
works just fine since there is an implementation of StringBuilder in the js-stdlib.

Regards, Tommy


#2

Hi,

Yes, there is a naming problem there, and we should have a “kotlin” string builder available in the appropriate package, but this is not done yet


#3

So it would be ok to start suggesting a std lib for kotlin and perhaps implement those classes in pure Kotlin?

This makes me glad, I was starting to feel that Kotlin had been tainted by JVM-ness.

For me, Kotlin feels like something like a cross of C# and Ruby, and the std lib should reflect that and not blindly copy atrocious API’s like Java’s StringBuilder class.


#4

While suggesting additions to std lib, keep in mind that interoperabilty with Java is still very important.