Top Banner
Porque aprender haskell me fez um programador python melhor? @gustavopinto [email protected]
103

Porque aprender haskell me fez um programador python melhor?

Jan 16, 2017

Download

Career

Gustavo Pinto
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Porque aprender haskell me fez um programador python melhor?

Porque aprender haskell me fez um programador

python melhor?

@[email protected]

Page 2: Porque aprender haskell me fez um programador python melhor?

Porque aprender haskell me fez um programador

python melhor?

@[email protected]

Baseado em fatos reais

Page 3: Porque aprender haskell me fez um programador python melhor?

Gustavo Pinto

2004 - belém, grad, php, sh2006 - amazontic, java, xp2008 - curitiba, msc, python2009 - aprioriti, xp, scrum2011 - recife, phd, haskell2012 - entropie, lean, scala

Page 4: Porque aprender haskell me fez um programador python melhor?

Belém

Page 5: Porque aprender haskell me fez um programador python melhor?

Belém

Page 6: Porque aprender haskell me fez um programador python melhor?

Belém

Page 7: Porque aprender haskell me fez um programador python melhor?

Belém

Page 8: Porque aprender haskell me fez um programador python melhor?

Belém

Page 9: Porque aprender haskell me fez um programador python melhor?

Belém

Page 10: Porque aprender haskell me fez um programador python melhor?

DISCLAIMER

Page 11: Porque aprender haskell me fez um programador python melhor?

Não tem código

Page 12: Porque aprender haskell me fez um programador python melhor?

Não tem código¬¬''

Page 13: Porque aprender haskell me fez um programador python melhor?

Mentira, tem mas épouquinho :-)

Page 14: Porque aprender haskell me fez um programador python melhor?
Page 15: Porque aprender haskell me fez um programador python melhor?
Page 16: Porque aprender haskell me fez um programador python melhor?

1912 ~ 1954

Page 17: Porque aprender haskell me fez um programador python melhor?

1912 ~ 19541936

Page 18: Porque aprender haskell me fez um programador python melhor?

1912 ~ 19541936

Page 19: Porque aprender haskell me fez um programador python melhor?

ON COMPUTABLE NUMBERS, WITH AN APPLICATION

TO THE ENTSCHEIDUNGS

PROBLEM

Page 20: Porque aprender haskell me fez um programador python melhor?

ON COMPUTABLE NUMBERS, WITH AN APPLICATION

TO THE ENTSCHEIDUNGS

PROBLEM

Page 21: Porque aprender haskell me fez um programador python melhor?

ON COMPUTABLE NUMBERS, WITH AN APPLICATION

TO THE DECISION PROBLEM

Page 22: Porque aprender haskell me fez um programador python melhor?
Page 23: Porque aprender haskell me fez um programador python melhor?
Page 24: Porque aprender haskell me fez um programador python melhor?
Page 25: Porque aprender haskell me fez um programador python melhor?
Page 26: Porque aprender haskell me fez um programador python melhor?
Page 27: Porque aprender haskell me fez um programador python melhor?

1903 ~1995

Page 28: Porque aprender haskell me fez um programador python melhor?

1903 ~19951936

Page 29: Porque aprender haskell me fez um programador python melhor?

1903 ~19951936

Page 30: Porque aprender haskell me fez um programador python melhor?

AN UNSOLVABLE PROBLEM OF ELEMENTARY

NUMBER THEORY

Page 31: Porque aprender haskell me fez um programador python melhor?
Page 32: Porque aprender haskell me fez um programador python melhor?
Page 33: Porque aprender haskell me fez um programador python melhor?

1936

Page 34: Porque aprender haskell me fez um programador python melhor?
Page 35: Porque aprender haskell me fez um programador python melhor?
Page 36: Porque aprender haskell me fez um programador python melhor?

1936

Page 37: Porque aprender haskell me fez um programador python melhor?

Church-Turing thesis

Page 38: Porque aprender haskell me fez um programador python melhor?

Church-Turing thesis

Page 39: Porque aprender haskell me fez um programador python melhor?

Church-Turing thesis

Equivalentes

Page 40: Porque aprender haskell me fez um programador python melhor?
Page 41: Porque aprender haskell me fez um programador python melhor?
Page 42: Porque aprender haskell me fez um programador python melhor?
Page 43: Porque aprender haskell me fez um programador python melhor?
Page 44: Porque aprender haskell me fez um programador python melhor?
Page 45: Porque aprender haskell me fez um programador python melhor?
Page 46: Porque aprender haskell me fez um programador python melhor?
Page 47: Porque aprender haskell me fez um programador python melhor?
Page 48: Porque aprender haskell me fez um programador python melhor?
Page 49: Porque aprender haskell me fez um programador python melhor?
Page 50: Porque aprender haskell me fez um programador python melhor?

Algumas features:

● Pure functions● Functions as first-class objects● No side effects

Page 51: Porque aprender haskell me fez um programador python melhor?

Algumas features:

● Pure functions● Functions as first-class objects● No side effects

Concurrency Friendly

Page 52: Porque aprender haskell me fez um programador python melhor?
Page 53: Porque aprender haskell me fez um programador python melhor?
Page 54: Porque aprender haskell me fez um programador python melhor?

Great.. But, what about Python??

Page 55: Porque aprender haskell me fez um programador python melhor?

Python functional

Page 56: Porque aprender haskell me fez um programador python melhor?

Is python functional?

Page 57: Porque aprender haskell me fez um programador python melhor?

Is python functional?

Page 58: Porque aprender haskell me fez um programador python melhor?

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 didn't 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

Page 59: Porque aprender haskell me fez um programador python melhor?

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 didn't 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

Page 60: Porque aprender haskell me fez um programador python melhor?

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 didn't 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

Page 61: Porque aprender haskell me fez um programador python melhor?

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 didn't 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

Page 62: Porque aprender haskell me fez um programador python melhor?

I see list and functions

Page 63: Porque aprender haskell me fez um programador python melhor?
Page 64: Porque aprender haskell me fez um programador python melhor?
Page 65: Porque aprender haskell me fez um programador python melhor?
Page 66: Porque aprender haskell me fez um programador python melhor?

hack, hack

if god exists: atepassar**2

Page 67: Porque aprender haskell me fez um programador python melhor?

search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element ==

element_f ] for element_f in e]

Page 68: Porque aprender haskell me fez um programador python melhor?

search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element ==

element_f ] for element_f in e]

Page 69: Porque aprender haskell me fez um programador python melhor?

List comprehensionA 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

Page 70: Porque aprender haskell me fez um programador python melhor?

List comprehensionA 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

Page 71: Porque aprender haskell me fez um programador python melhor?

List comprehensionA 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

Page 72: Porque aprender haskell me fez um programador python melhor?

List comprehensionA 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

Page 73: Porque aprender haskell me fez um programador python melhor?

List comprehensionA 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

Page 74: Porque aprender haskell me fez um programador python melhor?

List comprehensionA 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

Sou foda

Page 75: Porque aprender haskell me fez um programador python melhor?

search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element ==

element_f ] for element_f in e]

Page 76: Porque aprender haskell me fez um programador python melhor?

LambdaLambdas 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

Page 77: Porque aprender haskell me fez um programador python melhor?

LambdaLambdas 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

Page 78: Porque aprender haskell me fez um programador python melhor?

Lambda>>> lambda x: x % 2

http://learnyouahaskell.com/higher-order-functions#lambdas

Page 79: Porque aprender haskell me fez um programador python melhor?

Lambda>>> is_even = lambda x: x % 2

http://learnyouahaskell.com/higher-order-functions#lambdas

Page 80: Porque aprender haskell me fez um programador python melhor?

Lambda>>> is_even = lambda x: x % 2>>> is_even<function <lambda> at 0x2a3d050>

http://learnyouahaskell.com/higher-order-functions#lambdas

Page 81: Porque aprender haskell me fez um programador python melhor?

search_list = lambda l,e : [ [ idx for idx, element in enumerate(l) if element ==

element_f ] for element_f in e]

Page 82: Porque aprender haskell me fez um programador python melhor?

Built-in Functions>>> for mes in enumerate (['jan', 'fev', 'mar']):... print mes(0, 'jan')(1, 'fev')(2, 'mar')

Page 83: Porque aprender haskell me fez um programador python melhor?

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

Page 84: Porque aprender haskell me fez um programador python melhor?

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

Funções de alta ordem

Page 85: Porque aprender haskell me fez um programador python melhor?

Filterfilter(...)

filter(function or None, sequence) -> list, tuple or string

Return those items of sequence for which function(item) is true. [....]

>>> filter(lambda x: x % 2 == 0, range(10))

Page 86: Porque aprender haskell me fez um programador python melhor?

Filterfilter(...)

filter(function or None, sequence) -> list, tuple or string

Return those items of sequence for which function(item) is true. [....]

>>> is_even = lambda x: x % 2 == 0>>> filter(is_even, range(10))

Page 87: Porque aprender haskell me fez um programador python melhor?

Mapmap(...)

map(function, sequence[, sequence, ...]) -> list

Return a list of the results of applying the function to the items of the argument sequence(s). [....]

>>> map(lambda s: s.upper(), ['a', 'b', 'c'])

Page 88: Porque aprender haskell me fez um programador python melhor?

Reducereduce(...)

reduce(function, sequence[, initial]) -> value

Apply a function of two arguments cumulatively to the items of a sequence, from left to right, so as to reduce the sequence to a single value. [....]

>>> reduce(lambda x,y: x * y, range(1, 4))>>> reduce(lambda x, y: x + y, ['a', 'b', 'c', 'd'])

Page 89: Porque aprender haskell me fez um programador python melhor?

Sua High Order Functiondef f(x):

return x + 1

def g(function, x):return function(x) + function (x + 1)

print g(f, 1)

Page 90: Porque aprender haskell me fez um programador python melhor?

Sua High Order Functiondef f(x):

return x + 1

def g(function, x):return function(x) + function (x + 1)

print g(f, 1)

not bad

Page 91: Porque aprender haskell me fez um programador python melhor?

Porque aprender haskell me fez um programador

python melhor?

Page 92: Porque aprender haskell me fez um programador python melhor?

Consegui entendermelhor o

código do Marcel!

Page 93: Porque aprender haskell me fez um programador python melhor?

Consegui entender melhor o código

de outras pessoas!

Page 94: Porque aprender haskell me fez um programador python melhor?

Consegui entender melhor a minha

linguagem!

Page 95: Porque aprender haskell me fez um programador python melhor?

Consegui entender melhor o meu

framework!

Page 96: Porque aprender haskell me fez um programador python melhor?

Resumindo

Page 97: Porque aprender haskell me fez um programador python melhor?

Domine sua linguagem

Page 98: Porque aprender haskell me fez um programador python melhor?

Evolua com a sua linguagem

Page 99: Porque aprender haskell me fez um programador python melhor?

Domine outras linguagens(Tanto quanto)

Page 100: Porque aprender haskell me fez um programador python melhor?

Entenda que linguagens são

escolhas

Page 101: Porque aprender haskell me fez um programador python melhor?

Seja o principal crítico das suas

escolhas

Page 102: Porque aprender haskell me fez um programador python melhor?

Para saber mais:

from functional import *

Page 103: Porque aprender haskell me fez um programador python melhor?

OBRIGADO!

@[email protected]