Scala track: proposal for a syllabus (concept tree draft)

The Scala track has 102 practice exercises and no learning path: status.concept_exercises is false, there is no concepts/ directory, and the only concept exercise is a wip Lasagna (exercises/concept/basics). Now that the practice exercises are on Scala 3 and mostly in sync with problem-specifications (exercism/scala#488), I’d like to start on the syllabus (exercism/scala#652).

Before writing any content I’d like feedback on the concept tree below.

Guiding ideas

  • Scala 3 only. Indentation syntax, enum, given/using, extension methods.
  • Functional core first, classes later. Most students arrive from Java or Python and can already write Scala as “Java without semicolons”. The syllabus should get them to match, case classes, Option and collection operations quickly. Classes, traits and mutable state come after that core rather than before it.
  • Errors are values. Option and Either are taught early; exceptions and Try late. This matches how the practice exercises on the track already report errors.
  • No loops branch. while and var are mentioned, not taught through an exercise. Iteration is taught through collection operations, recursion and for comprehensions.
  • Reuse existing stories. Every exercise below is an existing Exercism story, mostly taken from the F#, Elixir, Java and C# tracks.
  • Not a copy of Java’s tree. Java has 24 active concept exercises; several of its concepts have no place here (for-loops, switch-statement, ternary-operators, nullability, constructors, method-overloading) and several Scala concepts have no Java counterpart.

Stage 1 — the first six

The docs suggest the design team builds the first five or six concepts before opening up to contributions. These are the ones every later exercise depends on.

# Exercise (story) Concepts Prerequisites Taken from
1 lucians-luscious-lasagna basics — exists as wip
2 annalyns-infiltration booleans basics Java, F#
3 cars-assemble numbers, if-expressions booleans Java, F#
4 log-levels strings basics Java, F#
5 guessing-game pattern-matching if-expressions, strings F#
6 tisbury-treasure-hunt tuples pattern-matching, strings F#

Notes:

  • basics: val, def, type inference, Int arithmetic, comments. strings includes s"..." interpolation.
  • if-expressions: if returns a value, so there is no ternary operator to teach.
  • pattern-matching at this point is match on literals, variable and wildcard patterns, and guards. Destructuring is added by the concepts that introduce something to destructure (tuples, case classes, enums, lists).

Stage 2 — the functional core

# Exercise (story) Concepts Prerequisites Taken from
7 bandwagoner case-classes pattern-matching, numbers, strings F# (records)
8 valentines-day enums case-classes F# (discriminated-unions)
9 role-playing-game options case-classes, tuples F#
10 tracks-on-tracks-on-tracks lists pattern-matching, strings, booleans F#
11 secret-agent higher-order-functions numbers, strings Kotlin (wip)
12 bird-watcher collection-operations lists, higher-order-functions Java, F#
13 pizza-pricing recursion enums, lists F#
14 password-checker either options, enums F# (results)

Notes:

  • enums covers both simple and parameterised cases, plus exhaustive match. In other words, algebraic data types the Scala 3 way. sealed trait hierarchies are left to traits.
  • options takes the place of Java’s nullability.
  • lists: the immutable List, ::, head/tail, and matching on Nil / head :: tail.
  • higher-order-functions: function types, lambdas, _ placeholder syntax, returning functions.
  • collection-operations: map, filter, exists, count, sum, take, foldLeft. On Java’s track bird-watcher teaches arrays and loops; here the same story is solved without either.
  • recursion includes @tailrec.

I’d propose launching (status.concept_exercises: true) when stages 1 and 2 are done: 14 exercises, 15 concepts. That is close to F#'s live syllabus (17 exercises).

Stage 3 — the rest of everyday Scala

# Exercise (story) Concepts Prerequisites Taken from
15 international-calling-connoisseur maps options, tuples, collection-operations Java, C#
16 gotta-snatch-em-all sets lists, collection-operations Java, Elixir
17 boutique-suggestions for-comprehensions collection-operations, options, tuples Elixir (list-comprehensions)
18 squeaky-clean chars strings, collection-operations Java, F#
19 jedliks-toy-car classes numbers, strings, if-expressions Java
20 need-for-speed objects classes Java (constructors)
21 remote-control-competition traits classes, lists Java (interfaces)
22 calculator-conundrum exceptions either, classes Java

Notes:

  • classes is where var, private state and constructor parameters are taught. objects: singleton and companion objects, apply, factory methods.
  • exceptions covers throw, try/catch and scala.util.Try, mainly as what you meet when calling Java libraries.

Stage 4 — candidates, in no particular order

extension-methods (log-analysis, C#), generics, given-using, type-classes, opaque-types, union-types, lazy-lists (lucas-numbers, Elixir), ranges (chessboard, Elixir), vectors-and-arrays, partial-functions, default-and-named-arguments (wizards-and-warriors-2), regular-expressions (log-parser), bit-manipulation (secrets), randomness (captains-log), datetime (booking-up-for-beauty, on java.time), futures.

These are a list of ideas rather than a plan. Following the docs’ advice, the tree can grow from here one exercise at a time.

The tree

basics
├── booleans
│   └── numbers, if-expressions
│       └── pattern-matching  (also needs strings)
│           ├── tuples
│           ├── case-classes
│           │   ├── enums
│           │   │   ├── recursion  (also needs lists)
│           │   │   └── either  (also needs options)
│           │   └── options  (also needs tuples)
│           └── lists
│               └── collection-operations  (also needs higher-order-functions)
│                   ├── maps  (also needs options, tuples)
│                   ├── sets
│                   ├── for-comprehensions  (also needs options, tuples)
│                   └── chars
├── strings
│   └── higher-order-functions  (also needs numbers)
└── (via numbers, strings, if-expressions) classes
    ├── objects
    ├── traits  (also needs lists)
    └── exceptions  (also needs either)

Practice exercises

Once a concept is live, the practice exercises get practices and prerequisites. A first, rough mapping, to show that the existing exercises cover the tree:

Concept Practice exercises that could practise it
booleans leap
numbers space-age, grains, difference-of-squares, darts, armstrong-numbers
strings two-fer, reverse-string, acronym, pig-latin
pattern-matching bob, raindrops, yacht
case-classes clock, complex-numbers, queen-attack
enums allergies, robot-simulator, bowling
options hamming, all-your-base, say, change, phone-number, binary-search
lists sublist, flatten-array, simple-linked-list
higher-order-functions accumulate, strain
collection-operations sum-of-multiples, scrabble-score, high-scores, series, sieve
recursion collatz-conjecture, prime-factors, pascals-triangle, binary-search-tree
either forth, protein-translation (after exercism/scala#947)
maps etl, word-count, nucleotide-count, grade-school
sets pangram, isogram, anagram, custom-set
for-comprehensions pythagorean-triplet, saddle-points, palindrome-products, zebra-puzzle
classes bank-account, robot-name, circular-buffer, linked-list

Tooling that needs work first

  • The test runner emits results version 2. Concept exercises are better served by version 3, which groups tests by task (task_id).
  • reference/implementing-a-concept-exercise.md is a TODO stub and needs writing before contributors can help.
  • The wip Lasagna lives under the slug basics. Concept exercises are named after their story, so I’d rename it to lucians-luscious-lasagna while it is still wip.

Questions

  1. Does the “functional core first, classes later” order look right, or should classes move into stage 2?
  2. Is 14 exercises a reasonable point to switch learning mode on, or would you launch earlier or later?
  3. Any concept you’d add to, or drop from, stages 1–3?
  4. Is anyone interested in reviewing or writing concept exercises for the track?

The plan is one concept exercise per PR, in the order above, with the concept’s about.md / introduction.md / links.json in the same PR.

2 Likes

My main piece of advice would be: start with a plan, but be flexible as you implement it. It’s a lot easier to see unexpected dependencies once you have an actual exercise with actual tests.

I believe most tracks end up re-ordering concepts at quite a late stage. That’s fine! This sort of change is much easier than writing the content initially.

Probably about right. You will know once you’ve written them: at some point it just feels right to launch.

Don’t stress about this now. It will become obvious as the implementation proceeds.

Unfortunately, I don’t (yet) know Scala: another reason I hope the syllabus succeeds. The maintainer community is pretty supportive.

Good! Several tracks break the 1:1 relationship, but I think we collectively now have enough experience to feel that this is a good target.

Good luck!

1 Like
  1. I’ve not talked about this yet, but one thing I’m planning on doing early next year is to allow tracks to have multiple learning courses. The core aim is to be able to faciliate different students. So someone learning a functional language with a functional background needs a different set of teaching to those coming from an OOP background (for example). This is a whole wider project that i’m still in the exploration stage of, and which I’ll bring for wider discussion later, BUT the reason I mention it here is that I think it will be entirely reasonable to think of the functional scala stuff and the OOP scala stuff as two seperate learning journeys, so “functional core first, classes later” sounds great.
  2. Yes, 14 feels good to me persoanlly.
  3. I’m planning on getting more involved in concept exercises in 2027 :slight_smile:

Thank you for working on this!

1 Like

(I’m also exploring “Learn Functional Programming” with a fix core path where you choose your language, and the same for OOP too, but these would compliment what you’re doing).

Often the concept and exercise introduction.md are very similar.

It saves review work when the content is always identical, enforced by CI.

e.g. concepts/basics/introduction.md =
exercises/concept/lasagna/.docs/introduction.md

As someone who’s using Exercism mostly to learn about new programming languages (and get old memories up to speed) I’m fully on board with this. Scala has proven to be quite difficult to get started without this type of guidance.

1 Like