Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automated Java to Scala source code conversion? [closed]

(Yes I know I can call Java code from Scala; but that is pointless; I want to DELETE the Java code, not keep it around and have to look at it and maintain it forever!)

Are there any utilities out there to convert Java source to Scala source?

I believe theoretically it should be possible to accomplish with minimal lossage.

I have found this but it seems inactive, probably buggy/incomplete... http://sourceforge.net/projects/java2scala/

Any alternatives?

like image 467
Alex R Avatar asked Mar 20 '10 17:03

Alex R


People also ask

Can I write Java code in Scala file?

Yes, it's completely possible and I've actually done this in the past. You need the Scala compiler that will produce a Java .


1 Answers

IntelliJ kinda, sorta, does this. You need to open a project with your Java sources. You can then copy/paste expressions, methods, or entire classes in to a .scala file. This converts to equivalent Scala code.

The fidelity of conversion isn't perfect, and, for this reason, it doesn't support a bulk conversion yet.

I recommend using the latest version of IntelliJ and the Scala Plugin. The Community Edition is free.

Aside from this, Paul Phillips once started the Scalify project to translate code from Java to Scala (or, potentially, your favourite language), and even improve it in the process! He explains the concept in this video. However this effort was stalled, presumably because he turned his attention to directly contributing to the Scala compiler and standard library.

like image 93
retronym Avatar answered Sep 19 '22 09:09

retronym