Slide 1

Slide 1 text

λ Imperative Vs

Slide 2

Slide 2 text

λ Imperative Vs > A style of building the structure and elements of computer programs, that treats computation as the evaluation of mathematical functions and avoids state and mutable data > A programming paradigm that describes computation in terms of statements that change a program state!

Slide 3

Slide 3 text

@raulraja 47 Nothing new under the sun… FP has been ignored for a while

Slide 4

Slide 4 text

- 1958 LISP - 1975 Scheme - 1984 Common LISP - 1986 Erlang - 1987 Caml - 2003 Scala - 2005 F# - 2007 Clojure History

Slide 5

Slide 5 text

λ Imperative Vs

Slide 6

Slide 6 text

λ Imperative Vs > Since 2002, we can only hold this true if we add extra cores. ! In order for today's developers to benefit from the speed increases Moore's Law offers, they need to take advantage of multicore processors ! Shit! Concurrency is hard! -Imperative Programming! ! Not hard! just make it immutable! - Functional Programming > The numbers of transistors on integrated circuits doubles approximately every two years, so your programs get faster without you doing any extra work - Moore’s Law! ! !Awesome - Imperative Programming!

Slide 7

Slide 7 text

λ Imperative Mutable Immutable State var article = new Article()! article.title = "9 Cards"! article.description = "Home Launcher"! …! article.title = "9 Cards by 47”! ! val a = Article(! ! title = "9 Cards",! ! description = "Home Launcher"! )! article.title = "9 Cards"! …! val b = a.copy(title = "9 Cards by 47”)! > Secure, Thread-Safe > Not Thread-Safe

Slide 8

Slide 8 text

λ Imperative Iteration and mutability Lambdas in Higher Order Functions HOF List n = new …! for (name : names) {! ! if (name.startsWith(value)) {! ! ! n.add(name)! ! }! }! ! val n = names filter (_ startsWith value)! > Simpler > Harder control flow

Slide 9

Slide 9 text

λ Imperative Task and State Definition / Lazyness Flow def fibo(n: Int): Int = {! if (n <= 1) {! return n! }! var fibo = 1! var fiboPrev = 1! for (i <- 2 until n) {! val temp = fibo! fibo += fiboPrev! fiboPrev = temp! }! fibo! } def fibo(in: Int): Int = in match {! case n if n <= 0 => 0! case 0 | 1 => 1! case n => fibo(n - 1) + fibo(n- 2)! }! ! … or …! ! def fib : Stream[Long] = {! def fibF(a: Long, b: Long) : Stream[Long] = ! ! a #:: fibF(b, a+b)! fibF(0, 1)! } > How to perform tasks (algorithms) and how to track changes in state. > Recursion and lazy structures

Slide 10

Slide 10 text

λ Imperative Statefull Stateless Flow def add(a: Int) = this.b = this.b + a def (a: Int, b : Int): Int = a + b > IO is necessary but others may be dangerous > A pure function does not change data outside of the function

Slide 11

Slide 11 text

Resources λ

Slide 12

Slide 12 text

Resources λ

Slide 13

Slide 13 text

Learn FP λ https://github.com/47deg/scala-crash-course-es Dia 1 - Conceptos Básicos (Martes 13 de Mayo) ! Breve introducción a la programación funcional en general y a Scala en particular y como las técnicas de programación funcional pueden ayudarte a ser más productivo como programador. Herramientas que se suelen utilizar y nuestro primer programa en Scala. ! Introducción (20m Teoría) Herramientas (20m Práctica) Sintaxis Básica (30m Teoría) Hello World (10 min Práctica)

Slide 14

Slide 14 text

Learn FP λ https://github.com/47deg/scala-crash-course-es Día 2 - Esenciales del día a día (Martes 27 de Mayo) ! Uso del pattern matching para la simplificación de decisiones y casos en el código, implícitos, opciones y colecciones (map, flatMap, match, implicit, Option, Try, Either) ! Pattern Matching (15m Teoría y Práctica) Errores y Opciones (30m Teoría y Práctica) Colecciones (45m Teoría y Práctica) Monads (30m Teoría y Práctica)

Slide 15

Slide 15 text

Learn FP λ https://github.com/47deg/scala-crash-course-es Día 3 - Asincronia y Concurrencia (Prog Reactiva) (Martes 10 de Junio) ! Haz que tus aplicaciones no bloqueen y se ejecuten en paralelo sacandole el maximo partido con técnicas de programación reactiva. ! Futuros y Promesas (1h Teoría y Práctica) Actores (1h Teoría y Práctica)

Slide 16

Slide 16 text

Learn FP λ https://github.com/47deg/scala-crash-course-es Dia 4 - Técnicas Funcionales Avanzadas (Martes 24 de Junio)! ! Una pequeña introducción a un mundo que hay por aprender si aun no sabes programación funcional ! Currying y Funciones Parciales (30m Teoría y Práctica) Funciones de Alto Orden (30m Teoría y Práctica) Type Classes (15m Teoría)

Slide 17

Slide 17 text

Learn FP λ https://github.com/47deg/scala-crash-course-es Día 5 - Micro Hackaton (Martes 1 de Julio) ! Una app reactiva con Play2 Scala mostrando algunos de los conceptos aprendidos en el curso. ! Anatomia de una App Play 2 (15m Teoria) App (2h Practica)