Power of Functions in a Typed World on the JVM
John Carmac once mentioned on twitter that "Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function." In this talk we will discuss the power of functions in modeling real world applications on the JVM. When we say functions, we mean "pure" functions as in the world of mathematics.
Functions model behaviors, functions compose to build larger functions, and combined with a powerful type system allow us to abstract over the generalities in defining real world domain models. The combination of functions along with algebraic data types has proven to be extremely useful in designing large scale systems that are modular and extensible.
Scala is a typed functional (well, almost) language on the JVM. In this session we will discuss how the functional features of Scala offer many of the above benefits in designing large scale systems. If you are coming from an OO background, you will appreciate how an alternative approach to programming can make your systems simpler to design, implement and maintain.
Outline/Structure of the Tutorial
- Introduce the benefits of pure functions
- Introduce Scala
- Discuss the powers of compositionality of functions
- From OO to FP - how to make the jump
- Introduce Algebraic Data Types (ADT)
- Thinking in terms of functions + ADTs
- Algebra is all you need
- A brief explanation of how to handle side-effects algebraically
- Modularity in a functionally designed system
Learning Outcome
I expect attendees to develop an appreciation of typed functional programming on the JVM
Target Audience
Beginners who would like to jump into the FP bandwagon
schedule Submitted 5 years ago
People who liked this proposal, also liked:
-
keyboard_arrow_down
Michael Snoyman - Applied Haskell Workshop
480 Mins
Workshop
Intermediate
This full day workshop will focus on applying Haskell to normal, everyday programming. We'll be focusing on getting comfortable with common tasks, libraries, and paradigms, including:
- Understanding strictness, laziness, and evaluation
- Data structures
- Structuring applications
- Concurrency and mutability
- Library recommendations
By the end of the workshop, you should feel confident in working on production Haskell codebases. While we obviously cannot cover all topics in Haskell in one day, the goal is to empower attendees with sufficient knowledge to continue developing their Haskell skillset through writing real applications.
-
keyboard_arrow_down
Luka Jacobowitz - Testing in the world of Functional Programming
45 Mins
Demonstration
Intermediate
Testing is one of the most fundamental aspects of being a software developer. There are several movements and communities based on different methodologies with regards to testing such as TDD, BDD or design by contract. However, in the FP community testing is often not a large topic and is often glossed over. While it’s true that testing in functional programming tends to be less important, there should still be more resources on how to create tests that add actual value.
This talks aims to provide exactly that, with good examples on how to leverage property based testing, refinement types and the most difficult part: figuring out how to test code that interacts with the outside world.
-
keyboard_arrow_down
Ravi Mohan - Experience Report: Building Shin - A Typed Functional Compiler For Computational Linear Algebra Problems.
45 Mins
Talk
Intermediate
Abstract: I wrote a distributed (mostly) Functional Compiler in Scheme, OCaml and Elixir that incorporates knowledge of Computational Linear Algebra and domain specific knowledge to generate highly optimized linear algebra code from specification of problems. This talk is about lessons learned in the process.
The problem:
In every domain that uses computational linear algebra (which is all of engineering and science), we encounter the 'how to optimize a linear algebra expression into an optimized sequence of BLAS (or LAPACK or $linear_algera library) kernel calls' problem.Example: (if the math equations make you want to tear your hair out and go jump off a cliff, don't worry, it is just an example, you don't have to grok it. Just skim the equations The basic problem being addressed here is that solving such equations with code takes up a lot of effort and time from experts in computational linear algebra)
Here is a linear algebra expression from a genetics problem , specifically GWAS -Genome Wide Association Studies, looking for significant associations for millions of genetic markers- where the essence of the problem [1] comes down to generating the most efficient algorithm possible that solves these equationsThis in turn involves solving a 2 dimensional sequence of Generalized Least Squared Problems of the form
The algorithms to solve these can be directly coded up in Matlab or Julia. But there are problems with this approach, with this specific problem.
1. For different input sizes, different algorithms give the most optimal performance. Which algorithm do you code up?
2. Even for a given input size, there are multiple algorithms that compute the same result, but have differing computational characteristics depending on the hardware etc. How do you generate the optimal algorithm for your hardware ?
3. Most importantly the structure of *this* specific problem allows optimizations that are specific to the problem which are not built into generic linear algebra routines. (Obviously, one can't expect MATLAB to incorporate problem specific information for every scientific/engineering problem ever). The GLS problems are connected to others, thus saving intermediate results can save hours of computation vs calculating every GLS problem from scratchIn practice, one needs to be an expert in Computational Linear Algebra to come up with the optimized algorithm for a domain specific problem, and then write (say Fortran) code to use BLAS, LAPACK etc optimally to actualize this algorithm, often with much iteration, often consuming 100s of hours.
The Solution:
Incorporating this 'expert knowledge' into a compiler speeds up the time taken to arrive at the best solution (often by a factor of 100 or 1000), and allows Computational Linear Algebra experts to do more interesting things, like focus on their research.For this particular problem, the above equations, and additional knowledge of the problem domain are the input into an expression compiler. The output is highly efficient and 'proved correct' code
In compiler terms, incorporating domain knowldege into the compilation process results in being able to apply optimizations to the generated Syntax Trees/Graphs, resulting in optimal algorithms. (note: the output of the compiler is a program in another language- say Matlab).
In essence, "Domain Specific Compilers" consume knowledge about the structure of a problem and generate optimized code that solves that problem.Shin is one such compiler. It consumes a problem description and outputs highly efficient Julia code that solves the problem.
This talk focuses on the engineering challenges I faced in building this compiler, with a special focus on the approaches that failed [5]
Trivia:
"Shin" is the Hebrew letter, not the English word meaning 'front of the leg between knee and ankle' ;-).
Every company uses names from a common theme to name their servers and components - Athena, Zeus, Hercules , or Thor, Loki, Odin, or Jedi, Sith, Skywalker etc. We use Hebrew words, so we have Ruach, Melekh, Malkuth etc..
-
keyboard_arrow_down
Gabriel Volpe - Cats Effect: The IO Monad for Scala
45 Mins
Talk
Intermediate
Since the first introduction of [Cats Effect](https://typelevel.org/cats-effect/) many things have changed taking its design and performance to a whole new level.
Come join me and learn how to deal with side effects in a pure functional way while abstracting over the effect type and taking composition to the next level. We will review the most important features such as synchronous and asynchronous computations, error handling, safe resource management, concurrency, parallelism and cancellation starting by reviewing the basic concepts.
-
keyboard_arrow_down
Gabriel Volpe - Beautiful Folds
45 Mins
Demonstration
Intermediate
A journey from statistics computations to composable streaming folds.
Come join me and learn by example about the beauty of generic folds and streaming data. I'll be revisiting these concepts, talking about its origins in Haskell and demonstrating the power of them by showing an example of a program that runs statistics computations using the Fs2 and Origami Scala libraries.
Inevitably, I'll also be talking about performance, concurrency, parallelism and some type classes such as Foldable, Applicative and Monoid, you won't be bored!