• Post Reply Bookmark Topic Watch Topic
  • New Topic

Kotlin in Action: Translating  RSS feed

 
Saloon Keeper
Posts: 1695
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using an IDE like InteilliJ you can get Java code translated into Kotlin code with plugins and possibly natively using tools.
When starting out with Kotlin do you recommend using such translators or is it better to not use them?
 
Ranch Hand
Posts: 90
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am interested in this question as well.  Automatic language translators/converters that I've used in the past have generated some weird code that took some effort to make workable.

Having just read about the concept of platform types (see https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types ), does the automatic translator built into IntelliJ tend to rely on type inference rather than explicit type denoting?

One further question:  Is the translator only available through IntelliJ or is it a standalone tool?
 
author
Ranch Hand
Posts: 149
5
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, we do recommend to use the Java to Kotlin translation tool. We've put a fair amount of effort into ensuring that its output is more or less idiomatic Kotlin code.

As for type declarations, I frankly don't remember what its policy is, and it doesn't really matter much. Platform types exist only in Java code; once you convert a Java class to Kotlin, all the types in it become real Kotlin types with explicit nullability, rather than platform types.

The full functionality of the translator is only available inside IntelliJ IDEA at this time.
 
Pete Letkeman
Saloon Keeper
Posts: 1695
68
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply Dmitry and I'm glad that you were able to clear this matter up for me.
 
I child proofed my house but they still get in. Distract them with this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!