
Prepare for the Scala advanced course by using the setup module to download the materials and the support materials, follow the course, and try the examples and exercises.
Set up the Java JDK by ensuring Java 8 or 9 is installed, verify with the Java compiler, and use Oracle Technical Network downloads or Linux PPA if needed.
Install sbt across Linux, Mac, or Windows by using the download page for the Scala language, then verify with sbt in the terminal and check the sbt version.
Learn to configure IntelliJ to use the correct JDK by setting the project SDK in project defaults and structure, then import the Scala exercises from the provided zip.
Please download the zip file attached to this lecture, then follow the video to unpack it and import it into IntelliJ IDEA
Explains the principle of uniform access, where all module services are accessible through a uniform notation regardless of storage or computation, contrasting with Java's distinction between fields and methods.
Explore mutable state in Scala using the rewriting convention, demonstrated with a weight example that uses an accessor and a setter to convert between pounds and kilos.
Explore how the Scala compiler rewrites kilo weights to a call for kilos, using underscores and a modifier; a var automatically generates a modifier, with rules next.
Explore how to manually implement a Scala class with private this backing fields, accessors, and weight conversion between pounds and kilos using explicit getters and modifiers.
See how the code Scalia generates uses private fields with access modifiers and modifier methods; use the scripts and worksheets to experiment and restore an older version if needed.
Explore how abstract properties in traits and abstract classes generate only accesses and modifiers, forming contract to fulfill in concrete instances, and override height and height_ equals with proper types.
Back properties with a mutable map, limited to string and double, preserving the same access and modifier API while defaulting to 0.0 and enabling external storage options.
Demonstrate how futures enable non-blocking cache lookups with a Guava cache, using a cache loader to fetch values and resolve futures concurrently.
Learn caching best practices in Scala: minimize mutable state, document it when used, favor immutable results, use Guava for in-memory caching, and complete exercises to implement custom accesses and modifiers.
Explore Scala simple types by modeling an abstract food class with a string name and concrete case classes like banana and apple (fruit), granola and muesli (cereal).
Explore how inheritance and subtyping let you pass apples and muesli to the eat method that accepts food, then store them in a bowl.
Learn how upper bounds constrain a generic type to be a kind of food, enabling name calls on F. See how bounds prevent invalid assignments and compile errors.
Explore how Scala's type system enforces generic type parameters through a fruit bowl example, illustrating subtypes, type variance, and the rule that a fruit bowl must match a fruit eater.
This lecture explains invariance in generic types and introduces covariance with a food bowl example, showing how plus F makes a fruit bowl usable as a food bowl.
Explore variance in Scala's type system, including invariant, covariant, and contravariant generics. See how lists are covariant and sets are invariant, and how contravariance flips type arrows for input parameters.
Explore how covariance and contravariance affect type safety in sinks and fruit handling, illustrating upper and lower bounds and why variance matters in scala's type system.
Explore how Scala treats type parameters as invariant, covariant, or contravariant, including upper and lower bounds, where only class or trait definitions specify variance and bounds.
Examine control variance and covariance in Scala function definitions, showing how input types stay at least as general and outputs at least as specific through a fruit and description example.
Explore how functions behave with variance, passing an apple into a function that handles fruits and producing descriptions like taste and texture, illustrating contravariance on inputs and covariance on outputs.
Explore variance in the Scala type system, comparing covariance and contravariance with examples like fruit, orange, texture, and description to understand function input and output types.
Explore how type parameters become part of Scala type and how variance governs subtypes and supertypes, enabling the compiler to infer relationships from generic containers such as a food bowl.
Explore Scala's advanced type system and how outside access differs from inside a class, using variable parameters, fields, and type members.
Explore how types can be members of a class, using abstract types, upper bounds, and a type projection to define and access internal and external types like food and apple.
Explore building a tiny Scala DSL with singleton types and infix notation to create a type-safe to be or not to be style API that links type system concepts.
Explore refinement types that combine easy initialization with embedding a specific type inside a type member, illustrated by a food bowl where the food equals apple.
This lecture explains a type class pattern using compare T of itself, defines a distance case class extending the trait, and shows sorting engine sizes and people by name.
Explore F-bounded polymorphism and recursive types in Scala, where a trait or class defines itself through its own type parameter, then apply with Module 3 exercises and tests.
Explore existential types, structural typing, refinement types, and self types with constraints, plus infix type notation, within the regular Scala type system in module four.
Explore existential types, underscore notation, structural types for static duck typing with compile-time checks; reflexion, refinement types, self types and self aliases, infix type notation, and Scala enumerations.
Learn how existential types serve as bounds shortcuts, compare them to Java wildcards, and explore structural types with static duck typing, including reflection considerations.
Explore refinement types and type parameters in Scala with a food bowl example (apple vs muesli) to enforce correct feeding by a fruit eater, via type members and upper bounds.
Refinement types offer safer structural typing by constraining a bowl to fruit, allowing apple bowl but rejecting a muesli bowl; they enforce compile-time rules without reflection, boosting type-member expressiveness.
Explains infix type notation for two-parameter types in Scala, showing the equivalence between infix and square-bracket forms and how parentheses affect scope.
Explore the Scala type system's implicit instances and type classes, then a simple retry pattern using nonfatal, by-name bindings and an explicit retry type.
Register and use implicit parameters in Scala by marking values as implicit, enabling compiler lookup by type for features like retry parameters and execution context in futures.
Learn how Scala's implicit parameters work, how explicit definitions override implicits, how the compiler fills implicit arguments, and best practices for implicit parameter lists and the implicitly keyword.
Learn how implicit parameters in Scala use type matches, not names, and how to override, hide, or disable implicits with scoped definitions, avoiding ambiguous defaults.
Explore how a type class defines behavior for a generic type with a single parameter and a compare method, using implicit instances to enable insert sort without changing inheritance.
Explore how Scala's implicit mechanism applies to objects, classes, and defs. See how implicit objects, implicit vals, and implicit defs enable compositional patterns and the powerful capabilities of implicit defs.
Explore using context bounds as sugar for implicit type class patterns in Scala. Learn to replace implicit parameters with a bound like T: type class and retrieve evidence with implicitly.
Implement a json writer type class in Scala by adding an implicit string writer that quotes strings via interpolation, then extend with a double writer using toString without quotes.
Learn to derive a JSON writer for lists of any type using implicit type classes and context bounds, reducing boilerplate and enabling seamless composition when the items have a writer.
Explore a Scala type-system based rules approach that matches eaters to foods using implicit evidence and upper-bounded type parameters, implementing vegan, vegetarian, and paleo rules for fruit, cereals, and meat.
Explore how compile-time enforced behavior uses implicits to import and alter rules, enabling safe, configurable constraints. See how databases with long transactions are required and unsupported ones trigger compiler errors.
This module explains the Scala numeric type class, how to define numerics for custom types (rational, complex), and how implicit constraints enable safe operations.
Explore how Scala uses a sealed, implicit equals type class to enforce type equality, enabling numeric operations only when two types match, with implicit conversions simplifying the evidence.
Explore flattening futures in Scala by using safe casting and evidence that a type equals a future of another type. Apply flatMap to implement the flatten operation.
Explore how implicit conversions create extension methods in Scala, showing a Time class and syntax, and why safe practice requires owning a type and using implicit classes inside an object.
Explore how implicit classes wrap values and incur minimal overhead, and learn the rules for extension methods: a single parametric implicit parameter, no additional state, and top-level placement.
Learn to debug implicit rules in Scala by applying implicits explicitly to reveal type incompatibilities, resolve ambiguous implicits, and use scalac options to inspect the AST and code expansion.
Place implicit definitions in the companion object or a package object. Use a convenient utility object to import implicits, or import from the package object that shares the package name.
Use implicits judiciously, prefer companion object implicits for ubiquitous defaults, and rely on type classes to reduce macro usage and slow compiler lookups.
Scala Advanced, Part 1
The Escalate Software Scala Advanced course is intended for experienced Scala developers looking to improve their skills, particularly for library and API design and development. It covers topics needed to be effective in producing high quality, correct, powerful and flexible Scala libraries that are still easy to use by others.
Part 1 provides in depth and thorough knowledge of the Scala type system, an important precursor to any library development. We start off with a look at the dangers, and safe use, of mutable shared state in Scala, covering properties and caching. From there we delve into the Scala type system including:
Generics
Co- and Contra-Variance
Upper and Lower Bounds
Type Inference
Type Parameters and Type Members
Path Dependent Types
Refinement Types
Structural Types
Recursive Types
F-bounded Polymorphism
The final two modules then move on to the secondary Implicits type system that augments the regular Scala type system, covering:
Simple Implicit Parameters
Type Classes
Implicit classes, objects and methods
Type Class Composition
Implicit Constraints
=:= and <:<
Implicit Class and Type Tags
Implicit Conversions
extends AnyVal
And more.
After completing this course you will understand the Scala type system in a way that lets you construct your own well designed APIs, reason about type abstraction and calculus, apply implicit constraints and augment the language rules, and much more.
Parts 2 and 3 (available separately) cover topics like best practices, idioms, patterns, advanced functional programming, asynchronous programming, parser-combinators, macros, performance profiling and optimization, and much more. These parts rely on information presented during this advanced part 1 course.