Scala Fundamentals
Scala is a statically typed language that combines object-oriented and functional programming on the JVM, with JavaScript and native targets. Its immutable values, pattern matching, and concise syntax help you build expressive, reliable application code.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Scala Fundamentals
Scala is a statically typed language where object-oriented types and functional values share the same program. That sounds like a committee meeting, but the useful result is concrete: a case class can model data while functions reshape it without sending the program to a different language or a different mental drawer.
Start with expressions. A value has a type, even when Scala infers it for you. Use val when the reference should not be reassigned, and keep var visible when it must change. The surprise is that type inference does not make types disappear. It merely saves you from writing the obvious parts while the compiler continues to care intensely.
Then meet the case class, the preferred compact container for immutable data. It gives structural equality, a copy method, and pattern-matching support. Pair it with functions as values, and collection work becomes a sequence of transformations: map changes every element, filter keeps selected elements, and flatMap handles one extra layer of nesting. The language is being tidy on purpose, which is rarer than it should be.
A match expression is not merely a switch wearing a more ambitious hat. It can decompose a case class, a tuple, or a collection, then bind the parts that matched. A for comprehension gives the same collection machinery a readable shape when generators and guards would otherwise pile up. The yield is the receipt: it builds the result collection.
Scala 3 adds contextual abstractions. A given is a value the compiler can supply, and a using clause marks a parameter that can receive it. Extension methods add behavior to an existing type without changing that type. These are useful after ordinary values, functions, and control flow feel familiar; starting here is how a small language becomes an unexplained magic trick.
The JVM is Scala's default target. The same source can also reach JavaScript through Scala.js or native executables through Scala Native, but pick one target first because tooling and libraries follow it. Read the Intro when the type hierarchy or contextual abstractions need a fuller explanation. Use Slides for the relationships, Cheatsheet for compact syntax and decisions, Practice for a runnable program, and Reference when you are ready for the official material.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://docs.scala-lang.org/tour/tour-of-scala.html
Supports
- Scala combines object-oriented and functional programming in one statically typed language
- The Tour of Scala is the official starting sequence for language concepts
- https://docs.scala-lang.org/tour/basics.html
Supports
- val declares an immutable reference and var permits reassignment
- Scala supports type inference and expression-oriented definitions
- https://docs.scala-lang.org/tour/unified-types.html
Supports
- Any is the supertype of all types, with AnyVal for value types and AnyRef for reference types
- Nothing sits at the bottom of the type hierarchy
- https://docs.scala-lang.org/tour/higher-order-functions.html
Supports
- Functions are values in Scala
- Higher-order functions take functions as parameters or return functions as results
- map applies a function to each element and returns a new collection
- https://docs.scala-lang.org/tour/pattern-matching.html
Supports
- Match expressions decompose values by trying each case in order
- Type patterns check and bind in one step and a wildcard matches anything
- https://docs.scala-lang.org/tour/for-comprehensions.html
Supports
- For comprehensions chain generators, guards, and yield into readable collection operations
- A for comprehension with yield produces a collection of yielded values
- https://docs.scala-lang.org/scala3/reference/contextual/givens.html
Supports
- Given instances provide values the compiler can supply automatically
- Using clauses mark parameters the compiler may fill from the context
- https://docs.scala-lang.org/scala3/reference/contextual/extension-methods.html
Supports
- Extension methods add methods to an existing type without modifying its definition
- https://en.wikipedia.org/wiki/Scala_(programming_language)
Supports
- Scala is designed by Martin Odersky at EPFL and released under a BSD license
- Scala source code can compile to JVM bytecode, transpile to JavaScript, or compile to native executables
- Scala supports immutable values, pattern matching, and a unified object-functional design
- Scala 2.8.0 shipped on 14 July 2010 and Scala 2.12.0 required Java 8 on 3 November 2016
- Scala 3.0.0 released on 13 May 2021 and Scala 3.3.0 was the first LTS release on 30 May 2023
- Scala 1.0 reached the public in early 2004 after an internal release in late 2003, and Scala 2.0 followed in March 2006 with the compiler rewritten in Scala
- A .NET target shipped in 2004 and was officially dropped in 2012
- Scala 2.10 added futures and promises, value classes, implicit classes, and string interpolation in January 2013
- Scala.js was declared no longer experimental in 2015 and Scala Native had its first release on 14 March 2017
- Typesafe Inc., later renamed Lightbend, was launched on 12 May 2011 to provide commercial support for Scala
- Apache Spark is a well-known open-source cluster computing solution written in Scala
- Scala's actor model support is now available as the source-available Akka platform licensed by Lightbend
- https://github.com/lauris/awesome-scala
Supports
- Awesome Scala is a curated Scala ecosystem list; no entry was included without a verified project destination
- https://www.scala-lang.org/
Supports
- The reference Scala language and compiler distribution is the subject of this course
- https://www.scala-sbt.org/
Supports
- sbt is the classic Scala build tool used by most multi-file Scala projects
- https://scala-cli.virtuslab.org/
Supports
- Scala CLI is a single-file scripting and project tool that lowers the entry cost before a full sbt setup
- https://www.scala-js.org/
Supports
- Scala.js is the Scala compiler target that compiles to JavaScript for browser and Node.js
- https://scala-native.readthedocs.io/
Supports
- Scala Native is the LLVM target that compiles Scala to a native executable with a lightweight runtime
- https://scalameta.org/metals/
Supports
- Metals is the Scala language server that powers Scala editing in VS Code and other LSP-based editors
- https://www.jetbrains.com/idea/
Supports
- IntelliJ IDEA offers first-class Scala support, free in the Community edition and paid in Ultimate
- https://scalameta.org/scalafmt/
Supports
- Scalafmt is the standard Scala code formatter that enforces one consistent style across a project
- https://github.com/scalacenter/scalafix
Supports
- Scalafix is a refactoring and linting tool that applies migration and cleanup rules across a Scala codebase
- https://scastie.scala-lang.org/
Supports
- Scastie is the official browser playground for running Scala snippets including Scala 3
- https://index.scala-lang.org/
Supports
- The Scala Package Index is the search index for published Scala libraries across JVM, Scala.js, and Scala Native targets
- https://akka.io/
Supports
- Akka is the actor and streams toolkit that grew out of Scala's original actor support, now source-available with paid tiers
- https://spark.apache.org/
Supports
- Apache Spark is the open-source cluster computing engine written in Scala
- https://scala-cli.virtuslab.org/docs/reference/scala-command/commands/
Supports
- Scala CLI run compiles and runs Scala code and requires a main method on the classpath
- Scala CLI fmt formats Scala source files using scalafmt
- Scala CLI accepts Scala source files as run inputs
- https://www.scala-lang.org/blog/2024/01/23/migration-to-scala-3.html
Supports
- A production team reported that its Scala 2 to Scala 3 migration depended on its technology stack, tooling, macro use, internal libraries, and third-party library support
- The team retained Scala 2 services while writing new services in Scala 3, creating onboarding costs when developers moved between versions
- https://theguardian.engineering/blog/info-developer-blog-2016-dec-22-parental-advisory-implicit-content
Supports
- Implicit parameters reduce boilerplate but can obscure a function behavior
- A missing intended implicit value can be masked by another matching imported value, allowing code to compile with unintended behavior
- https://www.scala-lang.org/blog/2018/06/04/scalac-profiling.html
Supports
- Heavy typeclass derivation, implicits, and macros can increase Scala compilation time
- Compiler profiling can expose expensive implicit searches and repeated materialization during automatic typeclass derivation
