The first surprise is that Scala is not a single, stable target. The language version, the build tool, and the JDK all affect whether a tutorial’s code compiles. These are the lessons I wish someone had put in front of me before the first install, not after the first confusing error.
Scala 3 and Scala 2.13 are different enough to notice
Before you copy a tutorial, check whether it is Scala 3 or Scala 2.13. They share a lot of syntax, but not all of it. A 3.3 LTS line is a sensible default for new work; 2.13 still appears in older libraries and examples. Put scalaVersion := "3.3.3" in build.sbt and leave it there until you deliberately change it. If a tutorial uses implicit, it may be Scala 2; Scala 3 often uses given. Code that fails to compile may be from the other version, not from you. Check the first version line in the tutorial before you debug your own typing.
The JVM and your JDK matter from day one
Scala runs on the JVM, so the JDK is part of your setup, not an optional extra. Install JDK 17 or 21 LTS before sbt. Run java -version and note what it says. If UnsupportedClassVersionError appears, your build is using a different or older JDK than you think. Check JAVA_HOME and sbt’s Java setting. For a small project, sbt’s default heap of about 1 GB is often enough; if compilation crawls or you see OutOfMemoryError, try -Xmx2G. A cold sbt start can take 10–30 seconds, which is normal.
sbt is a language you learn alongside Scala
sbt is not just a button that runs code. The first sbt run can download 100–500 MB of dependencies in 2–10 minutes. That is not a crash. Learn compile, run, test, and console before adding plugins. A build with one dependency is easier to diagnose than one with five. If sbt hangs, check network or proxy settings, wait for downloads, then try sbt clean and sbt reload. Do not edit cache folders by hand; it rarely fixes the real problem.
Type inference is not mind reading
Type inference means val n = 1 is an Int, but it does not mean every type is obvious. val items = List() gives you a list with an unhelpful inferred type; write List[String]() instead. For public methods, write return types: def total(xs: List[Int]): Int = xs.sum. If the compiler reports Nothing or Any, add annotations. Inference is a convenience, not documentation. A written type is often the fastest explanation you can give the next reader.
Immutability changes your default style
Scala nudges you toward immutable values. Use val by default and keep var for deliberate local mutation; 80–90% val is a reasonable target for beginner code. List(1, 2, 3).map(_ * 2) is clearer than an index loop once you are used to it. Use Option instead of null. A for comprehension is not a Java-style loop; it maps and flatMaps. If you translate Java line by line, Scala feels noisy and slow. Start by rewriting one loop as a collection operation.
The compiler is strict, and that is the point
One wrong type can produce 10–50 lines of errors, many cascading from the first. Fix the first error, recompile, then look again. Do not silence real problems with asInstanceOf, null, or implicit conversions. Reduce the problem to a 10–30 line snippet or the REPL. Strictness feels hostile for a day and useful for years. The compiler is doing the review that a friendly colleague would do later, only earlier.
When it breaks: symptoms, likely causes, and the fix
Cannot resolve symbolornot found: value: likely a typo, missing import, unloaded dependency, or wrong Scala version. Fix the import or runsbt reload, then compile a minimal file.Type mismatch: an annotation, collection type, or missinggiven/implicit is wrong. Write the expected type explicitly and remove conversions.Unsupported class file major version: JDK mismatch. Point sbt at JDK 17 or 21 and re-checkjava -version.- sbt appears frozen: first-run downloads, proxy trouble, or too many plugins. Wait 10 minutes, check the network, then remove plugins and reload.
No tests found: missing test framework dependency or wrong test location/naming. Add the framework and runsbt testagain.
Learn the standard library before the ecosystem
Collections, Option, Either, and basic pattern matching cover most beginner scripts. Scala 3 libraries use a _3 suffix; Scala 2.13 uses _2.13, and mixing them fails at dependency resolution. Add one library at a time and check its supported Scala version. Advanced effect libraries add concepts before you have mastered the basics. You do not need them to write a 50-line script that reads a file and transforms a list.
FAQ
Do I need to learn Java first?
Not the language, but the JVM basics help: installing a JDK, classpaths, and memory settings. A 30–60 minute primer is enough to start.
Can I run Scala without sbt?
Yes for small experiments: the REPL and single-file runners are fine for 10–50 lines. Once you need dependencies or tests, use sbt rather than fighting the setup.
How long before Scala feels useful?
Many beginners can write 20–50 line scripts after a few focused sessions. If setup takes more than 2–4 hours and nothing runs, fix the JDK and sbt path before studying more syntax.