Learning Scala at Light Speed: Key Concepts Unpacked


Scala at Light Speed is a free, compact course by Rock the JVM , designed to teach you Scala’s essential features in just about 2 hours, roughly the length of a movie.
Course: Scala at light speed.
The official GitHub repo reinforces this learning with code snapshots at every stage.
Repo: GitHub
Learnings
1. Everything Is a Value
In Scala, every expression yields a value, there are no statements without results. Even blocks and control structures like if
, while
and braces evaluate to values.
2. Left-Hand Side Assignment
You can assign values to named variables (val
or var
), but Scala encourages immutability using val
(constant values).
3. Braces (Blocks) Evaluate
Braced code blocks are expressions whose value is the last line inside them. They also introduce scope for local definitions.
4. Prefer Recursion Over Loops
Instead of traditional loops, Scala emphasizes functional recursion for iteration—keeping code immutable and expressive.
5(&6). println
Returns Unit
; Side Effects
Functions like println
return the Unit
type (Scala’s equivalent of void
), representing side effects rather than computed values.
7. Classes & Constructors
Yes, class parameters defined in parentheses serve as constructors. This pattern also exists in Python via __init__
methods, though syntactically different.
8. “Most Derived Method”
This likely refers to method overriding semantics: the most specific (child class/trait) method is used in polymorphic calls.
9. Access Modifiers
In Scala:
Default is
public
(no need to write it).private
limits access to inside the containing class.protected
permits access within subclasses.
This parallels Java, but Scala's default differs—>public is implicit.
10. Interface = Trait
Scala’s trait
serves a similar purpose to Java's interface, and can also hold concrete implementations, making them more powerful.
11. Single Class, Multiple Traits
Scala allows multiple inheritance via traits while requiring only one base class, combining flexibility with clarity.
12. Overriding Methods from Superclasses
Superclass methods can be overridden in subclasses using the override
keyword in Scala.
13. Use with
for Traits
When mixing in traits, Scala syntax uses extends
(for classes) followed by with
for additional traits:
"class MyClass extends Base with Trait1 with Trait2
"
14. Infix Notation
Single-argument methods can be invoked in infix style: 1 to 10
, list head
, making code read more naturally.
15. Operators Are Methods
Operators like +
, *
, etc., are just methods on objects, you can even define your own operators using this mechanism.
16. Singleton Objects
Scala’s object
keyword defines a singleton, only one instance exists. For example: object MySingleton
.
17. Case Classes
Case classes provide lightweight data containers with automatic features like equals
, hashCode
, serialization, companion objects, and support for pattern matching.
18. Scala on the JVM vs Android
Scala runs on the JVM; Android has its own runtime (ART/Dalvik). Scala can target Android via special tools, but they serve different ecosystems.
19. Immutable Data
Functional programming in Scala encourages immutability: modifying collections like lists returns new instances rather than modifying in place.
20. extends App
for main
Scala’s App
trait offers a quick way to define entry points, extending App
allows a script-like main method without verbose boilerplate.
21. =>
Means “Will Be”
In type signatures (=>
) it denotes “resulting in” or “returns,” e.g., Int => String
means a function that takes an Int
and returns a String
.
22. Higher-Order Functions
Functions that take other functions as parameters or return them, core to Scala’s functional programming capabilities.
Extra Gems from the Course
Additional insights from the Scala at Light Speed series:
Course Structure: It's split into modules like Getting Started, Basics, Object-Orientation, Functional Programming, Pattern Matching, Advanced Concepts, and Scala 3 Contextual Abstractions.
Lazy Evaluation: Use
lazy val
to defer evaluation until the first access, great for costly computations or infinite data structures.Option and Try Types: Scala avoids
null
by usingOption
(Some
orNone
) and handles exceptions gracefully withTry
, both can be composed using functional methods likemap
andflatMap
.Practical Match: The course walks through ~50 real-world examples (~500 lines of code), helping to ground theory in hands-on practice.
Subscribe to my newsletter
Read articles from Anshuman Awasthi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
