Functional Java Workshop

Workshop Overview

Saran Ahluwalia

https://github.com/ahlusar1989/java-workshop-materials

https://ahlusar1989.github.io/java-workshop-materials/

About Me

  • AE Intern in Compozed
  • Previously worked at Social Tables, DivvyCloud and the Wynyard Group
  • Currently studying mathematics and statistics
  • Marathoner

How this Workshop Came to Be

  • First language I learned were Scala and Haskell
  • Java 8 Study Group in DC and Durham
  • "Clean Code" Book
  • Working on research in optimizing reinforcement learning algorithms
  • These experiences have changed the way I think about writing code.

Plan for the Workshop

  • Some thoughts about Functional Programming
  • Immutability Review and Exercises
  • Lambda Review
  • Streams Review and Exercises
  • Optionals Review
  • Multi-step guided exercise - Green Field
  • Function Composition Review
  • Multi-step guided exercise - Refactoring
  • Coda: Advanced Immutability

We will focus on practical applications - very few vocabulary words and mathematical jargon!

Functional Programming Hype

  • Solves all your concurrency problems!
  • The solution to Moore's Law slowing down!
  • Super Trendy! Big Money!
  • Retro/Vintage/Hipster Programming - Lisp is Cool Again!

But seriously, how many people in this room...

  • have major concurrency problems?
  • have a Moore's Law problem?

Why Are We Here?

I want to be a functional programmer!

Wrong answer

I want to be a better programmer!

This is why we're here...

What is clean code?

  • Meaningful Names
  • Small Methods
  • Small Classes
  • TDD
  • SOLID Principles

Functional practices urge us towards clean code

What is Functional Programming?

  • Functions as first class citizens?
  • Pure functions?
  • Lambdas?
  • Closures?
  • Recursion with Tail Call Optimization?
  • Lazy streams?
  • Immutability?
  • Declarative vs. Imperative?
  • Monads (Haskell)?
  • Code as Data (Lisp)?

Argh!

No one can define it!

Except maybe Uncle Bob...

Spoiler alert...Immutability is the Key!

Next Steps

  • Demo and overview of the source repo
  • Setup Exercise: Make sure you can run the tests in whatever IDE you choose