I know there are several Java to Scala source code converters out there. But many of them are out of maintenance or low quality. What converter could you recommend in 2023?
InteliJ with its convert-on-paste (not perfect, possible problems when something is missing on class path), or ChatGPT
It’s worth noting that the literal conversion is, in a sense, the easy part. The bigger problem is that typical modern Scala idiom is pretty different from Java norms. For example, most Scala codebases pretty firmly reject null
, which is still very common in most Java code. Scala code is mostly focused on different libraries nowadays. And that’s without getting into really interesting problems like FP.
So part of this comes down to what your use case is. What’s the Java codebase that you’re looking to convert, and what do you want to do with it?
I used to do a lot of straight Java-to-Scala conversion as an intermediate step: convert to Scala while changing as little as possible, get the tests passing again, commit, then think about making it more idiomatic in Scala.
I have some older Java code that I want to run on Scala.js. Non-idiomatic Scala would be ok.