Slide 1

Slide 1 text

Why and How Functional Programming By Anupam Jain

Slide 2

Slide 2 text

About Me •Organiser of FPNCR meetup •Programming professionally for over 12 years •Mostly Javascript and Haskell •Built large production systems with Haskell •Some FOSS libraries - •Web UIs - (https://github.com/ajnsit/concur) •Servers - (https://github.com/ajnsit/wai-routes)

Slide 3

Slide 3 text

What is Functional Programming •Functions Exist! •Functions are not Procedures. •Input and Output •First class

Slide 4

Slide 4 text

What is Functional Programming •Functional •Declarative • Pure • Immutable • Statically Typed • Algebraic Data Types • Lazy • Concurrent • ……

Slide 5

Slide 5 text

What is Functional Programming •Functional •Declarative • Pure • Immutable • Statically Typed • Algebraic Data Types • Lazy • Concurrent • …… Functions are the mode of abstraction

Slide 6

Slide 6 text

What is Functional Programming •Functional •Declarative •Pure • Immutable • Statically Typed • Algebraic Data Types • Lazy • Concurrent • …… No sequence of steps

Slide 7

Slide 7 text

What is Functional Programming •Functional •Declarative •Pure • Immutable • Statically Typed • Algebraic Data Types • Lazy • Concurrent • …… No side effects

Slide 8

Slide 8 text

What is Functional Programming •Functional •Declarative • Pure •Immutable • Statically Typed • Algebraic Data Types • Lazy • Concurrent • …… No assignments

Slide 9

Slide 9 text

What is Functional Programming •Functional •Declarative • Pure • Immutable •Statically Typed • Algebraic Data Types • Lazy • Concurrent • …… Potentially invalid programs are not compiled

Slide 10

Slide 10 text

What is Functional Programming •Functional •Declarative • Pure • Immutable • Statically Typed •Algebraic Data Types • Lazy • Concurrent • …… User defined data types are sums of products

Slide 11

Slide 11 text

What is Functional Programming •Functional •Declarative •Pure • Immutable • Statically Typed • Algebraic Data Types •Lazy • Concurrent • …… Order of evaluation is unknown

Slide 12

Slide 12 text

The Sweet Spot Productivity Quality Resilience FP

Slide 13

Slide 13 text

Productivity • Steep learning curve. But.. • Abstraction • Types • Isolation • APIs - Immutability, Laziness, Composition

Slide 14

Slide 14 text

Productivity • Very few FP practitioners. But… • Supply vs Demand • High Quality Talent Pool • High Employee Satisfaction • Remote • Training

Slide 15

Slide 15 text

Quality • Excellent Abstractions Pre-cooked for you • Excellent libraries for many things. Such as async programming.

Slide 16

Slide 16 text

Quality • Static types hinder quick scripts. But.. • Easy Refactoring, checked at compile time • Slight Hyperbole - “If it compiles it works” • Reality - “Refactor without fear” • Let the computer help you help yourself • All this implies - Low Tech Debt

Slide 17

Slide 17 text

Resilience • Forced to Manage Complexity • No Hidden State or Effects • Large class of bugs caught at Compile Time. • Great Refactoring Story.

Slide 18

Slide 18 text

Functions • Functions exist! • Local and anonymous function definitions. • Higher order functions • First class functions

Slide 19

Slide 19 text

Other things • Do notation. General purpose. • Alternative is a natural fit for many domains like parsing, gui construction. You can define many algorithmic functions on top like optional, many, foldMap etc. Almost forms a DSL. • Advanced techniques • Free Monads • Monad Transformers • Lens, Conduit, Pipes

Slide 20

Slide 20 text

Via Haskell • Haskell Syntax • Haskell Semantics

Slide 21

Slide 21 text

FPNCR •The Delhi/NCR Haskell and other Functional Programming Languages Meetup Group •https://www.meetup.com/DelhiNCR-Haskell-And- Functional-Programming-Languages-Group •Github- https://github.com/fpncr •Mailing List - https://groups.google.com/forum/#!forum/ fpncr •Slack - https://functionalprogramming.slack.com - #FPNCR