Java8: Stream Style. Sergey

Size: px
Start display at page:

Download "Java8: Stream Style. Sergey"

Transcription

1 Java8: Stream Style Sergey

2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. Slide 2/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

3 Motivation Slide 3/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

4 Motivation Everything is well. Why do we need any Streams? Slide 4/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

5 Motivation Everything is well. Why do we need any Streams? public void printgroups ( List < People > people ) { Set < Group > groups = new HashSet < >(); for ( People p : people ) { if ( p. getage () >= 65) groups. add ( p. getgroup ()); } List < Group > sorted = new ArrayList < >( groups ); Collections. sort ( sorted, new Comparator < Group >() { public int compare ( Group a, Group b ) { return Integer. compare ( a. getsize (), b. getsize ()) } }); for ( Group g : sorted ) System. out. println ( g. getname ()); } Slide 4/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

6 Motivation It would be awesome to omit miles and miles of duplicated code. public void printgroups ( List < People > people ) { people. stream (). filter (p -> p. getage () > 65). map (p -> p. getgroup ()). distinct (). sorted ( comparing (g -> g. getsize ())). map (g -> g. getname ()). foreach (n -> System. out. println (n )); } Slide 5/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

7 Motivation It would be awesome to do less work, and do it later (laziness). public void printgroups ( List < People > people ) { people. stream (). filter (p -> p. getage () > 65). map (p -> p. getgroup ()). distinct (). sorted ( comparing (g -> g. getsize ())). map (g -> g. getname ()). foreach (n -> System. out. println (n )); // ACTIONS! } Slide 6/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

8 Motivation Parallelism? Collection < Item > data ;... for ( int i =0; i < data. size (); i ++) { processitem ( data. get (i )); } Slide 7/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

9 Motivation Parallelism? Collection < Item > data ;... for ( Item item : data ) { processitem ( item ); } Slide 8/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

10 Motivation Parallelism? Collection < Item > data ;... # pragma omg parallel for ( Item item : data ) { processitem ( item ); } Slide 9/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

11 Motivation Parallelism? Collection < Item > data ;... # pragma omp parallel for ( Item item : data ) { processitem ( item ); } Slide 10/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

12 Motivation Parallelism? Collection < Item > data ;... parallel_for( Item item : data ) { processitem ( item ); } Slide 11/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

13 Motivation Parallelism! Collection < Item > data ;... data. parallelstream (). foreach ( item -> processitem ( item )); Slide 12/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

14 Design Slide 13/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

15 Design Most of the code fits the same simple pattern source Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

16 Design Most of the code fits the same simple pattern source op Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

17 Design Most of the code fits the same simple pattern source op op Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

18 Design Most of the code fits the same simple pattern source op op op Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

19 Design Most of the code fits the same simple pattern source op op op Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

20 Design Most of the code fits the same simple pattern source op op op gangnamstyle Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

21 Design Most of the code fits the same simple pattern source op op op sink Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

22 Design Most of the code fits the same simple pattern source op op op sink sources : collections, iterators, channels,... operations : filter, map, reduce,... sinks : collections, locals,... Slide 14/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

23 Sources Standard classes? not-yet-created classes? 3 rd party classes? Slide 15/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

24 Sources Standard classes? not-yet-created classes? 3 rd party classes? Collection? should we put everything into collection? Slide 15/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

25 Sources Standard classes? not-yet-created classes? 3 rd party classes? Collection? should we put everything into collection? Iterable? Iterator Hell (inherently sequential) interface pollution Slide 15/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

26 Sources Standard classes? not-yet-created classes? 3 rd party classes? Collection? should we put everything into collection? Iterable? Iterator Hell (inherently sequential) interface pollution Stream! new (just invented) interface with required semantic inject the only stream() method into existing classes Slide 15/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

27 Stream Slide 16/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

28 Stream A multiplicity of values Not a collection (no storage) Operations are deferred as long as possible May be infinite Source is unmodifiable Can be used only once Ordered/Unordered Parallel/Sequential Primitive specializations: IntStream, LongStream, DoubleStream Slide 17/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

29 Stream pipeline a source: Source Stream intermediate operations: Stream Stream a terminal operation: Stream PROFIT! public void printgroups ( List < People > people ) { people.stream().filter(p -> p. getage () > 65).map(p -> p. getgroup ()).distinct().sorted( comparing (g -> g. getsize ())).map(g -> g. getname ()).foreach(n -> System. out. println (n )); } Slide 18/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

30 Stream pipeline a source: Source Stream intermediate operations: Stream Stream a terminal operation: Stream PROFIT! public void printgroups ( List < People > people ) { people.stream().filter(p -> p. getage () > 65).map(p -> p. getgroup ()).distinct().sorted( comparing (g -> g. getsize ())).map(g -> g. getname ()).foreach(n -> System. out. println (n )); } Slide 18/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

31 Stream pipeline a source: Source Stream intermediate operations: Stream Stream a terminal operation: Stream PROFIT! public void printgroups ( List < People > people ) { people.stream().filter(p -> p. getage () > 65).map(p -> p. getgroup ()).distinct().sorted( comparing (g -> g. getsize ())).map(g -> g. getname ()).foreach(n -> System. out. println (n )); } Slide 18/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

32 Stream pipeline a source: Source Stream intermediate operations: Stream Stream a terminal operation: Stream PROFIT! public void printgroups ( List < People > people ) { Stream < People > s1 = people. stream (); Stream < People > s2 = s1. filter (p -> p. getage () > 65); Stream < Group > s3 = s2. map (p -> p. getgroup ()); Stream < Group > s4 = s3. distinct (); Stream < Group > s5 = s4. sorted ( comparing (g ->g. getsize ())); Stream < String > s6 = s5. map (g -> g. getname ()); s6. foreach (n -> System. out. println (n )); } Slide 19/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

33 Stream Sources Slide 20/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

34 Stream Sources: collections ArrayList <T > list ; Stream <T > s = list. stream (); // sized, ordered Slide 21/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

35 Stream Sources: collections ArrayList <T > list ; Stream <T > s = list. stream (); // sized, ordered HashSet <T > set ; Stream <T > s = set. stream (); // sized, distinct Slide 21/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

36 Stream Sources: collections ArrayList <T > list ; Stream <T > s = list. stream (); // sized, ordered HashSet <T > set ; Stream <T > s = set. stream (); // sized, distinct TreeSet <T > set ; Stream <T > s = set. stream (); // sized, distinct // sorted, ordered Slide 21/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

37 Stream Sources: factories, builders T [] arr ; Stream <T > s = Arrays. stream ( arr ); Slide 22/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

38 Stream Sources: factories, builders T [] arr ; Stream <T > s = Arrays. stream ( arr ); Stream <T > s = Stream. of (v0, v1, v2 ); Slide 22/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

39 Stream Sources: factories, builders T [] arr ; Stream <T > s = Arrays. stream ( arr ); Stream <T > s = Stream. of (v0, v1, v2 ); Stream <T > s = Stream. builder (). add ( v0 ). add ( v1 ). add ( v2 ). build (); Slide 22/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

40 Stream Sources: factories, builders T [] arr ; Stream <T > s = Arrays. stream ( arr ); Stream <T > s = Stream. of (v0, v1, v2 ); Stream <T > s = Stream. builder (). add ( v0 ). add ( v1 ). add ( v2 ). build (); IntStream s = IntStream. range (0, 100); Slide 22/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

41 Stream Sources: generators AtomicInteger init = new AtomicInteger (0); Stream < Integer > s = Stream. generate ( init :: getandincrement ); Slide 23/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

42 Stream Sources: generators AtomicInteger init = new AtomicInteger (0); Stream < Integer > s = Stream. generate ( init :: getandincrement ); Stream < Integer > s = Stream. iterate (0, i -> i +1); Slide 23/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

43 Stream Sources: others Stream < String > s = bufferedreader. lines (); Slide 24/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

44 Stream Sources: others Stream < String > s = bufferedreader. lines (); Stream < String > s = Pattern. compile ( myregex ). splitasstream ( mystr ); Slide 24/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

45 Stream Sources: others Stream < String > s = bufferedreader. lines (); Stream < String > s = Pattern. compile ( myregex ). splitasstream ( mystr ); DoubleStream s = new SplittableRandom (). doubles (); Slide 24/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

46 Intermediate Operations Slide 25/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

47 Intermediate Operations Stream <S > s; Stream <S > s. filter ( Predicate <S >); Stream <T > s. map ( Function <S, T >); Stream <T > s. flatmap ( Function <S, Stream <T > >); Stream <S > s. peek ( Consumer <S >); Stream <S > s. sorted (); Stream <S > s. distinct (); Stream <S > s. limit ( long ); Stream <S > s. skip ( long ); Slide 26/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

48 Intermediate Operations Stream <S > s; Stream <S > s. filter ( Predicate <S >); Stream <T > s. map ( Function <S, T >); Stream <T > s. flatmap ( Function <S, Stream <T > >); Stream <S > s. peek ( Consumer <S >); Stream <S > s. sorted (); Stream <S > s. distinct (); Stream <S > s. limit ( long ); Stream <S > s. skip ( long ); Stream <S > s. unordered (); Stream <S > s. parallel (); Stream <S > s. sequential (); Slide 26/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

49 Terminal Operations a.k.a. PROFIT Slide 27/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

50 Terminal Operations Terminal operations yield final result Parallel or sequential execution Terminal operations flavors : iteration: foreach, iterator searching: findfirst, findany matching: allmatch, anymatch, nonematch aggregation: reduction collectors Slide 28/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

51 Short-circuiting Do not consume the entire stream, drop it on the floor as necessary May operate infinite streams find*, *Match, limit e.g.: int v = Stream. iterate (1, i -> i +1). filter ( i % 2 == 0). findfirst (). get (); Slide 29/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

52 Iteration Process each stream element: IntStream. range (0, 100). foreach ( System. out :: println ); Convert to old style iterator 1 : Iterator < Integer > = Stream. iterate (0, i -> i + 1). limit (100). iterator (); 1 for compatibility Slide 30/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

53 Example How to compute a sum over Stream<Integer>? Slide 31/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

54 Example How to compute a sum over Stream<Integer>? public int getsum ( Stream < Integer > s ){ int sum ; s. foreach ( i -> sum += i ); return sum ; } Slide 31/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

55 Example How to compute a sum over Stream<Integer>? public int getsum ( Stream < Integer > s ){ int sum ; s. foreach ( i -> sum += i ); // Compile error return sum ; } Slide 32/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

56 Example How to compute a sum over Stream<Integer>? public int getsum ( Stream < Integer > s ){ int [] sum = new int [1]; s. foreach ( i -> sum [0] += i ); return sum [0]; } Slide 33/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

57 Example Result? Stream < Integer > s = IntStream. range (0, 100). maptoobj (i -> 1); System. out. println ( getsum (s )); Slide 34/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

58 Example Result? Stream < Integer > s = IntStream. range (0, 100). maptoobj (i -> 1); System. out. println ( getsum (s )); 100 Slide 34/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

59 Example Result? Stream < Integer > s = IntStream. range (0, 100). maptoobj (i -> 1); System. out. println ( getsum (s )); 100 Stream < Integer > s = IntStream. range (0, 100). maptoobj (i -> 1). parallel (); System. out. println ( getsum (s )); Slide 34/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

60 Example Result? Stream < Integer > s = IntStream. range (0, 100). maptoobj (i -> 1); System. out. println ( getsum (s )); 100 Stream < Integer > s = IntStream. range (0, 100). maptoobj (i -> 1). parallel (); System. out. println ( getsum (s )); 79, 63, 100,... Slide 34/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

61 Reduction Take a stream and make a scalar value: Stream < Integer > s; Integer sum = s. reduce (0, (x, y) -> x + y ); Slide 35/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

62 Reduction Take a stream and make a scalar value: Stream < Integer > s; Integer sum = s. reduce (0, (x, y) -> x + y ); Some operations return Optional<T>: Stream < Integer > s; Optional < Integer > sum = s. reduce ((x, y) -> x + y ); Slide 35/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

63 Reduction Stream <T > {... <U > U reduce (U identity, BiFunction <U,T,U > accumulator, BinaryOperator <U > combiner )... } Slide 36/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

64 Collectors A.k.a. mutable reduction operations Accumulate elements into a mutable result container: List < Integer > list = IntStream. range (0, 100). boxed (). collect ( Collectors. tolist ()); int [] ints = IntStream. range (0, 100). toarray (); Slide 37/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

65 Collectors A.k.a. mutable reduction operations Accumulate elements into a mutable result container: List < Integer > list = IntStream. range (0, 100). boxed (). collect ( Collectors. tolist ()); int [] ints = IntStream. range (0, 100). toarray (); Complex collections: Map < Integer, Integer > map = IntStream. range (0, 100). boxed (). collect ( Collectors. toconcurrentmap ( k -> k % 42, v -> v, (a, b) -> b ) ); Slide 37/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

66 java.util.stream.collectors More than 30 predefined collectors, e.g.: collector = > result of Stream<T>.collect(collector) tolist () => List toset () => Set tocollection ( Supplier < Collection <T > >) => Collection <T > partitioningby ( Predicate <T >) => Map < Boolean, List <T >> groupingby ( Function <T,K >) => Map <K, List <T >>> tomap ( Function <T,K >, Function <T,U >) => Map <K,U > Slide 38/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

67 Collectors String [] a = new String []{ "a", "b", "c" }; Hot to get "a,b,c"? Slide 39/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

68 Collectors String [] a = new String []{ "a", "b", "c" }; Hot to get "a,b,c"? Arrays. stream (a ). collect ( Collectors. joining ("," )); Slide 39/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

69 Collectors String [] a = new String []{ "a", "b", "c" }; Hot to get "a,b,c"? Arrays. stream (a ). collect ( Collectors. joining ("," )); FYI: java.util.stringjoiner Slide 39/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

70 Collectors Stream <T > {... <R > R collect ( Supplier <R > supplier, BiConsumer <R, T > accumulator, BiConsumer <R, R > combiner )... } Slide 40/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

71 Collectors Stream <T > s; List <T > l = s. collect ( Collectors. tolist ()); l = collect ( () -> new ArrayList < >(), ( list, t) -> list. add (t), (l1, l2 ) -> l1. addall ( l2 )); Slide 41/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

72 Collectors Stream <T > s; List <T > l = s. collect ( Collectors. tolist ()); l = collect ( () -> new ArrayList < >(), ( list, t) -> list. add (t), (l1, l2 ) -> l1. addall ( l2 )); l = collect ( ArrayList :: new, List :: add, List :: addall ); Slide 41/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

73 Parallelism Slide 42/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

74 Parallelism Lots of sources are naturally splittable Lots of operations are well parallelizable Streams will do it for us ForkJoinPool inside Have to ask for the parallelism explicitly int v = list.parallelstream (). reduce ( Math :: max ). get (); Slide 43/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

75 Explicit parallelism Q: Why not implicit? A: Final speedup depends on: N number of source elements Q cost of operation P available HW parallelism C number of concurrent clients We know N. We can estimate P. We can somehow cope with C Q is almost not predictable. Slide 44/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

76 Thank you! Slide 45/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

77 Q & A? Slide 46/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

78 Appendix Slide 47/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

79 Spliterator Slide 48/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

80 Spliterator interface Spliterator <T > {... long estimatesize (); // Long. MAX_VALUE if unknown boolean tryadvance ( Consumer <T > action ); Spliterator <T > trysplit (); int characteristics (); }... Slide 49/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

81 Spliterator s characteristic ORDERED DISTINCT SORTED SIZED SUBSIZED NONNULL IMMUTABLE CONCURRENT Slide 50/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

82 Stream design I like to look at this as having chosen a design center that recognizes that sequential is a degenerate case of parallel, rather than treating parallel as the weird bonus mode. I realize that this choice was controversial and definitely caused some compromises, but eventually people will have to start to unlearn their sequential biases, and there s no time like the present. (c) Brian Goetz Slide 51/51. Copyright c 2014, Oracle and/or its affiliates. All rights reserved.

Multicore Programming

Multicore Programming Multicore Programming Java Streams Louis-Claude Canon louis-claude.canon@univ-fcomte.fr Bureau 414C Master 1 informatique Semestre 8 Louis-Claude Canon MCP Java Streams 1 / 124 Motivations Express simple

More information

Streams in Java 8. Start programming in a more functional style

Streams in Java 8. Start programming in a more functional style Streams in Java 8 Start programming in a more functional style Background Who am I? Tobias Coetzee I m a Technical Lead at BBD I present the Java Expert Level Certifications at BBD (EJB, JPA, etc.) I m

More information

Perchance to Stream with Java 8

Perchance to Stream with Java 8 Perchance to Stream with Java 8 Paul Sandoz Oracle The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated $$ into

More information

Java Technologies. Lecture V. Valdas Rapševičius

Java Technologies. Lecture V. Valdas Rapševičius Preparation of the material was supported by the project Increasing Internationality in Study Programs of the Department of Computer Science II, project number VP1 2.2 ŠMM-07-K-02-070, funded by The European

More information

LAMBDA EXPRESSIONS AND STREAMS API

LAMBDA EXPRESSIONS AND STREAMS API Java 8 LAMBDA EXPRESSIONS AND STREAMS API An Introduction Methods As Data 2 @FunctionalInterface public interface Runnable { public abstract void run(); public interface ActionListener extends EventListener

More information

Functional Constructs in Java 8: Lambdas and Streams

Functional Constructs in Java 8: Lambdas and Streams Functional Constructs in Java 8: Lambdas and Streams Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Homework 6 due Thursday 11:59 pm Final exam Tuesday, May 3, 5:30-8:30 pm, PH 100

More information

Java SE 8: Lambda Expressions And The Stream API

Java SE 8: Lambda Expressions And The Stream API Java SE 8: Lambda Expressions And The Stream API Simon Ritter Head of Java Technology Evangelism Java Product Management Java Day Tokyo 2015 April 8, 2015 Safe Harbor Statement The following is intended

More information

Advanced Programming Methods. Lecture 4 - Functional Programming in Java

Advanced Programming Methods. Lecture 4 - Functional Programming in Java Advanced Programming Methods Lecture 4 - Functional Programming in Java Important Announcement: At Seminar 6 (7-13 November 2017) you will have a closed-book test (based on your laboratory work). Overview

More information

Java 8 new features Juan Hernández

Java 8 new features Juan Hernández Java 8 new features Juan Hernández Dec 1st 2015 1 / 73 Introduction In this session we will do an introduction to the new features introduced by Java 8 for functional programming: λ-expressions and the

More information

Lambdas & Streams In JDK 8: Beyond The Basics

Lambdas & Streams In JDK 8: Beyond The Basics Lambdas & Streams In JDK 8: Beyond The Basics Simon Ritter Deputy CTO, Azul Systems @speakjava azul.com Copyright Azul Systems 2015 1 A clever man learns from his mistakes......a wise man learns from other

More information

Lesson 3-4: Using Collectors

Lesson 3-4: Using Collectors Lesson 3-4: Using Collectors Collector Basics A Collector performs a mutable reduction on a stream Accumulates input elements into a mutable result container Results container can be a List, Map, String,

More information

301AA - Advanced Programming

301AA - 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 information

Collectors. Raoul-Gabriel Urma Richard Warburton James Gough

Collectors. Raoul-Gabriel Urma Richard Warburton James Gough Collectors Raoul-Gabriel Urma Richard Warburton James Gough Outline of module 1. Grouping and partitioning 2. Collection operations 3. Arithmetic and reducing collectors 4. Advanced queries Grouping and

More information

Op>onal. The Mother of all Bikesheds. Stuart Marks Core Libraries Java PlaGorm Group, Oracle

Op>onal. The Mother of all Bikesheds. Stuart Marks Core Libraries Java PlaGorm Group, Oracle Op>onal The Mother of all Bikesheds Stuart Marks Core Libraries Java PlaGorm Group, Oracle Copyright 2016, Oracle and/or its affiliates. All rights reserved. Op>onal The Mother of all Bikesheds What is

More information

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Copyright 2012, Oracle and/or its affiliates. All rights reserved. 1 Jump-Starting Lambda Stuart Marks @stuartmarks Mike Duigou @mjduigou Oracle JDK Core Libraries Team 2 What is Lambda? Essentially an anonymous function allows one to treat code as data provides parameterization

More information

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. June 8, 2017

Pieter van den Hombergh Thijs Dorssers Stefan Sobek. June 8, 2017 Pieter van den Hombergh Thijs Dorssers Stefan Sobek Fontys Hogeschool voor Techniek en Logistiek June 8, 2017 /FHTenL June 8, 2017 1/19 Collection Zoo The basic collections, well known in programming s

More information

Project Lambda: Functional Programming Constructs and Simpler Concurrency in Java SE 8

Project Lambda: Functional Programming Constructs and Simpler Concurrency in Java SE 8 Project Lambda: Functional Programming Constructs and Simpler Concurrency in Java SE 8 Michael Cui Principle Engineer, Java Platform Group Oracle Corporation 1 The following is intended to outline our

More information

Common mistakes made with Functional Java. Brian Vermeer

Common mistakes made with Functional Java. Brian Vermeer Common mistakes made with Functional Java Brian Vermeer (@BrianVerm) Brian Vermeer Software Engineer Doing too much in a single lambda @BrianVerm Lambda Expression In computer programming, a lambda

More information

Java 8 Lambdas & Streams Angelika Langer

Java 8 Lambdas & Streams Angelika Langer Java 8 Lambdas & Streams Angelika Langer objective understand lambda expressions learn about method references explore the stream API get a feeling for its performance model Lambdas & Streams in Java 8

More information

JAVA. java.lang.stringbuffer java.lang.stringbuilder

JAVA. java.lang.stringbuffer java.lang.stringbuilder JAVA java.lang.stringbuffer java.lang.stringbuilder 1 Overview mutable string instances of String are immutable do not extend String String, StringBuffer, StringBuilder are final StringBuffer safe for

More information

Java 8 Stream Performance Angelika Langer & Klaus Kreft

Java 8 Stream Performance Angelika Langer & Klaus Kreft Java 8 Stream Performance Angelika Langer & Klaus Kreft objective how do streams perform? explore whether / when parallel streams outperfom seq. streams compare performance of streams to performance of

More information

New Features in Java 8

New Features in Java 8 New Features in Java 8 Lambda expressions Functional interfaces Streaming support for Collections Lambda expressions Are a block of java code with parameters Can be assigned to variables Can be executed

More information

STREAMS VS PARALLELSTREAMS BY VAIBHAV CHOUDHARY JAVA PLATFORMS TEAM, ORACLE

STREAMS VS PARALLELSTREAMS BY VAIBHAV CHOUDHARY JAVA PLATFORMS TEAM, ORACLE STREAMS VS PARALLELSTREAMS BY VAIBHAV CHOUDHARY (@VAIBHAV_C) JAVA PLATFORMS TEAM, ORACLE HTTP://BLOGS.ORACLE.COM/VAIBHAV IN SHORT, WE WILL DISCUSS Concurrency and Parallelism Stream support in Java 8 Streams

More information

PIC 20A Anonymous classes, Lambda Expressions, and Functional Programming

PIC 20A Anonymous classes, Lambda Expressions, and Functional Programming PIC 20A Anonymous classes, Lambda Expressions, and Functional Programming Ernest Ryu UCLA Mathematics Last edited: December 8, 2017 Introductory example When you write an ActionListener for a GUI, you

More information

Advanced Java Programming

Advanced Java Programming Advanced Java Programming Programming Technologies 2015/2016 spring Kollár, Lajos Kocsis, Gergely (English version) Advanced Java Programming Java 5 Generics (Enums) Java 7 Strings in switch try-with-resources

More information

Lambdas & Streams: Taking the Hard Work Out of Bulk Operations in Java SE 8.

Lambdas & Streams: Taking the Hard Work Out of Bulk Operations in Java SE 8. Lambdas & Streams: Taking the Hard Work Out of Bulk Operations in Java SE 8 Simon Ritter Head of Java Evangelism Oracle Corporation Twitter: @speakjava 1 Concurrency in Java Project Lambda java.util.concurrent

More information

Java 8 Stream Performance Angelika Langer & Klaus Kreft

Java 8 Stream Performance Angelika Langer & Klaus Kreft Java 8 Stream Performance Angelika Langer & Klaus Kreft agenda introduction loop vs. sequential stream sequential vs. parallel stream Stream Performance (2) what is a stream? equivalent of sequence from

More information

CS 10: Problem solving via Object Oriented Programming. Streams

CS 10: Problem solving via Object Oriented Programming. Streams CS 10: Problem solving via Object Oriented Programming Streams Agenda 1. Streaming data 2. Java streams 2 Streams allow us to process things as they come Stream movie vs. file Stream (Ne1lix) Data produc=on

More information

What is the Java Collections Framework?

What is the Java Collections Framework? 1 of 13 What is the Java Collections Framework? To begin with, what is a collection?. I have a collection of comic books. In that collection, I have Tarzan comics, Phantom comics, Superman comics and several

More information

CS 10: Problem solving via Object Oriented Programming Winter 2017

CS 10: Problem solving via Object Oriented Programming Winter 2017 CS 10: Problem solving via Object Oriented Programming Winter 2017 Tim Pierson 260 (255) Sudikoff Streams Agenda 1. Streaming data 2. Java streams 2 Streams allow us to process things as they come Stream

More information

Java SE 8 New Features

Java SE 8 New Features Java SE 8 New Features Duration 2 Days What you will learn This Java SE 8 New Features training delves into the major changes and enhancements in Oracle Java SE 8. You'll focus on developing an understanding

More information

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: +52 1 55 8525 3225 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming

More information

<Insert Picture Here> JSR-335 Update for JCP EC Meeting, January 2012

<Insert Picture Here> JSR-335 Update for JCP EC Meeting, January 2012 JSR-335 Update for JCP EC Meeting, January 2012 Alex Buckley Oracle Corporation The following is intended to outline our general product direction. It is intended for information

More information

CS 251 Intermediate Programming Java Basics

CS 251 Intermediate Programming Java Basics CS 251 Intermediate Programming Java Basics Brooke Chenoweth University of New Mexico Spring 2018 Prerequisites These are the topics that I assume that you have already seen: Variables Boolean expressions

More information

Effective Java Streams

Effective Java Streams Effective Java Streams Paul Sandoz Oracle list.stream(). map(λ). brian(λ). filter(λ). john(λ). reduce(λ) mark(λ) 2 Agenda Patterns/Idioms Tips and tricks with interesting stuff Effective parallel execution

More information

Future of Java. Post-JDK 9 Candidate Features. Jan Lahoda Java compiler developer Java Product Group, Oracle September, 2017

Future of Java. Post-JDK 9 Candidate Features. Jan Lahoda Java compiler developer Java Product Group, Oracle September, 2017 Future of Java Post-JDK 9 Candidate Features Jan Lahoda Java compiler developer Java Product Group, Oracle September, 2017 Safe Harbor Statement The following is intended to outline our general product

More information

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features

More information

Java SE 8 Programming

Java SE 8 Programming Java SE 8 Programming Training Calendar Date Training Time Location 16 September 2019 5 Days Bilginç IT Academy 28 October 2019 5 Days Bilginç IT Academy Training Details Training Time : 5 Days Capacity

More information

COURSE 5 PROGRAMMING III OOP. JAVA LANGUAGE

COURSE 5 PROGRAMMING III OOP. JAVA LANGUAGE COURSE 5 PROGRAMMING III OOP. JAVA LANGUAGE PREVIOUS COURSE CONTENT Generics Defining a generic Run-time behavior Collections List Set Map COUSE CONTENT Collections Utilities classes Aggregate Operations

More information

Introduction to Functional Programming in Java 8

Introduction to Functional Programming in Java 8 1 Introduction to Functional Programming in Java 8 Java 8 is the current version of Java that was released in March, 2014. While there are many new features in Java 8, the core addition is functional programming

More information

Lambda Expressions In JDK8: Going Beyond The Basics

Lambda Expressions In JDK8: Going Beyond The Basics Lambda Expressions In JDK8: Going Beyond The Basics Simon Ri?er Head of Java Technology Evangelism Oracle Corp Twi?er: @speakjava Copyright 2014, Oracle and/or its affiliates. All rights reserved. Safe Harbor

More information

Some features of modern CPUs. and how they help us

Some features of modern CPUs. and how they help us Some features of modern CPUs and how they help us RAM MUL core Wide operands RAM MUL core CP1: hardware can multiply 64-bit floating-point numbers Pipelining: can start the next independent operation before

More information

COMP6700/2140 Stream Pipelines

COMP6700/2140 Stream Pipelines COMP6700/2140 Stream Pipelines Alexei B Khorev Research School of Computer Science, ANU April 2017 Alexei B Khorev (RSCS, ANU) COMP6700/2140 Stream Pipelines April 2017 1 / 28 Topics 1 Idioms of Stream

More information

Java 8 Parallel Stream Internals (Part 2)

Java 8 Parallel Stream Internals (Part 2) Java 8 Parallel Stream Internals (Part 2) Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt

More information

ArrayList. Introduction. java.util.arraylist

ArrayList. Introduction. java.util.arraylist ArrayList Introduction In this article from my free Java 8 course, I will be giving you a basic overview of the Java class java.util.arraylist. I will first explain the meaning of size and capacity of

More information

JAVA. java.lang.stringbuffer java.lang.stringbuilder

JAVA. java.lang.stringbuffer java.lang.stringbuilder JAVA java.lang.stringbuffer java.lang.stringbuilder 1 Overview mutable string instances of String are immutable do not extend String String, StringBuffer, StringBuilder are final StringBuffer safe for

More information

Pieter van den Hombergh Richard van den Ham. February 8, 2018

Pieter van den Hombergh Richard van den Ham. February 8, 2018 Pieter van den Hombergh Richard van den Ham Fontys Hogeschool voor Techniek en Logistiek February 8, 2018 /FHTenL February 8, 2018 1/16 Collection Zoo The basic collections, well known in programming s

More information

Refactoring to Functional. Hadi Hariri

Refactoring to Functional. Hadi Hariri Refactoring to Functional Hadi Hariri Functional Programming In computer science, functional programming is a programming paradigm, a style of building the structure and elements of computer programs,

More information

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement

9/21/17. Outline. Expression Evaluation and Control Flow. Arithmetic Expressions. Operators. Operators. Notation & Placement Outline Expression Evaluation and Control Flow In Text: Chapter 6 Notation Operator evaluation order Operand evaluation order Overloaded operators Type conversions Short-circuit evaluation of conditions

More information

Outline. iterator review iterator implementation the Java foreach statement testing

Outline. iterator review iterator implementation the Java foreach statement testing Outline iterator review iterator implementation the Java foreach statement testing review: Iterator methods a Java iterator only provides two or three operations: E next(), which returns the next element,

More information

Collections After Eight. Maurice Naftalin Morningside Light

Collections After Eight. Maurice Naftalin Morningside Light Collections After Eight Maurice Naftalin Morningside Light Ltd. @mauricenaftalin Maurice Naftalin Developer, designer, architect, teacher, learner, writer 3 Maurice Naftalin Developer, designer, architect,

More information

Principles of Programming Languages

Principles 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 information

Clojure Concurrency Constructs. CSCI 5828: Foundations of Software Engineering Lecture 12 10/02/2014

Clojure Concurrency Constructs. CSCI 5828: Foundations of Software Engineering Lecture 12 10/02/2014 Clojure Concurrency Constructs CSCI 5828: Foundations of Software Engineering Lecture 12 10/02/2014 1 Goals Cover the material presented in Chapters 3 & 4 of our concurrency textbook! Books examples from

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

CS Programming Languages: Scala

CS Programming Languages: Scala CS 3101-2 - Programming Languages: Scala Lecture 3: Fun with Functions Daniel Bauer (bauer@cs.columbia.edu) October 29, 2014 Daniel Bauer CS3101-2 Scala - 03 - Fun with Functions 1/37 Contents 1 Defining

More information

Truffle A language implementation framework

Truffle A language implementation framework Truffle A language implementation framework Boris Spasojević Senior Researcher VM Research Group, Oracle Labs Slides based on previous talks given by Christian Wimmer, Christian Humer and Matthias Grimmer.

More information

Interfaces and Collections

Interfaces and Collections Interfaces and Collections COMPSCI 2S03 Mikhail Andrenkov Department of Computing and Software McMaster University Week 9: November 14-18 Mikhail Andrenkov Interfaces and Collections 1 / 25 Outline 1 Interfaces

More information

Unit #8: Shared-Memory Parallelism and Concurrency

Unit #8: Shared-Memory Parallelism and Concurrency Unit #8: Shared-Memory Parallelism and Concurrency CPSC 221: Algorithms and Data Structures Will Evans and Jan Manuch 2016W1 Unit Outline History and Motivation Parallelism versus Concurrency Counting

More information

Parallel Computing. Hwansoo Han (SKKU)

Parallel Computing. Hwansoo Han (SKKU) Parallel Computing Hwansoo Han (SKKU) Unicore Limitations Performance scaling stopped due to Power consumption Wire delay DRAM latency Limitation in ILP 10000 SPEC CINT2000 2 cores/chip Xeon 3.0GHz Core2duo

More information

NAME: c. (true or false) The median is always stored at the root of a binary search tree.

NAME: c. (true or false) The median is always stored at the root of a binary search tree. EE 322C Spring 2009 (Chase) Exam 2: READ THIS FIRST. Please use the back side of each page for scratch paper. For some of the questions you may need to think quite a bit before you write down an answer.

More information

Primitive Data and Objects

Primitive Data and Objects Primitive Data and Objects The programmer computes on data Data in Java is divided into primitive data and non-primitive data s primitive, String is not double is primitive, arrays are not (Wrapper classes

More information

Java Live Lab. Course Outline. Java Live Lab. 20 Jun 2018

Java Live Lab. Course Outline. Java Live Lab.  20 Jun 2018 Course Outline 20 Jun 2018 Contents 1. Course Objective 2. Expert Instructor-Led Training 3. ADA Compliant & JAWS Compatible Platform 4. State of the Art Educator Tools 5. Award Winning Learning Platform

More information

COMP 322: Fundamentals of Parallel Programming. Lecture 13: Parallelism in Java Streams, Parallel Prefix Sums

COMP 322: Fundamentals of Parallel Programming. Lecture 13: Parallelism in Java Streams, Parallel Prefix Sums COMP 322: Fundamentals of Parallel Programming Lecture 13: Parallelism in Java Streams, Parallel Prefix Sums Instructors: Vivek Sarkar, Mack Joyner Department of Computer Science, Rice University {vsarkar,

More information

Collections After Eight. Maurice Naftalin Morningside Light

Collections After Eight. Maurice Naftalin Morningside Light Collections After Eight Maurice Naftalin Morningside Light Ltd. @mauricenaftalin Maurice Naftalin Developer, designer, architect, teacher, learner, writer Co-author www.lambdafaq.org Current Projects Why

More information

Advanced Programming Generics Collections

Advanced Programming Generics Collections Advanced Programming Generics Collections The Context Create a data structure that stores elements: a stack, a linked list, a vector a graph, a tree, etc. What data type to use for representing the elements

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 20 February 28, 2018 Transition to Java Announcements HW05: GUI programming Due: THURSDAY!! at 11:59:59pm Lots of TA office hours today Thursday See Piazza

More information

11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures

11-1. Collections. CSE 143 Java. Java 2 Collection Interfaces. Goals for Next Several Lectures Collections CSE 143 Java Collections Most programs need to store and access collections of data Collections are worth studying because... They are widely useful in programming They provide examples of

More information

Alan Bateman Java Platform Group, Oracle November Copyright 2018, Oracle and/or its affiliates. All rights reserved.!1

Alan Bateman Java Platform Group, Oracle November Copyright 2018, Oracle and/or its affiliates. All rights reserved.!1 Alan Bateman Java Platform Group, Oracle November 2018 Copyright 2018, Oracle and/or its affiliates. All rights reserved.!1 Project Loom Continuations Fibers Tail-calls Copyright 2018, Oracle and/or its

More information

Class Libraries. Readings and References. Java fundamentals. Java class libraries and data structures. Reading. Other References

Class Libraries. Readings and References. Java fundamentals. Java class libraries and data structures. Reading. Other References Reading Readings and References Class Libraries CSE 142, Summer 2002 Computer Programming 1 Other References» The Java tutorial» http://java.sun.com/docs/books/tutorial/ http://www.cs.washington.edu/education/courses/142/02su/

More information

Core Java Contents. Duration: 25 Hours (1 Month)

Core Java Contents. Duration: 25 Hours (1 Month) Duration: 25 Hours (1 Month) Core Java Contents Java Introduction Java Versions Java Features Downloading and Installing Java Setup Java Environment Developing a Java Application at command prompt Java

More information

Java Collections The Force Awakens.

Java Collections The Force Awakens. Java Collections The Force Awakens Darth @RaoulUK Darth @RichardWarburto Collection Problems Java Episode 8 & 9 Persistent & Immutable Collections HashMaps Collection bugs 1. 2. 3. Element access (Off-by-one

More information

Java (8) for C++ Programmers

Java (8) for C++ Programmers Java (8) for C++ Programmers Technion - Israel Institute of Technology Oren Afek, Natan Bagrov - March 2017 236703 - Object-Oriented Programming 1 Why Java? Object-oriented (even though not purely ) Portable

More information

Oracle Fusion Middleware 12c

Oracle Fusion Middleware 12c Oracle Fusion Middleware 12c Cloud Application Foundation Coherence 12.1.2 Coherence 12.1.2 Configuration Enhancements (or Building Your Own Services) Brian Oliver Senior Consulting

More information

Free your Lambdas Java SE 8

Free your Lambdas Java SE 8 Free your Lambdas Java SE 8 Agenda Tutorial session: we will start at the very beginning! and explore how to build functional interfaces to design new APIs This is about lambdas and functional interfaces

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Class object initialization block destructor Class object

Class object initialization block destructor Class object In this segment, I will review the Java statements and primitives that relate explicitly to Object Oriented Programming. I need to re-enforce Java s commitment to OOP. Unlike C++, there is no way to build

More information

Parallel Programming Principle and Practice. Lecture 7 Threads programming with TBB. Jin, Hai

Parallel Programming Principle and Practice. Lecture 7 Threads programming with TBB. Jin, Hai Parallel Programming Principle and Practice Lecture 7 Threads programming with TBB Jin, Hai School of Computer Science and Technology Huazhong University of Science and Technology Outline Intel Threading

More information

15-418, Spring 2008 OpenMP: A Short Introduction

15-418, Spring 2008 OpenMP: A Short Introduction 15-418, Spring 2008 OpenMP: A Short Introduction This is a short introduction to OpenMP, an API (Application Program Interface) that supports multithreaded, shared address space (aka shared memory) parallelism.

More information

Basic Data Structures 1 / 24

Basic Data Structures 1 / 24 Basic Data Structures 1 / 24 Outline 1 Some Java Preliminaries 2 Linked Lists 3 Bags 4 Queues 5 Stacks 6 Performance Characteristics 2 / 24 Some Java Preliminaries Generics (aka parametrized types) is

More information

Cloud Ready: Introduction to Distributed Lambdas

Cloud Ready: Introduction to Distributed Lambdas Cloud Ready: Introduction to Distributed Lambdas Brian Oliver Architect Java Specification Lead Oracle Cloud Engineering April 2017 Email: brian.oliver@oracle.com Twitter: @pinocchiocode Safe Harbor Statement

More information

Copyright 2014, Oracle and/or its affiliates. All rights reserved.

Copyright 2014, Oracle and/or its affiliates. All rights reserved. 1 Introduction to Lambda Stuart W. Marks Principal Member of Technical Staff Oracle JDK Core Libraries Team Twitter: @stuartmarks What is a Lambda? A lambda is a function. A function is a computation that

More information

Kafka Streams: Hands-on Session A.A. 2017/18

Kafka Streams: Hands-on Session A.A. 2017/18 Università degli Studi di Roma Tor Vergata Dipartimento di Ingegneria Civile e Ingegneria Informatica Kafka Streams: Hands-on Session A.A. 2017/18 Matteo Nardelli Laurea Magistrale in Ingegneria Informatica

More information

Overview of Java 8 Functional Interfaces

Overview of Java 8 Functional Interfaces Overview of Java 8 Functional Interfaces Douglas C. Schmidt d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University

More information

CMSC 202. Containers

CMSC 202. Containers CMSC 202 Containers Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects. Arrays are compiler-supported containers.

More information

Shared-Memory Programming Models

Shared-Memory Programming Models Shared-Memory Programming Models Parallel Programming Concepts Winter Term 2013 / 2014 Dr. Peter Tröger, M.Sc. Frank Feinbube Cilk C language combined with several new keywords Different approach to OpenMP

More information

Object-Oriented Programming with Java

Object-Oriented Programming with Java Object-Oriented Programming with Java Recitation No. 2 Oranit Dror The String Class Represents a character string (e.g. "Hi") Explicit constructor: String quote = "Hello World"; string literal All string

More information

<Insert Picture Here> Get on the Grid. JVM Language Summit Getting Started Guide. Cameron Purdy, VP of Development, Oracle

<Insert Picture Here> Get on the Grid. JVM Language Summit Getting Started Guide. Cameron Purdy, VP of Development, Oracle Get on the Grid JVM Language Summit Getting Started Guide Cameron Purdy, VP of Development, Oracle The following is intended to outline our general product direction. It is intended

More information

CS4961 Parallel Programming. Lecture 5: More OpenMP, Introduction to Data Parallel Algorithms 9/5/12. Administrative. Mary Hall September 4, 2012

CS4961 Parallel Programming. Lecture 5: More OpenMP, Introduction to Data Parallel Algorithms 9/5/12. Administrative. Mary Hall September 4, 2012 CS4961 Parallel Programming Lecture 5: More OpenMP, Introduction to Data Parallel Algorithms Administrative Mailing list set up, everyone should be on it - You should have received a test mail last night

More information

Mixed projects: Java + Kotlin. Svetlana Isakova

Mixed projects: Java + Kotlin. Svetlana Isakova Mixed projects: Java + Kotlin Svetlana Isakova Compilation of a mixed project *.kt kotlinc *.class *.jar *.java javac *.class Nullability Nullability Type =? Java Kotlin Nullability annotations @Nullable

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Program Elements -- Introduction

Program Elements -- Introduction Program Elements -- Introduction We can now examine the core elements of programming Chapter 3 focuses on: data types variable declaration and use operators and expressions decisions and loops input and

More information

Fundamental language mechanisms

Fundamental language mechanisms Java Fundamentals Fundamental language mechanisms The exception mechanism What are exceptions? Exceptions are exceptional events in the execution of a program Depending on how grave the event is, the program

More information

The New Java Technology Memory Model

The New Java Technology Memory Model The New Java Technology Memory Model java.sun.com/javaone/sf Jeremy Manson and William Pugh http://www.cs.umd.edu/~pugh 1 Audience Assume you are familiar with basics of Java technology-based threads (

More information

The Pig Experience. A. Gates et al., VLDB 2009

The Pig Experience. A. Gates et al., VLDB 2009 The Pig Experience A. Gates et al., VLDB 2009 Why not Map-Reduce? Does not directly support complex N-Step dataflows All operations have to be expressed using MR primitives Lacks explicit support for processing

More information

Lecture 6: ArrayList Implementation

Lecture 6: ArrayList Implementation Lecture 6: ArrayList Implementation CS 62 Fall 2018 Alexandra Papoutsaki & William Devanny 1 Programming Assignment Weak AI/Natural Language Processing: Generate text by building frequency lists based

More information

CS Programming I: ArrayList

CS Programming I: ArrayList CS 200 - Programming I: ArrayList Marc Renault Department of Computer Sciences University of Wisconsin Madison Spring 2018 TopHat Sec 3 (AM) Join Code: 427811 TopHat Sec 4 (PM) Join Code: 165455 ArrayLists

More information

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 2 Analysis of Fork-Join Parallel Programs Steve Wolfman, based on work by Dan Grossman (with small tweaks by Alan Hu) Learning

More information

Exploring different level of parallelism Instruction-level parallelism (ILP): how many of the operations/instructions in a computer program can be performed simultaneously 1. e = a + b 2. f = c + d 3.

More information