Two things:
- 99% of Java code can be expressed in Scala
- You can write projects that support Java + Scala mixed compilation. Your Scala code can call your Java code, and your Java code can call your Scala code. (If you want to do the latter, I suggest defining an interface in Java and then just implementing it in Scala. Otherwise, calling Scala code with Java may be a little ugly.)
So the answer is: whatever parts you want. Your Scala code should not be purely functional. Your Scala code may call Java libraries. So almost any part that you could write in Java, you could also write in Scala.
Now a few more practical considerations. When using Scala for the first time, some people choose relatively isolated, non-mission parts of their program to write to Scala. Unit tests are a good candidate if you like this approach.
If you are familiar with Java and have learned Haskell in the past, I suggest considering Scala as "the best Java." Essentially, Scala compiles into JVM bytecode, which is very, very similar to what Java produces. The only difference is that Scala is more “productive”: it generates more bytecode per line of code than Java. Scala has a lot in common with Haskell (first-class functions, for -an understanding are similar to Haskell do-notation, a limited type of output), but it is also very different (it is not lazy by default, it is not clean). So you can use some of your ideas from Haskell to inspire your Scala style, but “under the hood” is all Java bytecode.
Jorge ortiz
source share