Successfully reported this slideshow.

Porque aprender haskell me fez um programador python melhor?

4,583 views

Published on

Published in: Career
  • Be the first to comment

  • Be the first to like this

Porque aprender haskell me fez um programador python melhor?

  1. 1. Porque aprender haskellme fez um programador python melhor? @gustavopinto gustavo@entropie.com.br
  2. 2. Porque aprender haskellme fez um programador python melhor? Baseado em fatos reais @gustavopinto gustavo@entropie.com.br
  3. 3. Gustavo Pinto2004 - belém, grad, php, sh2006 - amazontic, java, xp2008 - curitiba, msc, python2009 - aprioriti, xp, scrum2011 - recife, phd, haskell2012 - entropie, lean, scala
  4. 4. Belém
  5. 5. Belém
  6. 6. Belém
  7. 7. Belém
  8. 8. Belém
  9. 9. Belém
  10. 10. DISCLAIMER
  11. 11. Não tem código
  12. 12. Não tem código¬¬
  13. 13. Mentira, tem mas épouquinho :-)
  14. 14. 1912 ~ 1954
  15. 15. 1912 ~ 1954 1936
  16. 16. 1912 ~ 1954 1936
  17. 17. ON COMPUTABLENUMBERS, WITHAN APPLICATION TO THEENTSCHEIDUNGS PROBLEM
  18. 18. ON COMPUTABLENUMBERS, WITHAN APPLICATION TO THEENTSCHEIDUNGS PROBLEM
  19. 19. ON COMPUTABLENUMBERS, WITHAN APPLICATION TO THE DECISION PROBLEM
  20. 20. 1903 ~1995
  21. 21. 1903 ~1995 1936
  22. 22. 1903 ~1995 1936
  23. 23. AN UNSOLVABLE PROBLEM OF ELEMENTARY NUMBER THEORY
  24. 24. 1936
  25. 25. 1936
  26. 26. Church-Turing thesis
  27. 27. Church-Turing thesis
  28. 28. Church-Turing thesis Equivalentes
  29. 29. Algumas features:● Pure functions● Functions as first-class objects● No side effects
  30. 30. Algumas features:● Pure functions● Functions as first-class objects● No side effects Concurrency Friendly
  31. 31. Great.. But, whatabout Python??
  32. 32. Python functional
  33. 33. Is python functional?
  34. 34. Is python functional?
  35. 35. I have never considered Python to be heavily influenced by functional languages, no matter what people say or think. I was much more familiar with imperative languages such as C and Algol 68 and although I had made functions first-class objects, I didnt view Python as a functional programming language. However, earlier on, it was clear that users wanted to do much more with lists and functions.http://python-history.blogspot.com.br/2009/04/origins-of-pythons-functional-features.html
  36. 36. I have never considered Python to be heavily influenced by functional languages, no matter what people say or think. I was much more familiar with imperative languages such as C and Algol 68 and although I had made functions first-class objects, I didnt view Python as a functional programming language. However, earlier on, it was clear that users wanted to do much more with lists and functions.http://python-history.blogspot.com.br/2009/04/origins-of-pythons-functional-features.html
  37. 37. I have never considered Python to be heavily influenced by functional languages, no matter what people say or think. I was much more familiar with imperative languages such as C and Algol 68 and although I had made functions first-class objects, I didnt view Python as a functional programming language. However, earlier on, it was clear that users wanted to do much more with lists and functions.http://python-history.blogspot.com.br/2009/04/origins-of-pythons-functional-features.html
  38. 38. I have never considered Python to be heavily influenced by functional languages, no matter what people say or think. I was much more familiar with imperative languages such as C and Algol 68 and although I had made functions first-class objects, I didnt view Python as a functional programming language. However, earlier on, it was clear that users wanted to do much more with lists and functions.http://python-history.blogspot.com.br/2009/04/origins-of-pythons-functional-features.html
  39. 39. I see list and functions
  40. 40. if god exists: atepassar**2hack, hack
  41. 41. search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element == element_f ] for element_f in e]
  42. 42. search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element == element_f ] for element_f in e]
  43. 43. List comprehension A basic comprehension for a set that contains the first ten even natural numbers is The part before the pipe is called the output function, x is the variable, N is the input set and x <= 10 is the predicate. That means that the set contains the doubles of all natural numbers that satisfy the predicate.http://learnyouahaskell.com/starting-out#im-a-list-comprehension
  44. 44. List comprehension A basic comprehension for a set that contains the first ten even natural numbers is The part before the pipe is called the output function, x is the variable, N is the input set and x <= 10 is the predicate. That means that the set contains the doubles of all natural numbers that satisfy the predicate.http://learnyouahaskell.com/starting-out#im-a-list-comprehension
  45. 45. List comprehension A basic comprehension for a set that contains the first ten even natural numbers is >>> [i for x in range (0, 100) if x > 10]http://learnyouahaskell.com/starting-out#im-a-list-comprehension
  46. 46. List comprehension A basic comprehension for a set that contains the first ten even natural numbers is >>> [i for x in range (0, 100) if x > 10] >>> [[row[i] for row in matrix] for i in range(4)]http://learnyouahaskell.com/starting-out#im-a-list-comprehension
  47. 47. List comprehension A basic comprehension for a set that contains the first ten even natural numbers is >>> [i for x in range (0, 100) if x > 10] >>> [[row[i] for row in matrix] for i in range(4)] >>> dict([(i, chr(65+i)) for i in range(4)])http://learnyouahaskell.com/starting-out#im-a-list-comprehension
  48. 48. List Sou foda comprehension A basic comprehension for a set that contains the first ten even natural numbers is >>> [i for x in range (0, 100) if x > 10] >>> [[row[i] for row in matrix] for i in range(4)] >>> dict([(i, chr(65+i)) for i in range(4)])http://learnyouahaskell.com/starting-out#im-a-list-comprehension
  49. 49. search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element == element_f ] for element_f in e]
  50. 50. Lambda Lambdas are basically anonymous functions that are used because we need some functions only once. Normally, we make a lambda with the sole purpose of passing it to a higher-order function.http://learnyouahaskell.com/higher-order-functions#lambdas
  51. 51. Lambda Lambdas are basically anonymous functions that are used because we need some functions only once. Normally, we make a lambda with the sole purpose of passing it to a higher-order function.http://learnyouahaskell.com/higher-order-functions#lambdas
  52. 52. Lambda >>> lambda x: x % 2http://learnyouahaskell.com/higher-order-functions#lambdas
  53. 53. Lambda >>> is_even = lambda x: x % 2http://learnyouahaskell.com/higher-order-functions#lambdas
  54. 54. Lambda >>> is_even = lambda x: x % 2 >>> is_even <function <lambda> at 0x2a3d050>http://learnyouahaskell.com/higher-order-functions#lambdas
  55. 55. search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element == element_f ] for element_f in e]
  56. 56. Built-in Functions>>> for mes in enumerate ([jan, fev, mar]):... print mes(0, jan)(1, fev)(2, mar)
  57. 57. Built-in Functions>>> for mes in enumerate ([jan, fev, mar]):... print mes(0, jan)(1, fev)(2, mar)outras built-in functions: ● filter ● map ● reduce
  58. 58. Built-in Functions>>> for mes in enumerate ([jan, fev, mar]):... print mes(0, jan)(1, fev)(2, mar)outras built-in functions: ● filter ● map Funções de ● reduce alta ordem
  59. 59. Filterfilter(...) filter(function or None, sequence) -> list,tuple or string Return those items of sequence for whichfunction(item) is true. [....]>>> filter(lambda x: x % 2 == 0, range(10))
  60. 60. Filterfilter(...) filter(function or None, sequence) -> list,tuple or string Return those items of sequence for whichfunction(item) is true. [....]>>> is_even = lambda x: x % 2 == 0>>> filter(is_even, range(10))
  61. 61. Mapmap(...) map(function, sequence[, sequence, ...]) -> list Return a list of the results of applying thefunction to the items of the argument sequence(s). [....]>>> map(lambda s: s.upper(), [a, b, c])
  62. 62. Reducereduce(...) reduce(function, sequence[, initial]) -> value Apply a function of two argumentscumulatively to the items of a sequence, fromleft to right, so as to reduce the sequence to asingle value. [....]>>> reduce(lambda x,y: x * y, range(1, 4))>>> reduce(lambda x, y: x + y, [a, b, c, d])
  63. 63. Sua High Order Functiondef f(x): return x + 1def g(function, x): return function(x) + function (x + 1)print g(f, 1)
  64. 64. Sua High Order Functiondef f(x): return x + 1 not baddef g(function, x): return function(x) + function (x + 1)print g(f, 1)
  65. 65. Porque aprender haskellme fez um programador python melhor?
  66. 66. Conseguientendermelhor ocódigo do Marcel!
  67. 67. Conseguientendermelhor o códigode outraspessoas!
  68. 68. Consegui entender melhor a minhalinguagem!
  69. 69. Consegui entender melhor o meuframework!
  70. 70. Resumindo
  71. 71. Domine sualinguagem
  72. 72. Evolua com asua linguagem
  73. 73. Domine outras linguagens (Tanto quanto)
  74. 74. Entenda quelinguagens são escolhas
  75. 75. Seja o principalcrítico das suas escolhas
  76. 76. Para saber mais:from functional import *
  77. 77. OBRIGADO! @gustavopinto gustavo@entropie.com.br

×