Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If I were to use Kotlin server-side on JVM and didn't care about portability to other Kotlin platforms, could I not just use JVM green threads?


Depends on how Kotlin decides to expose them at the language level.

For example, you need special syntax to use SAM types and Kotlin cannot use all use cases from interfaces with default methods.

That is the thing with the Java Virtual Machine, the bytecodes and runtime are designed for Java, all guest languages have to pretend to be Java.

Just disassemble the amount of boilerplate generated by the Kolin compiler.


This is not always the case. One example is checked exceptions which are purely Java thing and do not exist in JVM (outside of metadata). That always amused me, it's like a switch to remove checked exceptions from language, you can turn it any time without backward compatibility issues.

Another example is inner classes. Inner class can access private fields of outer class in Java. But in JVM there's no inner class concept, so compiler generates synthetic accessors for outer class private fields and inner class uses those methods to access private fields. That was fixed recently, though, but it was the case for many decades.

Also I remember some funny bytecode with try-finally, I think it's implemented with gotos.

Of course Kotlin generates a lot more boilerplate, that's for sure.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: