O futuro chegou: Programação concorrente com futures LEONARDO BORGES SENIOR CLOJURE
|
|
- Donald Malone
- 6 years ago
- Views:
Transcription
1 O futuro chegou: Programação concorrente com futures LEONARDO BORGES SENIOR CLOJURE
2 SOBRE Um pouco sobre mim Senior Clojure Engineer na Atlassian, Sydney Fundador do Grupo de Usuários Clojure de Sydney Autor de Clojure Reactive Programming - * QCon discount code: CRP10
3 O quê? FUTURES CONCORRÊNCIA ABSTRAÇÃO COMPOSIÇÃO
4 Futures em Java <= 1.7
5 FUTURES EM JAVA <= 1.7 static ExecutorService es = Executors.newCachedThreadPool(); static Integer doubler(integer n) { return 2 * n; } static Future<Integer> servicea(integer n) { return es.submit(() -> { Thread.sleep(1000); return n; }); } static Future<Integer> serviceb(integer n) { return es.submit(() -> { Thread.sleep(1500); return Double.valueOf(Math.pow(n, 2)).intValue(); }); } static Future<Integer> servicec(integer n) { return es.submit(() -> { Thread.sleep(2000); return Double.valueOf(Math.pow(n, 3)).intValue(); }); }
6 FUTURES EM JAVA <= 1.7 Bloqueia a thread Integer doubled = doubler(servicea(10).get()); System.out.println("Couldn't do anything else while the line above was being executed..."); System.out.println("Result: " + serviceb(doubled).get() + " - " + servicec(doubled).get()); Bloqueia a thread Bloqueia a thread
7 Problemas Desperdício de processamento
8 Problemas Desperdício de processamento Baixo nível de composição
9 E no Java 8?
10 FUTURES NO JAVA 8 final CompletableFuture<Integer> doubled = servicea(10).thenapply(completablefutures::doubler); final CompletableFuture<Integer> resultb = doubled.thencompose(completablefutures::serviceb); final CompletableFuture<Integer> resultc = doubled.thencompose(completablefutures::servicec); CompletableFuture<Void> allfutures = CompletableFuture.allOf(resultB, resultc); allfutures.whencomplete((v, ex) -> { try { System.out.println("Result: " + resultb.get() + " - " + resultc.get()); } catch (Exception e) {} }); System.out.println("Doing other important things...");
11 FUTURES NO JAVA 8 final CompletableFuture<Integer> doubled = servicea(10).thenapply(completablefutures::doubler); final CompletableFuture<Integer> resultb = doubled.thencompose(completablefutures::serviceb); final CompletableFuture<Integer> resultc = doubled.thencompose(completablefutures::servicec); CompletableFuture<Void> allfutures = CompletableFuture.allOf(resultB, resultc); allfutures.whencomplete((v, ex) -> { try { System.out.println("Result: " + resultb.get() + " - " + resultc.get()); } catch (Exception e) {} }); System.out.println("Doing other important things..."); Não bloqueia a thread
12 Esses combinadores são familiares?
13 STREAMS NO JAVA 8 List<Integer> ns = Arrays.asList(1, 2, 3, 4); Function<Integer, Integer> doubler = (i) -> i * 2; System.out.println(ns.stream().map(doubler).collect(Collectors.toList())); // [2, 4, 6, 8] Function<Integer, Stream<? extends Integer>> torange = (i) -> IntStream.range(0, i).boxed(); Stream<Integer> combined = ns.stream().map(doubler).flatmap(torange); System.out.println(combined.collect(Collectors.toList())); // [0, 1, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7]
14 Streams vs Futures Stream<R> map(function<? super T,? extends R> mapper) { } Stream<R> flatmap(function<? super T,? extends Stream<? extends R>> mapper) { } CompletableFuture<U> thenapply(function<? super T,? extends U> fn) { } CompletableFuture<U> thencompose(function<? super T,? extends CompletionStage<U>> fn) { }
15 Streams vs Futures Stream<R> map(function<? super T,? extends R> mapper) { } Stream<R> flatmap(function<? super T,? extends Stream<? extends R>> mapper) { } CompletableFuture<U> thenapply (Function<? super T,? extends U> fn) { } CompletableFuture<U> thencompose(function<? super T,? extends CompletionStage<U>> fn) { }
16 E se quisermos escrever funções que funcionem com Streams e Futures?
17 SEQUENCING FUTURES CompletableFuture<Collection<Integer>> result = // java.util.concurrent.completablefuture[10, 100, 1000] sequence(servicea(10), serviceb(10), servicec(10));
18 SEQUENCING FUTURES static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); }
19 SEQUENCING FUTURES static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); }
20 SEQUENCING FUTURES static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); }
21 SEQUENCING FUTURES static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); }
22 SEQUENCING FUTURES static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); }
23 SEQUENCING STREAMS Stream<Integer> s1 = Arrays.asList(1).stream(); Stream<Integer> s2 = Arrays.asList(2).stream(); Stream<Integer> s3 = Arrays.asList(3).stream(); sequences(s1, s2, s3) // [[1, 2, 3]]
24 SEQUENCING STREAMS static <A> Stream<Stream<A>> sequences(stream<a>... cfs) { return Arrays.asList(cfs).stream().reduce( Stream.of(Stream.empty()), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, Stream.of(x)))), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, x)))); }
25 SEQUENCING STREAMS static <A> Stream<Stream<A>> sequences(stream<a>... cfs) { return Arrays.asList(cfs).stream().reduce( Stream.of(Stream.empty()), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, Stream.of(x)))), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, x)))); }
26 SEQUENCING STREAMS static <A> Stream<Stream<A>> sequences(stream<a>... cfs) { return Arrays.asList(cfs).stream().reduce( Stream.of(Stream.empty()), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, Stream.of(x)))), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, x)))); }
27 SEQUENCING STREAMS static <A> Stream<Stream<A>> sequences(stream<a>... cfs) { return Arrays.asList(cfs).stream().reduce( Stream.of(Stream.empty()), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, Stream.of(x)))), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, x)))); }
28 Perceberam alguma semelhança?
29 FUTURES VS STREAMS static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); } static <A> Stream<Stream<A>> sequences(stream<a>... cfs) { return Arrays.asList(cfs).stream().reduce( Stream.of(Stream.empty()), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, Stream.of(x)))), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, x)))); }
30 FUTURES VS STREAMS static <A> CompletableFuture<Collection<A>> sequence(completablefuture<a>... cfs) { return Arrays.asList(cfs).stream().reduce( CompletableFuture.completedFuture(new ArrayList<>()), (acc, future) -> acc.thencompose((xs) -> future.thenapply((x) -> { xs.add(x); return xs; })), (a, b) -> a.thencompose((xs) -> b.thenapply((ys) -> { xs.addall(ys); return xs; }))); } static <A> Stream<Stream<A>> sequences(stream<a>... cfs) { return Arrays.asList(cfs).stream().reduce( Stream.of(Stream.empty()), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, Stream.of(x)))), (acc, coll) -> acc.flatmap((xs) -> coll.map((x) -> Stream.concat(xs, x)))); }
31 FlatMappable
32 FLATMAPPABLE <M extends FlatMappable, A> M<List<A>> sequence(m<a>... ma) { }
33 Chegando no limite do sistema de tipos Java não suporta tipos de alta espécie (higher kinded types) Tipos de alta espécie são indispensáveis ao se implementar tais abstrações
34 Colocando nome nos bois
35 FlatMappable se chama Monad trait Monad[F[_]] { def point[a](a: => A): F[A] def bind[a, B](a: F[A])(f: A => F[B]): F[B] def map[a, B](a: F[A])(f: A => B): F[B] = bind(a)(b => point(f(b))) }
36 FlatMappable se chama Monad trait Monad[F[_]] { Tipos de alta espécie em ação def point[a](a: => A): F[A] def bind[a, B](a: F[A])(f: A => F[B]): F[B] def map[a, B](a: F[A])(f: A => B): F[B] = bind(a)(b => point(f(b))) }
37 MONADS EM SCALA O Monad de Futures implicit def FutureMonad: Monad[Future] = new Monad[Future] { def point[a](a: => A) = Future.successful(a) } def bind[a, B](a: Future[A])(f: A => Future[B]): Future[B] = a flatmap f
38 MONADS EM SCALA O Monad de Listas implicit def ListMonad: Monad[List] = new Monad[List] { def point[a](a: => A) = List(a) def bind[a, B](a: List[A])(f: A => List[B]): List[B] = a flatmap f }
39 MONADS EM SCALA Implementando sequence def sequence[m[_] : Monad, A](ma: List[M[A]]): M[List[A]] = { ma.foldleft(monad[m].point(list(): List[A]))((acc, m) => acc.flatmap((xs) => m.map((x) => xs :+ x)) ) }
40 Being abstract is something profoundly different from being vague The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise. EDSGER W. DIJKSTRA
41 MONADS EM SCALA Sequencing val resultf: Future[List[Integer]] = sequence(list(servicea(10), serviceb(10), servicec(10))) println(await.result(resultf, Duration(2, "seconds"))) // List(10, 100, 1000) val resultl: List[List[Int]] = sequence(list(list(1,2,3), List(4,5,6), List(7,8,9))) println(resultl) // List(List(1, 4, 7), List(2, 4, 7), List(3, 4, 7), List(1, 5, 7),...)
42 Demais! O quê mais podemos fazer??
43 Folding
44 FOLDING List(2, 3, 4).reduce(_+_) //9
45 FOLDING List(2, 3, 4).reduce(_+_) //9 val intfutures = List(Future.successful(1), Future.successful(2), Future.successful(3)) val result: Future[Int] = sequence(intfurures).map((x) => x.reduce(_ + _)) // Future[9]
46 Existe algo em comum?
47 Introduzindo Foldable trait Foldable[F[_]] { self => def fold[m: Monoid](t: F[M]): M =??? }
48 Introduzindo Monoids trait Monoid[F] { self => def zero: F def append(f1: F, f2: => F): F }
49 Introduzindo Monoids: Ints implicit def intmonoid: Monoid[Int] = new Monoid[Int] { def zero: Int = 0 def append(f1: Int, f2: => Int): Int = f1 + f2 }
50 Introduzindo Monoids: Ints implicit def intmonoid: Monoid[Int] = new Monoid[Int] { def zero: Int = 0 def append(f1: Int, f2: => Int): Int = f1 + f2 } Foldable[List].fold(List(2, 3, 4))) //9
51 Introduzindo Monoids: Futures
52 Introduzindo Monoids: Futures implicit def futurefreemonoid[a] = new Monoid[Future[List[A]]] { def zero: Future[List[A]] = Future.successful(List()) def append(f1: Future[List[A]], f2: => Future[List[A]]) = for { a1 <- f1 a2 <- f2 } yield a1 ++ a2 }
53 Introduzindo Monoids: Futures implicit def futurefreemonoid[a] = new Monoid[Future[List[A]]] { def zero: Future[List[A]] = Future.successful(List()) def append(f1: Future[List[A]], f2: => Future[List[A]]) = for { a1 <- f1 a2 <- f2 } yield a1 ++ a2 } Foldable[List].fold(List(Future.successful(2), Future.successful(3), Future.successful(4))) // Future[9]
54 Monad, Foldable e Monoid são apenas o começo
55 Em Scala, muitas delas já foram implementadas em Scalaz
56 A Teoria das Categorias pode ter um impacto grande na criação de bibliotecas
57 Being abstract is something profoundly different from being vague The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise. EDSGER W. DIJKSTRA
58 Referências Clojure Reactive Programming - Java 8 CompletableFuture - Java 8 Streams - Category Theory - Free Monoids - Scalaz - Fluokitten (Clojure) -
59 Obrigado! Q&A LEONARDO BORGES SENIOR CLOJURE
60 We are hiring! LEONARDO BORGES SENIOR CLOJURE
Completable Future. Srinivasan Raghavan Senior Member of Technical Staff Java Platform Group
Completable Future Srinivasan Raghavan Senior Member of Technical Staff Java Platform Group Program Agenda 1 2 3 4 java.util.future Introduction Cloud Services Design and the fight for Performance CompletableFuture
More informationOverview of Advanced Java 8 CompletableFuture Features (Part 2)
Overview of Advanced Java 8 CompletableFuture Features (Part 2) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated
More informationIntroduction to Type Driven Development in Scala
Introduction to Type Driven Development in Scala Marcus A. Henry, Jr. @dreadedsoftware Software Engineer @integrichain 1 def f(a: Int, b: Int): String = { a.tostring + b.tostring This is a function 2 def
More informationCompositional I/Ο Streams in Scala. Rúnar Bjarnason, Verizon QCon London, March 2016
Compositional I/Ο Streams in Scala Rúnar Bjarnason, Verizon Labs @runarorama QCon London, March 2016 Scalaz-Stream (FS2) Functional Streams for Scala github.com/functional-streams-for-scala Disclaimer
More informationUsing Java CompletionStage in Asynchronous Programming
Using Java CompletionStage in Asynchronous Programming DEV4798 Douglas Surber Oracle Database JDBC Architect Database Server Technologies October 25, 2018 Safe Harbor Statement The following is intended
More informationMONIX TASK LAZY, ASYNC & AWESOME. Alexandru Nedelcu. Software / alexn.org
LAZY, ASYNC & AWESOME Alexandru Nedelcu Software Developer @ eloquentix.com @alexelcu / alexn.org WHAT IS MONIX? Scala / Scala.js library For composing asynchronous programs Exposes Observable & Task Typelevel
More informationINSTRUCTIONS TO CANDIDATES
NATIONAL UNIVERSITY OF SINGAPORE SCHOOL OF COMPUTING FINAL ASSESSMENT FOR Semester 1 AY2017/2018 CS2030 Programming Methodology II November 2017 Time Allowed 2 Hours INSTRUCTIONS TO CANDIDATES 1. This
More informationThe First Monad Tutorial
The First Monad Tutorial Philip Wadler University of Edinburgh YOW! Melbourne, Brisbane, Sydney December 2013 The Term type trait Term case class Con(a: Int) extends Term case class Div(t:
More informationCSE341 Section 3. Standard-Library Docs, First-Class Functions, & More
CSE341 Section 3 Standard-Library Docs, First-Class Functions, & More Adapted from slides by Daniel Snitkovskiy, Nick Mooney, Nicholas Shahan, Patrick Larson, and Dan Grossman Agenda 1. SML Docs Standard
More informationRefactoring mit monadischen Transaktionen. In Java
Refactoring mit monadischen Transaktionen In Java Refactoring towards monadic transactions In Java Gregor Trefs 32 years old Senior software engineer Organizer of @majug Founder of @swkrheinneckar twitter/github:
More informationOverview. Elements of Programming Languages. Advanced constructs. Motivating inner class example
Overview Elements of Programming Languages Lecture 11: Object-oriented functional programming James Cheney University of Edinburgh October 30, 2017 We ve now covered: basics of functional programming (with
More informationEssential Scala. Six Core Concepts for Learning Scala Noel underscore
Essential Scala Six Core Concepts for Learning Scala Noel Welsh, @noelwelsh underscore Introduction Overview 1. Expressions, types, & values 2. Objects and classes 3. Algebraic data types 4. Structural
More informationExperiences with Scala Across the College-Level Curriculum
Loyola University Chicago Loyola ecommons Emerging Technologies Laboratory Publications Computer Science: Faculty Publications and Other Works 4-21-2017 Experiences with Scala Across the College-Level
More informationPrograms as Values Pure Functional Database Access in Scala
Programs as Values Pure Functional Database Access in Scala Rob Norris Gemini Observatory Programs as Values Pure Functional Database Access in Scala Rob Norris Gemini Observatory What's this about? This
More informationInstituto Superior Técnico. First Exam 7/6/2013. Number:
Instituto Superior Técnico Programação Avançada First Exam 7/6/2013 Name: Number: Write your number on every page. Your answers should not be longer than the available space. You can use the other side
More informationQuerying Microsoft SQL Server 2014 (20461)
Querying Microsoft SQL Server 2014 (20461) Formato do curso: Presencial e Live Training Localidade: Lisboa Com certificação: MCSA: SQL Server Data: 14 Nov. 2016 a 25 Nov. 2016 Preço: 1630 Promoção: -760
More informationAsynchronous API with CompletableFuture
Asynchronous API with CompletableFuture Performance Tips and Tricks Sergey Kuksenko Java Platform Group, Oracle November, 2017 Safe Harbor Statement The following is intended to outline our general product
More informationSharePoint 2013 Site Collection and Site Administration (55033)
SharePoint 2013 Site Collection and Site Administration (55033) Formato do curso: Presencial Preço: 1740 Nível: Intermédio Duração: 35 horas Este curso de 5 dias, É destinado a utilizadores avançados de
More informationCS Programming Languages: Scala
CS 3101-2 - Programming Languages: Scala Lecture 6: Actors and Concurrency Daniel Bauer (bauer@cs.columbia.edu) December 3, 2014 Daniel Bauer CS3101-2 Scala - 06 - Actors and Concurrency 1/19 1 Actors
More informationPurely Functional I/O in Scala
Purely Functional I/O in Scala Rúnar Óli Bjarnason @runarorama Scala.IO, Paris 2013 What you should take away from this talk You do not need side-effects to do I/O. Purely functional I/O really is pure.
More informationDomain Specific Languages - a user view and an implementation view. does expressiveness imply a compromise on the underlying domain model?
Domain Specific Languages - a user view and an implementation view does expressiveness imply a compromise on the underlying domain model? Debasish Ghosh @debasishg on twitter Code @ http://github.com/debasishg
More informationFunctional Programming in Scala by Paul Chiusana Rúnar Bjarnason
SAMPLE CHAPTER Functional Programming in Scala by Paul Chiusana Rúnar Bjarnason Chapter 10 Copyright 2014 Manning Publications brief contents PART 1 INTRODUCTION TO FUNCTIONAL PROGRAMMING...1 1 What is
More informationThose classes I never wrote. The power of recursion schemes applied to data engineering
Those 10000 classes I never wrote The power of recursion schemes applied to data engineering 1 greetings The name s Valentin (@ValentinKasas) Organizer of the Paris Scala User Group Member of the ScalaIO
More informationEnabling and Managing Office 365 (20347)
Enabling and Managing Office 365 (20347) Formato do curso: Presencial Preço: 1670 Nível: Iniciado Duração: 35 horas Este curso permite aos formandos adquirir conhecimentos na avaliação, planificação, implementação
More informationFunctional Programming
Functional Programming Midterm Solution Friday, November 6 2015 Exercise 1: List functions (10 points) You are asked to implement the following List functions using only the specified List API methods.
More informationEXAM PREPARATION SECTION 10
EXAM PREPARATION SECTION 10 SQL, ITERATORS AND GENERATORS April 25 to April 26, 2018 1 Iterators and Generators 1. Lazy Sunday (Fa14 Final Q4a) A flat-map operation maps a function over a sequence and
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And
More informationTypes Working For You
Types Working For You Richard Dallaway, @d6y underscore.io Modern type system with lots of power Two Themes Straightforward Scala Types Working for Us Progression Part 1 Straightforward Scala Part 2
More informationLearn Sphinx Documentation Documentation
Learn Sphinx Documentation Documentation Release 0.0.1 Lucas Simon Rodrigues Magalhaes January 31, 2014 Contents 1 Negrito e italico 1 2 Listas 3 3 Titulos 5 4 H1 Titulo 7 4.1 H2 Sub-Titulo.............................................
More informationFinal Concurrency. Oleg October 27, 2014
Final Concurrency Oleg Šelajev @shelajev oleg@zeroturnaround.com October 27, 2014 Feedbacks Task Executors Fork-Join framework Completable Future Agenda 2 HOMEWORK 4 FEEDBACK THREAD LOCAL VARIABLES TASK
More informationOCaml Language Choices CMSC 330: Organization of Programming Languages
OCaml Language Choices CMSC 330: Organization of Programming Languages! Implicit or explicit declarations?! Explicit variables must be introduced with let before use! But you don t need to specify types
More informationSide-effect checking for Scala. Lukas Rytz, Martin Odersky, Adriaan Moors Scala Days 2011
Side-effect checking for Scala Lukas Rytz, Martin Odersky, Adriaan Moors Scala Days 2011 Why effect checking? We have at least one post a week where the correct answer is wholly or in part, effect system.
More information301AA - Advanced Programming
301AA - Advanced Programming Lecturer: Andrea Corradini andrea@di.unipi.it h;p://pages.di.unipi.it/corradini/ Course pages: h;p://pages.di.unipi.it/corradini/dida@ca/ap-18/ AP-2018-23: Streams in Java
More informationExercise 1: Graph coloring (10 points)
Exercise 1: Graph coloring (10 points) Graph coloring is the problem of assigning colors to vertices in a non-directed graph, so that no two adjacent nodes have the same color. In other words, if two vertices
More informationIntrodução e boas práticas em UX Design (Portuguese Edition)
Introdução e boas práticas em UX Design (Portuguese Edition) By Fabricio Teixeira Introdução e boas práticas em UX Design (Portuguese Edition) By Fabricio Teixeira Cada vez mais o desenvolvimento do front-end
More informationan overview Alceste Scalas Programming languages reading group
an overview Alceste Scalas Programming languages reading group 31 October 2017 Scala: what s the hype about? Object oriented and functional programming language Runs on the JVM... interoperability with
More informationAsynchronous API with CompletableFuture
Asynchronous API with CompletableFuture Performance Tips and Tricks Sergey Kuksenko Java Platform Group, Oracle October, 2017 Safe Harbor Statement The following is intended to outline our general product
More informationMastering Advanced Scala
Mastering Advanced Scala Exploring the deep end of functional programming Denis Kalinin This book is for sale at http://leanpub.com/mastering-advanced-scala This version was published on 2017-10-08 This
More informationProgramming Principles
Programming Principles Final Exam Wednesday, December 18th 2013 First Name: Last Name: Your points are precious, don t let them go to waste! Your Name Work that can t be attributed to you is lost: write
More informationIntroduction to Spark
Introduction to Spark Outlines A brief history of Spark Programming with RDDs Transformations Actions A brief history Limitations of MapReduce MapReduce use cases showed two major limitations: Difficulty
More informationSistemas Distribuídos com Redes de Sensores. Noemi Rodriguez
2012 TinyOS SO para motes com recursos limitados aplicação única bateria deve ter vida longa memória muito limitada Exemplo: micaz Atmel ATmega128: microcontrolador de 8 bits 4K memória RAM 128K memória
More informationPrinciples of Programming Languages
Principles of Programming Languages h"p://www.di.unipi.it/~andrea/dida2ca/plp- 15/ Prof. Andrea Corradini Department of Computer Science, Pisa Lesson 30 Java 8! Lambdas and streams in Java 8 1 Java 8:
More informationFunctional Programming
Functional Programming Final Exam Friday, December 18 2015 First Name: Last Name: Your points are precious, don t let them go to waste! Your Name Work that can t be attributed to you is lost: write your
More informationby Mario Fusco Monadic
by Mario Fusco mario.fusco@gmail.com twitter: @mariofusco Monadic Imperative languages Java C# C / C++ Fortran Add abstractions Scala Subtract abstractions F# Hybrid languages Lisp Algol Haskell ML Functional
More informationPython Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY
Python Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY PyCon Korea 2017 Kim Sol kstreee@gmail.com Python Asynchronous Programming with Salt Stack (tornado, asyncio) and RxPY Kim Sol
More informationAxiomatic Rules. Lecture 18: Axiomatic Semantics & Type Safety. Correctness using Axioms & Rules. Axiomatic Rules. Steps in Proof
Lecture 18: Axiomatic Semantics & Type Safety CSCI 131 Fall, 2011 Kim Bruce Axiomatic Rules Assignment axiom: - {P [expression / id]} id := expression {P} - Ex: {a+47 > 0} x := a+47 {x > 0} - {x > 1} x
More informationCSci 4223 Lecture 12 March 4, 2013 Topics: Lexical scope, dynamic scope, closures
CSci 4223 Lecture 12 March 4, 2013 Topics: Lexical scope, dynamic scope, closures 1 Lexical Scope SML, and nearly all modern languages, follow the Rule of Lexical Scope: the body of a function is evaluated
More informationCSE Lecture 7: Polymorphism and generics 16 September Nate Nystrom UTA
CSE 3302 Lecture 7: Polymorphism and generics 16 September 2010 Nate Nystrom UTA 2 Polymorphism poly = many morph = shape Allow a variable to contain values with different types 3 Subtype polymorphism
More informationParallel Operations on Collections. Parallel Programming in Scala Viktor Kuncak
Parallel Operations on Collections Parallel Programming in Scala Viktor Kuncak Parallelism and collections Parallel processing of collections is important one the main applications of parallelism today
More informationMicrosoft SharePont Server 2013 for the Site Owner/Power User (55035)
Microsoft SharePont Server 2013 for the Site Owner/Power User (55035) Formato do curso: Presencial Preço: 860 Nível: Intermédio Duração: 14 horas Este curso de 3 dias, é destinado a utilizadores avançados
More informationThe Rise and Rise of Dataflow in the JavaVerse
The Rise and Rise of Dataflow in the JavaVerse @russel_winder russel@winder.org.uk https://www.russel.org.uk 1 The Plan for the Session Stuff. More stuff. Even more stuff possibly. Summary and conclusions
More informationScala - Some essential concepts -
Scala - Some essential concepts - Marcel Lüthi Graphics and Vision Research Group Department of Mathematics and Computer Science University of Basel Programming an important activity Data preprocessing
More informationFunctional Architecture:
Functional Architecture: an Experience Report JED WESLEY-SMITH @JEDWS scala because jvm scala/fp many teams now using Scala no longer particularly controversial, mostly Scala is not very good for product
More informationZte mf667 driver win8. Zte mf667 driver win8.zip
Zte mf667 driver win8 Zte mf667 driver win8.zip Download ZTE MF627 Driver (Windows) (For WIN 8) Download Huawei Driver for Dongle / Modem Download Huawei E155XUpdate 11.608.13.02.00.B418 (14.31 MB) ZTE
More informationCSCI 3155: Homework Assignment 3
CSCI 3155: Homework Assignment 3 Spring 2012: Due Monday, February 27, 2012 Like last time, find a partner. You will work on this assignment in pairs. However, note that each student needs to submit a
More informationsrc docs Release Author
src docs Release 0.8.18 Author September 20, 2018 Contents 1 networkapiclient package 3 1.1 Submodules............................................... 3 1.2 networkapiclient.ambiente module...................................
More informationMore Examples. Lecture 24: More Scala. Higher-Order Functions. Control Structures
More Examples Lecture 24: More Scala CSC 131 Fall, 2014 Kim Bruce MyList, MyArrayList, SinglyLinkedList - Val vs var - Can create Array[T] (unlike Java), though need implicit ClassManifest - foreach(f)
More informationINTERFACES IN JAVA. Prof. Chris Jermaine
INTERFACES IN JAVA Prof. Chris Jermaine cmj4@cs.rice.edu 1 Now On To Interfaces in Java Java gives the ability to declare an interface Like a, except: Can t declare any member variables (well, you can,
More informationFirst Exam/Second Test 19/6/2010
Instituto Superior Técnico Programação Avançada First Exam/Second Test 19/6/2010 Name: Number: Write your number on every page. Your answers should not be longer than the available space. You can use the
More informationPractically Functional. Daniel Spiewak
Practically Functional Daniel Spiewak whoami Author of Scala for Java Refugees and other articles on Scala and FP Former editor Javalobby / EclipseZone Engaged in academic research involving Scala DSLs
More informationRepensando Templates com Cryml. Dalton Pinto
Repensando Templates com Cryml Dalton Pinto 1 Dalton Pinto 2 3 4 5 Motivação 6 # partial: _file_or_folder.html.erb
More informationA Formal Model for Direct-style Asynchronous Observables
A Formal Model for Direct-style Asynchronous Observables Philipp Haller! KTH Royal Institute of Technology, Sweden!! Heather Miller! EPFL, Switzerland!! 27th Nordic Workshop on Programming Theory (NWPT)!
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative
More informationCompSci 220. Programming Methodology 12: Functional Data Structures
CompSci 220 Programming Methodology 12: Functional Data Structures A Polymorphic Higher- Order Function def findfirst[a](as: Array[A], p: A => Boolean): Int = { def loop(n: Int): Int = if (n >= as.length)
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 10a Andrew Tolmach Portland State University 1994-2017 Object-oriented Programming Programs are structured in terms of objects: collections of variables
More informationGenerics: Past, Present and Future
Generics: Past, Present and Future @richardwarburto insightfullogic.com @raouluk cambridgecoding.com binarysearch(list
More informationCSCI 2041: Lazy Evaluation
CSCI 2041: Lazy Evaluation Chris Kauffman Last Updated: Wed Dec 5 12:32:32 CST 2018 1 Logistics Reading Module Lazy on lazy evaluation Module Stream on streams Lambdas/Closures Briefly discuss these as
More information// Body of shortestlists starts here y flatmap { case Nil => Nil case x :: xs => findshortest(list(x), xs)
8 Shortest-strings Problem: Partial-Solution Dump Drew McDermott drew.mcdermott@yale.edu Lecture notes for 2016-09-19, revised 20016-09-25 Here is the state of play in solving the little puzzle about finding
More informationCSCI-GA Final Exam
CSCI-GA 2110-003 - Final Exam Instructor: Thomas Wies Name: Sample Solution ID: You have 110 minutes time. There are 7 assignments and you can reach 110 points in total. You can solve the exercises directly
More informationCPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia
CPL 2016, week 10 Clojure functional core Oleg Batrashev Institute of Computer Science, Tartu, Estonia April 11, 2016 Overview Today Clojure language core Next weeks Immutable data structures Clojure simple
More informationCSE431 Translation of Computer Languages
CSE431 Translation of Computer Languages Semantic Analysis Doug Shook Control Structure Analysis Three major phases for Java: Type Checking How might this apply to control structures? Reachability Analysis
More informationAcelerando a Manada. Parallel Queries no PostgreSQL
Acelerando a Manada Parallel Queries no PostgreSQL Paralelismo Intra-Consulta em PostgreSQL pré 9.6 Paralelismo Intra-Consulta - Requisitos Apresenta maiores ganhos em grandes volumes (Pode não encaixar
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 6a Andrew Tolmach Portland State University 1994-2016 Functional Programming An alternative paradigm to imperative programming First-class functions Emphasis
More informationScala Actors. Scalable Multithreading on the JVM. Philipp Haller. Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland
Scala Actors Scalable Multithreading on the JVM Philipp Haller Ph.D. candidate Programming Methods Lab EPFL, Lausanne, Switzerland The free lunch is over! Software is concurrent Interactive applications
More informationYou ve encountered other ways of signalling errors. For example, if you lookup an unbound key in a hashtable, Java (and Scala) produce nulls:
Lecture 5 1 Required Reading Read Chapters 16 and 17 of Programming in Scala. 2 Partial Functions and Signalling Errors Many functions are not defined on all inputs. For example, if you re reading input
More informationNADABAS and its Environment
MZ:2011:02 NADABAS and its Environment Report from a remote mission to the National Statistical Institute of Mozambique, Maputo Mozambique 8 March - 1 April 2011 within the frame work of the AGREEMENT
More informationProperty Based Testing : Shrinking Risk In Your Code. Amanda Pariveda Solutions Consultant Mined Minds Co-Founder
Property Based Testing : Shrinking Risk In Your Code Amanda Laucher @pandamonial Pariveda Solutions Consultant Mined Minds Co-Founder What is Property Based Testing? Patterns for specifying properties
More informationCompile-Time Code Generation for Embedded Data-Intensive Query Languages
Compile-Time Code Generation for Embedded Data-Intensive Query Languages Leonidas Fegaras University of Texas at Arlington http://lambda.uta.edu/ Outline Emerging DISC (Data-Intensive Scalable Computing)
More informationBuilding a Modular Static Analysis Framework in Scala (Tool Paper)
Building a Modular Static Analysis Framework in Scala (Tool Paper) Quentin Stiévenart Jens Nicolay Wolfgang De Meuter Coen De Roover Vrije Universiteit Brussel, Belgium {qstieven,jnicolay,wdmeuter,cderoove}@vub.ac.be
More informationCSE341: Programming Languages Lecture 9 Function-Closure Idioms. Dan Grossman Winter 2013
CSE341: Programming Languages Lecture 9 Function-Closure Idioms Dan Grossman Winter 2013 More idioms We know the rule for lexical scope and function closures Now what is it good for A partial but wide-ranging
More informationPhilipp Wille. Beyond Scala s Standard Library
Scala Enthusiasts BS Philipp Wille Beyond Scala s Standard Library OO or Functional Programming? Martin Odersky: Systems should be composed from modules. Modules should be simple parts that can be combined
More informationGenerics: Past, Present
Generics: Past, Present and Future @richardwarburto @raouluk binarysearch(list
More informationApplied Unified Ownership. Capabilities for Sharing Across Threads
Applied Unified Ownership or Capabilities for Sharing Across Threads Elias Castegren Tobias Wrigstad DRF transfer parallel programming AppliedUnified Ownership memory management placement in pools (previous
More informationProf. Edwar Saliba Júnior
1 package Conexao; 2 3 4 * 5 * @author Cynthia Lopes 6 * @author Edwar Saliba Júnior 7 8 import java.io.filenotfoundexception; 9 import java.io.ioexception; 10 import java.sql.sqlexception; 11 import java.sql.statement;
More informationUnlocking magic of Monads with Java 8
Unlocking magic of Monads with Java 8 Oleg Šelajev @shelajev ZeroTurnaround Who am I @shelajev What do we want to achieve? > have fun while learning stuff > understand the concept of Monad > get generic
More informationCombining Concurrency Abstractions
Combining Concurrency Abstractions Philipp Haller Typesafe, Switzerland Correctly and Efficiently Combining Concurrency Abstractions Philipp Haller Typesafe, Switzerland The Problem Tendency to combine
More informationHd video converter factory pro 3. Hd video converter factory pro 3.zip
Hd video converter factory pro 3 Hd video converter factory pro 3.zip HD Video Converter Factory Pro Download - Convert video files to other video file formats.hd Video Converter Factory Pro download.
More informationImperative Programming 2: Traits
Imperative Programming 2: Traits Hongseok Yang University of Oxford Experience with traits so far In IP1, you have used traits as interfaces, in order to specify available methods and fields. trait IntQueue
More informationClassical Themes of Computer Science
Functional Programming (Part 1/2) Bernhard K. Aichernig Institute for Software Technology Graz University of Technology Austria Winter Term 2017/18 Version: November 22, 2017 1/49 Agenda I Functional Programming?
More informationCSE 130, Fall 2006: Final Examination
CSE 130, Fall 2006: Final Examination Name: ID: Instructions, etc. 1. Write your answers in the space provided. 2. Wherever it says explain, write no more than three lines as explanation. The rest will
More informationJDBC Next A new asynchronous API for connecting to a database
JDBC Next A new asynchronous API for connecting to a database Douglas Surber Kuassi Mensah JDBC Architect Director, Product Management Database Server Technologies April 18, 2017 Safe Harbor Statement
More informationStatic Program Analysis Part 1 the TIP language
Static Program Analysis Part 1 the TIP language http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Questions about programs Does the program terminate
More informationINTRODUCTION. SHORT INTRODUCTION TO SCALA INGEGNERIA DEL SOFTWARE Università degli Studi di Padova
SHORT INTRODUCTION TO SCALA INGEGNERIA DEL SOFTWARE Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2014 2015 rcardin@math.unipd.it INTRODUCTION Object/functional
More informationIntroduction to Functional Programming and Haskell. Aden Seaman
Introduction to Functional Programming and Haskell Aden Seaman Functional Programming Functional Programming First Class Functions Expressions (No Assignment) (Ideally) No Side Effects Different Approach
More informationHigher-Order Functions
Higher-Order Functions Tjark Weber Functional Programming 1 Based on notes by Pierre Flener, Jean-Noël Monette, Sven-Olof Nyström Tjark Weber (UU) Higher-Order Functions 1 / 1 Tail Recursion http://xkcd.com/1270/
More informationArne Brüsch Philipp Wille. Pattern Matching Syntax
Scala Enthusiasts BS Arne Brüsch Philipp Wille Pattern Matching Syntax Scala Modular programming language Some used to call it objectfunctional 2 Scala Modular programming language Some used to call it
More informationBig Data Analytics with Apache Spark. Nastaran Fatemi
Big Data Analytics with Apache Spark Nastaran Fatemi Apache Spark Throughout this part of the course we will use the Apache Spark framework for distributed data-parallel programming. Spark implements a
More informationAdvanced Type System Features Tom Schrijvers. Leuven Haskell User Group
Advanced Type System Features Tom Schrijvers Leuven Haskell User Group Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists and Effect Free Other Handlers
More informationList are immutable Lists have recursive structure Lists are homogeneous
WORKING WITH LISTS val fruit = List("apples", "oranges", "pears") val nums: List[Int] = List(1, 2, 3, 4) val diag3 = List( List(1, 0, 0), List(0, 1, 0), List(0, 0, 1) ) val empty = List() List are immutable
More informationHeresies and Dogmas in Software Development
Heresies and Dogmas in Software Development @deanwampler StrangeLoop 2011 Functional Programming for Java Developers Dean Wampler programmingscala.com polyglotprogramming.com /fpjava https://twitter.com/#!/stesla/status/11390744100
More information