I found some work on github for more than half of the code in an incomprehensible Scala, the question of whether this Rock can be turned into Java for my usual form. And then you can convert Java to Scala - http://javatoscala.com/

And even if the Android project is compiled, and then try to pick open the form will be more familiar to Java or the same Scala.

Well, if you use scala, how will it appear in the future on the project, will the weight be less or the speed more?

  • 2
    “there will be less weight or more speed ”: Scala, like all high-level languages, does not have the advantage of speed / compilation size (you need to turn to lower-level languages ​​for this). The advantage here is the expressive power of the language and the ease of programming of complex structures. - VladD

4 answers 4

Scala compiles into Java code, so when answering the last question, they will work the same way (well, of course there are exceptions, but this is not about that now).

You can decompile the code and it will be in Java.

And so, there is an excellent scaloid project for developing Android applications on Scala. IMHO, sort it out with Scala, it is not so complicated, and you will upgrade and the application will work. And then it is similar to decompiling a class and copying it to the source on a crutch.

  • 7
    Scala is not compiled into Java code, but into JVM bytecode. - zzashpaupat
  • Sorry, didn’t write exactly :) - MrRontgen
  1. To convert Scala to Java is a pretty crazy idea. in Java there are not so many Scala constructions such as case class , match and many others; this will inflate existing code 2-3 times, if not more. Moreover, it will become absolutely unreadable, it is terrible to imagine what the covariant generic will unfold in, for example. Well, get ready for what you have to do in the future, modifying this code, working with Scala collections (in Java, this will be VERY not nice) and dragging along Scala libraries (they are quite massive).
  2. Scala in the project, in comparison with Java, will reduce the number of lines of code several times (stupid conversion using javatoscala already significantly reduces the code), and, IMHO, it is much nicer to write to Scala, there are functional programming and other Scala buns (very I recommend to read some little article on this topic). But there are also disadvantages, you probably won’t win in speed, and maybe you lose, programs in FP style will work a little longer (you can rewrite critical sections of code in OOP style and performance will be just like in Java), and the output apk size is likely there will be more, just due to the massive standard library of the language, but ProGuard should come to the rescue, but practice shows that apk will still be slightly more than if the application was written in Java.

    Theoretically, you can get java code. Yes, for this you have to take jar-files, feed any decompiler that supports at least Java 6. And you will get Java code at the output. Does this code suit you? The fact is that the code that you receive during the broadcast can be called understandable with great difficulty. Detailed instructions on how to do this can be found here . You can learn more about the decompilation process here.

      Scala provides a powerful tool for writing code, but neither the weight (probably because the scala code is still converted to byte code), nor the speed will be better: moreover, in some cases, the Scala speed is an order of magnitude (10 times) worse than Java, for example, when sorting lists ( https://stackoverflow.com/questions/23588615/scala-collection-sorted-sortwith-and-sortby-performance ). Even when using conventional arrays there will be a loss in speed due to wrappers. As already written before, using Scala in a Java project is not very convenient (as opposed to using Java in Scala). When compiling for Android, additional problems may arise, however, they can be solved.