Functional Programming

Transcript

  1. Functional Programming Ionut G. Stan - OpenAgile 2010

  2. Functional Programming what why how

  3. Functional Programming what why how

  4. What is FP a programming style

  5. Imperative Programming programming: telling a computer what to do

  6. von Neumann architecture

  7. What is FP a programming style conceptually derived from lambda

    calculus (1930s) not procedural programming functions as in mathematical functions trying to plug the abstraction leak tell the computer what to do, not how mutations not allowed (no variables, just identifiers) no statements, just expressions (if/then/else is expression)

  8. What is FP a programming style conceptually derived from lambda

    calculus (1930s) not procedural programming functions as in mathematical functions trying to plug the abstraction leak tell the computer what to do, not how mutations not allowed (no variables, just identifiers) no statements, just expressions (if/then/else is expression) functions are deterministic and side-effect free

  9. What is FP a programming style conceptually derived from lambda

    calculus (1930s) not procedural programming functions as in mathematical functions trying to plug the abstraction leak tell the computer what to do, not how mutations not allowed (no variables, just identifiers) no statements, just expressions (if/then/else is expression) functions are deterministic and side-effect free functions are all we need to model computation

  10. What is FP a programming style conceptually derived from lambda

    calculus (1930s) not procedural programming functions as in mathematical functions trying to plug the abstraction leak tell the computer what to do, not how mutations not allowed (no variables, just identifiers) no statements, just expressions (if/then/else is expression) functions are deterministic and side-effect free functions are all we need to model computation execution order is not guaranteed

  11. Functional Programming what why how

  12. Why FP easier to reason about programs

  13. Why FP easier to reason about programs heisenbugs

  14. Why FP easier to reason about programs heisenbugs race conditions

  15. Why FP easier to reason about programs

  16. Why FP easier to reason about programs easier to parallelize

  17. Functional Programming what why how

  18. Functional Programming what why how (even in imperative languages)

  19. How to FP avoid side-effects/mutation as much as possible

  20. Functional Programming what why how example

  21. Example

  22. Example

  23. Example

  24. "Conventional programming languages are growing ever more enormous, but not

    stronger. Inherent defects at the most basic level cause them to be both fat and weak: their primitive word- at-a-time style of programming inherited from their common ancestor -- the von Neumann computer, their close coupling of semantics to state transitions, their division of programming into a world of expressions and a world of statements, their inability to effectively use powerful combining forms for building new programs from existing ones, and their lack of useful mathematical properties for reasoning about programs." John Backus, known for Fortran, Algol and BNF

  25. Thank You igstan.ro | [email protected] | @igstan

  26. Questions? igstan.ro | [email protected] | @igstan