Date(s) - 04/03/2019 - 06/03/2019
9:00 am - 5:30 pm
Functional Scala by John A. De Goes
Functional Scala is an extensive 3 day course that may be attended remotely (Central European Standard Time) or locally (Nieuwegein, just outside of Amsterdam). The course rigorously instructs Scala developers on the most complex, confusing aspects of Scala, and shows them how to use the features of the Scala programming language to write rock-solid, bulletproof business applications that are easy to test, easy to reason about, and easy to change safely in arbitrary directions required by the business.
If you know Scala, but are confused by concepts and techniques in functional programming, or perplexed by advanced features of Scala’s type system, then this is the course for you. You will learn how functional programming enables Scala developers to build highly-scalable, concurrent, parallel, asynchronous, testable, and modular programs. You will discover how to program passionately and fearlessly, with confidence, and build and test scalable programs that are correct-by-construction.
Day 1: Functional Essentials
In Functional Essentials, you will learn the foundations on which all functional programming in Scala is built: function composition, algebraic data types, higher-kinded types, and type classes. These topics can be very confusing to even experienced Scala developers, but properly explained, can provide a smooth gateway into the world of functional programming. By the end of the day, you’ll be confident in using ADTs and composition to solve real world problems, know why higher-kinded types are important to code reuse and how to use them, and understand how functional programs cleanly and simply abstract over data types.
- Function Composition. In object-oriented programming, code can be reused, but implementation inheritance leads to the logic for an entity being scattered across a complex hierarchy. Functional programming provides a simpler, saner approach based on composition. You will learn how to use composition rather than inheritance to build larger pieces from smaller, self-similar pieces.
- Algebraic Data Types. Many bugs in applications are caused by invalid data, which leads to edge cases, logic errors, and runtime exceptions. Functional programming provides Algebraic Data Types (ADTs), which allow you to precisely your domain in a way that eliminates these bugs. Equipped with a knowledge of ADTs and how they improve upon the “record” types found in other programming languages like Java, you will gain an ability to craft precise models of your domain that do not allow invalid states to exist.
- Higher-Kinded Types. In object-oriented programming, generics allow us to reuse code—for example, having a single sorting algorithm that can work with arrays of any element type. However, traditional OOP generics aren’t powerful enough to allow us to reuse higher-order logic. Functional programming provides Higher-Kinded Types (HKTs), which allow us to abstract over first-order abstractions (e.g. a collection-like data structure). You will understand why higher-kinded types are important to code reuse, and you will be able to pick apart and understand even the most complex higher-kinded type signatures.
- Type Classes. The traditional object-oriented habit of mandating that classes extend certain interfaces results in tangled inheritance hierarchies that are hard to understand, and impossible to force onto third-party libraries. In functional programming, Type Classes provide an alternative way of adding structure to types, one that is easier to understand and works for user-defined and third-party data types alike. You will learn how to define and implement your own type classes so you can write generic code that works across user-defined and third-party data types.
Day 2: Functional Abstractions
In Functional Abstractions, you will learn the core type classes used in functional programming, including some from abstract algebra and others from category theory. You will also learn about some of the powerful data types like lenses that help make functional programming better at stateful, effectful programs than procedural programming. By the end of the day, you’ll have a firm grasp on monads, functors, monoids, lenses, prisms, and traversals.
- Abstract Algebra. In object-oriented programming, many opportunities for code reuse go unnoticed, because common patterns do not come equipped with strong guarantees. In functional programming, monoids, semigroups, rings, fields, and other structures encapsulate common patterns of composition and combination, and can be used to solve many problems, especially in data processing. You will learn the basics of abstract algebra and define instances of monoids and other structures for common business data types.
- Functor Hierarchy. In object-oriented programming, design patterns like visitor, command, and dependency injection are used to describe common patterns. In functional programming, we can give names to common patterns and describe their behavior with structured type classes (instead of English prose) and generic laws, which lets us reuse more code and have a clearer idea of when code benefits from a certain pattern. The functor hierarchy, including everything from functor to applicative and monad and beyond, let’s us describe patterns of building data, changing data, and building programs to compute data. You will learn how to identify patterns that can benefit from various types of functors, including monads, and implement instances for practical data types.
- Folds & Traverses. In object-oriented programming, processing data is accomplished by writing lots of imperative loops. In functional programming, we can eliminate the duplication inherent to this style of programming, and focus strictly on the step of a loop, and its contribution toward the overall result of the iteration. This segment explores catamorphisms in the context of processing tree-like data structures, including lists, trees, and options. You will learn how to write clean, compact, and clear iterations using folds, and how to perform powerful of effectful loops using monadic traversals.
- Optics. In object-oriented programming, objects have getters and setters, which allow easy manipulation of data, but at the cost of local reasoning, because passing a data reference to any code anywhere means giving permanent read/write access to the data. In functional programming, a powerful construct known as optics (including lenses and prisms) allow us to preserve local reasoning and gain back not just easy data manipulation, but first class fields, which can be passed around and stored in data structures. You will learn how to manipulate deeply nested data in a first-class, functional, and powerful way.
Day 3: Functional Effects
In Functional Effects, you will become an expert in using ZIO, a new library for building high-performance, leak-free Scala applications that are asynchronous and concurrent. Functional effect systems like ZIO include operations for safely acquiring and releasing resources, running tasks in parallel, racing tasks, forking tasks to run on green threads, interrupting forked tasks whose results are no longer needed, and joining forked tasks. By the end of the day, you will feel confident using ZIO either stand-alone or with Future or Cats Effect, and will have built your own purely functional application in a graduation project that ties together everything you learn in the course.
- Effects. In object-oriented programming, types say nothing about the behavior of a function, and detailed exploration of code is necessary to understand behavior. Functional programming solves these problems by turning effects into ordinary values, which allows types to describe behavior, and provides powerful ways of reasoning about and composing programs. You will learn how to describe any interaction with effectful systems using monadic effect types.
- Asynchronicity, Concurrency & Parallelism. In object-oriented programming, asynchronicity, concurrency and parallelism are extremely painful, because of the presence of imperative callbacks and shared mutable state, which leads to callback hell, deadlocks, thread leaks, and other massive pain points. Functional programming provides a more principled, sane model of asynchronicity, concurrency and parallelism, which makes developing asynchronous, safe, scalable programs trivial. You will learn how to write efficient (asynchronous) and performant code.
- Resource-Safety. In object-oriented programming, the only primitive for resource safety is try / finally, which doesn’t work for asynchronous and concurrent programs, and can’t help avoiding thread-leaks. Functional programming allows us to increase the usefulness of try / finally across asynchronous and concurrent code, and across threads as well as file and socket handles. You will learn how to write programs that cannot leak resources.
- Real World Programming. In object-oriented programming, real world concerns include partiality, optionality, input and output, logging, bad user input, and so forth. Functional programming lets us handle all these concerns, with only pure functions, and in ways that provide strong benefits to local reasoning, testability, and modularity. You will learn how to solve the concerns of every day programming using the tools of functional programming.
- Testing & Mocking. In object-oriented programming, testing effectful code is difficult, often requiring strange mocking libraries that perform bytecode rewriting. Functional programming makes testing even the most effectful code trivial, without requiring any bytecode rewriting and still being completely typesafe. You will learn how to thoroughly test effectful code with blazing fast unit tests that require no magic and are completely type safe.
- 9:00 – Begin Instruction
- 10:25 – Break
- 10:35 – Resume Instruction
- 12:00 – Lunch Break
- 13:30 – Resume Instruction
- 14:55 – Break
- 15:05 – Resume Instruction
- 16:25 – Break
- 16:35 – Resume Instruction
- 17:30 – End of Day
The training course will take place at Big Data Republic.
Attendance to Functional Scala is local or remote. Local attendees must arrange their own transportation and lodging to the host city, as well as their own food and beverages. Remote attendees will be provided with a link to a remote meeting session, in which they can see and hear the live workshop, ask the instructor questions, and chat with both local and remote attendees. Motivated remote attendees who participate in all exercises can expect to get nearly as much out of the training as local attendees.
Attendees will be provided with example code, a course outline, and exercises in electronic form. The workshop is not recorded and recording is strictly prohibited.
Financial aid is available for qualified applicants. If you would like to attend the training but cannot afford the list prices, please contact the organizer for information on all available aid packages.