I'm coming from a PHP/Python/Javascript background, and recently became very interested in Scala - specifically Akka coming from the web standpoint.
I'm having an extremely hard time though with general workflow, issues compared to interpreted languages such as the ones I described.
In general I tend to code, test results, code and repeat. This comes to a standstill when even changing a single line in a 20 line class takes up to 30secs to compile and run. Is this really normal? Do I need to just build, build, build then go back 30 minutes or an hour later and compile/test?
(I'm using IDEA with SBT) Do I need to specifically learn how to use Maven other than linking to the repos?
Thoughts? Advice?
But like any other programming language, learning Scala can be done quickly. From my experience teaching 41000+ people online at Rock the JVM, one common frustration that people have over (learning) Scala is that Scala has too many features and it's hard for people to connect them all.
Scala is worth learning in 2022. The demand for Scala developers is high, and the pay is good. LinkedIn currently lists over 24,000 Scala jobs. According to ZipRecruiter, the average Scala developer salary in the United States is $139,292 a year .
7- The learning curve of the Scala vs java programming language is high as compared to that of Java. The coding in Scala can be extremely challenging to predict due to less coding. Also, the syntax in Scala is more complicated than Java.
I think you're on the right track with Idea and SBT. Have you tried
~compile
That will detect changes to your source automatically. For web applications, you can do a
jetty-run
followed by
~prepare-webapp
To continuously compile and redeploy your app to jetty. Makes Scala dev feel a lot like Python web development.
Usually I've found SBT to be very fast when compiling, especially the size file you're talking about. By the time I save my change and go to my SBT prompt, it's done.
Another handy SBT aspect is the REPL which will load your project and its dependencies:
console
You can reload any compiled changes with
:replay
in the scala REPL.
EDIT: Guess I should mention that you can play around with a simple class with a main method. If you create a file called src/main/scala/Foo.scala that looks like this:
object Foo {
def main(args: Array[String]) {
println("Hello World")
}
}
And a file project/build/Build.scala like this:
import sbt._
class Build(info: ProjectInfo) extends DefaultProject(info) {
override def mainClass = Some("Foo")
}
Then at the sbt prompt, you can do
~run
To continuously compile and run the Foo.main method. You may need to do a 'reload' in sbt first. It seemed to take 2-3 seconds from saving change to seeing output. Then you just edit away, save and see changes. It's a pretty good workflow.
Also, don't forget the REPL - definitely a critical tool for learning Scala. You can learn a ton just playing with it interactively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With