Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Functional Programming - Why and How

Anupam
January 01, 2018

Functional Programming - Why and How

An introduction to Functional Programming, given during an FPNCR meetup at S&P offices in January 2018.

Anupam

January 01, 2018
Tweet

More Decks by Anupam

Other Decks in Technology

Transcript

  1. 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)
  2. What is Functional Programming •Functional •Declarative • Pure • Immutable

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

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

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

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

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

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

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

    Statically Typed • Algebraic Data Types •Lazy • Concurrent • …… Order of evaluation is unknown
  10. Productivity • Steep learning curve. But.. • Abstraction • Types

    • Isolation • APIs - Immutability, Laziness, Composition
  11. Productivity • Very few FP practitioners. But… • Supply vs

    Demand • High Quality Talent Pool • High Employee Satisfaction • Remote • Training
  12. 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
  13. Resilience • Forced to Manage Complexity • No Hidden State

    or Effects • Large class of bugs caught at Compile Time. • Great Refactoring Story.
  14. Functions • Functions exist! • Local and anonymous function definitions.

    • Higher order functions • First class functions
  15. 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
  16. 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