Skip to content

Instantly share code, notes, and snippets.

@davegurnell
Last active March 6, 2016 03:52
Show Gist options
  • Save davegurnell/669fa34b66bb4aceb586 to your computer and use it in GitHub Desktop.
Save davegurnell/669fa34b66bb4aceb586 to your computer and use it in GitHub Desktop.
Introduction / Motivation
Curriculum---what you teach
- How to present Scala (OO, functional)
- Design patterns
Pedagogy---how you teach it
Technology to support teaching
Examples to motivate different students
Who Can Support It / Develop It
Why Invest in Learning Scala?
1. Conceptual / artistic / aesthetic
- Simplicity
- Closure. a . a = a
- Fancy words
2. Theory
- Algebraic data types and structural recursion
- Type classes
- Sequencing operations
- map, flatMap, and fold
Higher kinds
Monoids
Functors, monads, applicatives
Monad transformers
3. Craft
- val
- pattern matching
- sealed abstract class and final case classes
- traits, implicit parameters, companion objects
- for comprehensions
self types, f-bound polymorphism
path-dependent types
- The importance of context / background of
the people you are training
- Scala as a better Java ... with worse tooling
- Teaching concepts has a very undesirable learning curve
- Start from examples / lean on intuitions then move to concepts?
- But not all concepts translate from Java / other PLs to Scala
- Use familiar tools, at least to start
- Small code, fewer tests
- Using material from other languages (Haskell, Clojure)
- Quick start for projects. Minimise setup complexity.
- Early wins quickly
- Implicits as AOP
- Introduce abstractions at an appropriate pace
- Natural order of progression?
- Classroom versus other methods of teaching
Aesthetic / Conceptual
- Immutability
- No alarms and no surprises
- Errors at compile time that are close to where the error is
- No nulls, no exceptions---with no exceptions!
- Writing code that communicates concepts to other developers
- Processes that allow peer learning
- Recognisable patterns and idioms
- Functional purity / localisation of effects / substitution / equational reasoning
- Modularity---small reusable modules, and ways to compose these modules
- Team level and team fit
Theory
- Pattern matching, algebraic data types,
with an emphasis on sum types (logical ors)
(modularity, idioms)
- Type classes (a bit later)
- Teach concepts first
- Not necessarily defining their own type classes but using existing implementation
- Naming concepts before people use Cats / Scalaz
Craft
- vals over vars
- using immutable collections and data types
- concurrency (futures, actors, ?)
- functions as values
- apply / unapply
- restructuring algorithms around immutability
- patterns for minimising confusion with implicits
Syntax is important. Gotta get the syntax down before you can progress
Simplicity
- what does this mean for FP?
Should we teach the red book?
How do we teach people to unlearn other paradigms
Understanding people's blind spots
Teach via teaching---get team members to present to other team members
Code dive / code review
- Learn by studying other code
- Code criticism
Model solutions in types
Recognising solutions in terms of recursion and immutability
Patterns for using Scala
Using a subset of Scala---which subset?
- Using tools like Wart Remover
Emphasis on not being married to the computer
Allow people to understand concepts before going to encoding in Scala
Understand students' motivations
Code critiques---case studies
Not always lectures. Small groups, lots of interaction. Mix up groups.
Resources: lectures and practice
Real world examples
Periodic group reviews / address techincal debt as case study
Code reviews on pull requests or similar
- involving all the team in performing reviews
Common resource for Typelevel?
- Can / should Typelevel produce a guide to Scala
Organisation politics
- enforce of rules or not? e.g. Wart Remover
Remove ego
FP must be more approachable
Hate the code not the coder
Inferred types and type parameters don't require full knowledge of library details
- libraries can be both beginner and advanced friendly
- See Rapture
Repeating small exercises
Quick easy win. Ride the dopamine wave
Scala 99
Scala Koans (but some problems---not full application)
Fun activities, such as Scalabot (fighting robots)
Immediate feedback
Exercises that emphasise the benefits of Scala
- Gilded Rose refactoring exercise
Decompose examples and explain all the small parts
- don't let syntax or other small things throw people off
Get syntax out of the way early
Working the way up to types
Actors vs functions
- being selective about using actors / Akka
Discount some parts of Scala
scalap---show people what the Scala code is doing
- desugar case expressions for example
Formative assessment
Feedback
Visuals / graphics
Student led teaching
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment