How good are Java and Scala?

I have been studying Scala for the last couple of months, and now I feel that I can start using real work, besides solving some simple problems. My question here is how well do these two work together?

I have several Java projects that I am currently working on. How easy is it to start using Scala in them? Are there any issues you need to know about? Are there any tutorials or any materials that can be done? If I want to use Scala in web projects, how to do it (except for the elevator)? All ideas and suggestions are welcome.

+7
java scala
source share
2 answers

In general, using Java libraries from Scala code is simpler than using Scala materials in Java. This is because Scala has advanced features that are technically available in java but implemented by the Scala compiler, creating all kinds of additional classes with malformed names.

If your "main" program is now written in java, but you want to implement some functions or modules in scala, you should probably define your modules in terms of Java interfaces. Then use the Scala code for these interfaces.

I hope you will soon find that you like Scala so much that you switch to Scala, which is the main language that calls your old Java code.

+14
source share

In general, I do not receive prerequisites for projects in a mixed language, except in extremely specialized cases. Scala is capable (like a language) of expressing everything Java can be, and much more. So why "inject Scala into a Java project"? Why just write a pure-Scala project?

When I say β€œclean” Scala, I take it as read so that you can reference the JAR file written in Java. But for the vast majority of cases, I don’t see the need to write Java code in a Scala project.

+1
source share

All Articles