Scala Course Program and Materials

  • Tutorial
Good day.

My name is Golovach Ivan, I am a Java Tech Lead practitioner with 10+ years of programming experience (Java EE, J2ME, C, C ++, M-language, Delphi) who switched to Scala.

I prepared and read both regular programming courses ( Java Core + Junior Java Developer ) and special courses (Multicore Programming for JVM ( one and two )).

At the moment I am starting a special course on Scala and in this topic I want to share the materials that I found the most interesting / informative (the course was prepared for more than a year).

Course Program
Materials: Miscellaneous
Materials: Object Oriented Programming in Scala
Materials: Functional Programming in Scala
Materials: Higher kinded types
Materials: Parser combinators
Materials: Metaprogramming / Reflection
Materials: Metaprogramming / Macroses
Materials: Scalaz
Materials: Netty
Materials: Akka
Materials: Finagle
Materials: Zookeeper
Materials: Using FP in the financial industry

Course program

The Scala special course aims at
1. Deeply learning the language, including such “dark corners” as macroses, path dependent types, generics of higher kind. Learn how to create internal and external DSL. to understand why functional programming languages ​​are so popular in the financial industry.
2. Understand why when writing code in functional programming languages ​​(and Scala in particular), mathematical libraries that refer to algebra and category theory are often used.
3. See why modern startups (like Twitter and LinkedIn) often write their infrastructure on Scala.

The special course starts on February 27, 2015 and consists of 16 webinars for 2-2.5 hours. Duration 3 months (1-2 lessons per week). All lectures are recorded on video and provided to students. All necessary literature is provided in electronic form. I answer questions both during webinars and the rest of the time. You have the opportunity to communicate with 15-20 other students who are learning Scala in parallel.

  • Module # 1 (4 lectures): Basic Scala
    The task of the module is to consider the syntax and ways of solving "everyday" problems on Scala
    • "Miscellanea"
      • Local Type Inference, unified types
      • Structural types, tuples
      • Generics: variance, upper / lower bounds, existential types
      • Lazy values, DelayedInit trait, App / Application
      • Implicits, view, view bounds
      • Sequence comprehensions
      • Annotations, Exceptions
      • Work with XML
      • Scala's Collections Library, Arrays

    • Object Oriented Programming
      • Classes, objects, traits
      • Type members, abstract types
      • Explicitly Typed Self References
      • Mixin class composition, compound types, hierarchy linearization
      • Cake pattern

    • Functional programming
      • Functional types, anonymous functions, nested functions, curring, partial application
      • Methods / Functions, Operators (prefix, infix, postfix; associativity), zero-bit + no-bit-write
      • Call-by-name / call-by-value, named and default params
      • Pattern matching, case classes, extractor objects

  • Module # 2 (4 lectures): Advanced Scala
    The task of the module is to examine in detail the capabilities of Scala that are not in Java.
    • Dependent types
    • Higher kinded types
    • Parser combinators
    • Metaprogramming = Reflection + Macros

  • Module # 3 (4 lectures): Type-acrobatic libraries in Scala
    The task of the module is to consider the most advanced libraries (in the sense of using the system of types and language features), how they are written, what can be done on them.
    • Scalaz - a bit of category theory (monad, applicative functor, catamorphism, ...)
    • Shapeless - a type class and dependent type based generic programming library
    • Algebird - or how Twitter uses algebra (monoid, group, half ring, ...)

  • Module # 4 (4 lectures): Multithreaded, network and distributed programming
    The task of the module is to consider the most popular network libraries for JVM, which are most often the “building blocks” of large distributed systems. Understand why Twitter is written on Scala.
    • Netty
    • Aka
    • Finagle
    • Zookeeper

Materials: "Miscellaneous"

Scala Introductory Articles

These articles are brief overviews of the language (15-20 pages). They are more likely to be ideological / historical - as the author himself (Odersky) sees his brainchild, which he considers the most important / distinctive / characteristic.

Scala style guide

Key Scala Articles

These articles illuminate and clarify the basic characteristics of the language.

  • Scalable Component Abstractions , Odersky + .... We identify three programming language abstractions for the construction of reusable components: abstract type members , explicit selftypes and modular mixin composition . Together, these abstractions enable us to transform an arbitrary assembly of static program parts with hard references between them into a system of reusable components. ... We demonstrate this approach in two case studies, a subject / observer framework and a compiler front-end.
  • “Type classes as objects and implicits” , Odersky + ..., Type classes were originally developed in Haskell as a disciplined alternative to ad-hoc polymorphism. Type classes have been shown to provide a type-safe solution to important challenges in software engineering and programming languages ​​such as, for example, retroactive extension of programs. They are also recognized as a good mechanism for concept-based generic programming and, more recently, have evolved into a mechanism for type-level computation . This paper presents a lightweight approach to type classes in object-oriented (OO) languages ​​with generics using the CONCEPT pattern and implicits (a type-directed implicit parameter passing mechanism).
  • “Matching Objects With Patterns” , Odersky + ..., Pattern Matching in all its glory with Case classes / Extractors + comparison with more classical solutions ( Visitor , Type-Test / Type-Cast , ...)

Scala Courses / Collections

Reaching material for a small book, but not books. From the "classics".

Yes, Coursera itself is written in Scala .


There are a large number of books on the market (about 20) on Scala, but I liked the following 4 most

Materials: Object Oriented Programming in Scala

Materials: Functional Programming in Scala

Functional Programming in Scala is a powerful book from one of the contributors at Scalaz.

Materials: Higher kinded types

  • “Fighting Bit Rot with Types” , Odersky + ... - described the refactoring of Scala collections for version 2.8 with good immersion in higher-kind types , implicit parameters and implicit conversions

Materials: Parser combinators

Scala includes a package ( scala.util.parsing ) that provides tools for describing Scala External DSL grammar in a format close to EBNF. Those. it is an “internal DSL” for creating “external DSLs”.

In Scala, parsers are implemented as monads - hence defining combinators for parsers are just monadic transformations implementing sequencing, alternation or any other composition operations.

In a number of subject areas, you can build an API in the form of some primitive elements (in this case, parsers) and ways to combine these elements in a certain way (combinators). In this case, the core of the language has everything you need to build external DSLs.

Materials: Metaprogramming / Reflection

A particularly interesting aspect of macros is that they are based on the same API used also for Scala's runtime reflection, provided in package scala.reflect.api. This enables the sharing of generic code between macros and implementations that utilize runtime reflection.

Until 2.10, Scala has not had any reflection capabilities of its own. Instead, one could use part of the Java reflection API, namely that dealing with providing the ability to dynamically inspect classes and objects and access their members. However, many Scala-specific elements are unrecoverable under standalone Java reflection, which only exposes Java elements (no functions, no traits) and types (no existential, higher-kinded, path-dependent and abstract types). In addition, Java reflection is also unable to recover runtime type info of Java types that are generic at compile-time; a restriction that carried through to runtime reflection on generic types in Scala.

In Scala 2.10, a new reflection library was introduced not only to address the shortcomings of Java's runtime reflection on Scala-specific and generic types, but to also add a more powerful toolkit of general reflective capabilities to Scala. ... with full-featured runtime reflection for Scala types and generics ...

Materials: Metaprogramming / Macroses

A particularly interesting aspect of macros is that they are based on the same API used also for Scala's runtime reflection, provided in package scala.reflect.api. This enables the sharing of generic code between macros and implementations that utilize runtime reflection.

Our flavor of macros is reminiscent of Lisp macros, adapted to incorporate type safety and rich syntax. Unlike infamous C / C ++ preprocessor macros, Scala macros: 1) are written in full-fledged Scala, 2) work with expression trees, not with raw strings, 3) cannot change syntax of Scala. [ here ]

Macros are functions that are called by the compiler during compilation. Within these functions the programmer has access to compiler APIs. For example, it is possible to generate, analyze and typecheck code. You can learn more about macros from documentation. [ here ]

Def macros are shipped as an experimental feature of Scala since version 2.10.0 . A subset of def macros, pending a thorough specification, is tentatively scheduled to become stable in one of the future versions of Scala.

Experimental feature- Also note that macros are considered an experimental and advanced feature, so in order to write macros you need to enable them. Do that either with import scala.language.experimental.macros on per-file basis or with -language: experimental.macros (providing a compiler switch) on per-compilation basis. Your users, however, don't need to enable anything - macros look like normal methods and can be used as normal methods, without any compiler switches or additional configurations.

Materials: Scalaz

Materials: Netty

Netty - an asynchronious and event-driven network application framework for rapid development of maintanable high performance protocol servers and clients. Netty is the de fakto standard for using *, NIO and NIO.2 (Akka and Finagle use Netty, Zookeeper directly under NIO / NIO.2 "under the hood"). Although it is possible to directly implement Reactor / Proactor / Asynchronous Completion Token / Acceptor-Connector asynchronous message processing templates,however, this involves a lot of template code and obscuring the functionality of the subject area. Netty's advantage is both declarative code and the fact that the library is a protocol constructor (http, ftp, smtp, websockets, ...).

Materials: Akka

Akka is the de facto standard framework for multi-threaded and distributed actor-based architectures for the JVM. Starting with Scala version 2.10.0, Akka has superseded the native implementation of actors .

Materials: Finagle

Finagle - A Protocol-Agnostic extensible RPC System for the JVM, used to construct high-concurrency servers. Written and used on The basic principle is “We must program locally, communicate globally” . Part of the Twitter stack (along with Ostrich, Zipkin, Mesos, Iago, ZooKeeper, Scalding). Finagle includes load balancing, connection pooling, call with timeout, monitoring, statistics collection.

Materials: Zookeeper

Zookeeper is a fail-safe centralized service for managing configuration information, naming, distributed synchronization and other group services, part of the Twitter stack . It can be used to create basic data structures (cluster) - queues, locks, barriers. Suitable for distributed algorithms such as two-phase-commit, leader election and others.

Materials: Using FP in the financial industry

For a number of reasons (the ability to describe a subject area in the language of combinators) they like to use functional programming languages ​​in the financial industry, which creates a demand for “functionaries” in New York and London.

  • Composing Contracts: An Adventure in Financial Engineering, Simon Peyton Jones + ... - A basic article by Haskell about introducing financial contracts at Haskell. "We introduce a combinator library that allows us to describe such contracts precisely, and a compositional denotational semantics that says what such contracts are worth. We sketch an implementation of our combinator library in Haskell. Interestingly, lazy evaluation plays a crucial role. " "The finance industry has an enormous vocabulary of jargon for typical combinations of financial contracts (swaps, futures, caps, oors, swaptions, spreads, straddles, captions, European options, American options, ... the list goes on)." "Our combinators can be used to describe a contract, but we also want to process a contract. Notably, we want to be able to find the value of a contract. In Section 4 we describe how to give an abstract valuation semantics to our combinators. A fundamentally-important property of this semantics is that it is compositional; that is, the value of a compound contract is given by combining the values ​​of its sub-contracts. ”
  • “Commercial Uses: Going functional on exotic trades” - a description of the DSL used in Barclays for working with financial instruments (Haskell). “The Functional Payout Framework (fpf) is a Haskell application that uses an embedded domain-specific functional language to represent and process exotic financial derivatives. Whereas scripting languages ​​for pricing exotic derivatives are common in banking, fpf uses multiple interpretations to not only price such trades, but also to analyze the scripts to provide lifecycle support and more »
  • “Scala at EDF Trading. Implementing a Domain-Specific Language for Derivative Pricing with Scala. ” -“ DIESEL is a language for representing energy derivatives to facilitate Monte Carlo pricing and analytics. The DSL consists of a combinator parser libary and algebraic data types with case classes. ”
  • "Compositional specification of commercial contracts"
  • “An Algebraic Specification of a Language for Describing Financial Products” - “We report on the use of formal methods and supporting tools during the development of a language applied in a banking environment. This language, called RISLA, is used to define the nature of the interest products offered by a bank. A RISLA description fixes the cash flows (amounts of money coming in or going out on particular dates) resulting from a product .... "The language has been developed with the use of algebraic specifications, the role of which is discussed."
  • “Domain-Specific Languages ​​versus Object-Oriented Frameworks: A Financial Engineering Case Study” - “The use of a domain-specific language can help to develop readable and maintainable applications in that domain with little effort. Alternatively, the same aims can be achieved by setting up an object-oriented framework. For the domain of financial engineering, independently both an objectoriented framework and a domain-specific language have been developed. We use this opportunity to contrast these two, to highlight the differences and to discuss opportunities for mutual benefits. ”
  • "Adventures in financial and software engineering"
  • “Financial Domain-Specific Language Listing - A Large Selection of Finance API / DSL

PS We are happy to answer any questions via
skype: GolovachCourses

Only registered users can participate in the survey. Please come in.

What technology / framework would you like to study / add to your resume?

Also popular now: