Collections After Eight. Maurice Naftalin Morningside Light

Size: px
Start display at page:

Download "Collections After Eight. Maurice Naftalin Morningside Light"

Transcription

1

2 Collections After Eight Maurice Naftalin Morningside Light

3 Maurice Naftalin Developer, designer, architect, teacher, learner, writer 3

4 Maurice Naftalin Developer, designer, architect, teacher, learner, writer Co-author 3

5 Maurice Naftalin Developer, designer, architect, teacher, learner, writer Co-author Current Project 3

6 First computer I programmed Varian 620/i 4

7 Why is everyone so rude about us? 5

8 Why is everyone so rude about us? 90% of all Java programs are written by morons. 5

9 Why is everyone so rude about us? 90% of all Java programs are written by morons. If Java had true garbage collection, most programs would delete themselves upon execution. 5

10 Why is everyone so rude about us? 90% of all Java programs are written by morons. If Java had true garbage collection, most programs would delete themselves upon execution. Lambdas aren t a new invention so why did it take Java so long to incorporate them? IIRC even COBOL had something like them. 5

11 Why is everyone so rude about us? 90% of all Java programs are written by morons. If Java had true garbage collection, most programs would delete themselves upon execution. Lambdas aren t a new invention so why did it take Java so long to incorporate them? IIRC even COBOL had something like them. Sufficiently advanced Java is indistinguishable from satire. 5

12 Why is everyone so rude about us? 90% of all Java programs are written by morons. If Java had true garbage collection, most programs would delete themselves upon execution. Lambdas aren t a new invention so why did it take Java so long to incorporate them? IIRC even COBOL had something like them. Sufficiently advanced Java is indistinguishable from satire. Java is the new Cobol 5

13 Is it because we write code like this? Code plucked from a personal project // check each deadlined Plan. If it can t be done in time for its deadline, return the Plan // that caused the problem; otherwise, return null. private Plan checkplans(list<plan> deadlinedplans) { Plan problemplan = null; Iterator<Plan> planitr = deadlinedplans.iterator(); while (planitr.hasnext() && problemplan == null) { Plan plan = planitr.next(); problemplan = checkplan(plan); return problemplan; 6

14 Is it because we write code like this? Code plucked from a personal project // check each deadlined Plan. If it can t be done in time for its deadline, return the Plan // that caused the problem; otherwise, return null. private Plan checkplans(list<plan> deadlinedplans) { Plan problemplan = null; Iterator<Plan> planitr = deadlinedplans.iterator(); while (planitr.hasnext() && problemplan == null) { Plan plan = planitr.next(); problemplan = checkplan(plan); return problemplan; 6

15 Could we improve our image? 7

16 Could we improve our image? Wouldn t it be cool if instead of writing this: private Plan checkplans(list<plan> deadlinedplans) { Plan problemplan = null; Iterator<Plan> planitr = deadlinedplans.iterator(); while (planitr.hasnext() && problemplan == null) { Plan plan = planitr.next(); problemplan = checkplan(plan); return problemplan; 7

17 Could we improve our image? private Plan checkplans(list<plan> deadlinedplans) { Plan problemplan = null; Iterator<Plan> planitr = deadlinedplans.iterator(); Wouldn t it be cool if instead of writing this: while (planitr.hasnext() && problemplan == null) { Plan plan = planitr.next(); problemplan = checkplan(plan); return problemplan; we could write this: private Optional<Plan> checkplans( List<Plan> deadlinedplans) { return deadlinedplans.stream(). map(p -> checkplan(p)). filter(p -> p!= null). findfirst(); 7

18 Could we improve our image? private Plan checkplans(list<plan> deadlinedplans) { Plan problemplan = null; Iterator<Plan> planitr = deadlinedplans.iterator(); Wouldn t it be cool if instead of writing this: while (planitr.hasnext() && problemplan == null) { Plan plan = planitr.next(); problemplan = checkplan(plan); return problemplan; And easily make it execute in parallel??! we could write this: private Optional<Plan> checkplans( List<Plan> deadlinedplans) { return deadlinedplans.stream(). map(p -> checkplan(p)). filter(p -> p!= null). findfirst(); 7

19 Presentation Overview The Magic Ingredient Result: Better APIs Result: More Parallelism 8

20 Take values to a higher order 9

21 Take values to a higher order instead of supplying values to specific library methods public interface Collection<E> {... boolean remove(object o);... 9

22 Take values to a higher order instead of supplying values to specific library methods public interface Collection<E> {... boolean remove(object o);... we re going to supply behaviour to general library methods: public interface Collection<E> {... boolean removeif(predicate<? super E> p);... 9

23 Take values to a higher order higher-order values instead of supplying values to specific library methods public interface Collection<E> {... boolean remove(object o);... we re going to supply behaviour to general library methods: public interface Collection<E> {... boolean removeif(predicate<? super E> p);... 9

24 Take values to a higher order higher-order values instead of supplying values to specific library methods public interface Collection<E> {... boolean remove(object o);... we re going to supply behaviour to general library methods: public interface Collection<E> {... boolean removeif(predicate<? super E> p);... Predicate is an interface with a single abstract boolean-valued method test removeif executes test for each element: if test returns true, removeif removes that element 9

25 Take values to a higher order higher-order values instead of supplying values to specific library methods public interface Collection<E> {... boolean remove(object o);... we re going to supply behaviour to general library methods: public interface Collection<E> {... boolean removeif(predicate<? super E> p);... Predicate is an interface with a single abstract boolean-valued method Whaat? test removeif executes test for each element: if test returns true, removeif removes that element 9

26 How to make an interface instance? Using an anonymous inner class, of course! planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) { return p.equals(problemplan); ); 10

27 How to make an interface instance? Using an anonymous inner class, of course! planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) { return p.equals(problemplan); ); Maybe this is why they re so rude about us? 10

28 Let s strip out the boilerplate! Why do we have to say we re supplying a Predicate? Why do we have to say we re implementing test, the only abstract method? planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) { return p.equals(problemplan) ); 11

29 Let s strip out the boilerplate! Why do we have to say we re supplying a Predicate? Why do we have to say we re implementing test, the only abstract method? planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) p { return p.equals(problemplan) ); 11

30 Let s strip out the boilerplate! Why do we have to say we re supplying a Predicate? Why do we have to say we re implementing test, the only abstract method? planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) p {-> return p.equals(problemplan) ); 11

31 Let s strip out the boilerplate! Why do we have to say we re supplying a Predicate? Why do we have to say we re implementing test, the only abstract method? planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) p {-> return p.equals(problemplan) ); planlist.removeif(p -> p.equals(problemplan)); 11

32 Let s strip out the boilerplate! Why do we have to say we re supplying a Predicate? Why do we have to say we re implementing test, the only abstract method? planlist.removeif(new Predicate<Plan>(){ public boolean test(plan p) p {-> return p.equals(problemplan) ); planlist.removeif(p -> p.equals(problemplan)); Basically, lambdas are just better syntax! 11

33 Presentation Overview The Magic Ingredient Result: Better APIs Pipes and Filters More Finely-Grained APIs Result: More Parallelism 12

34 Pipes and Filters Venerable Unix tool-building pattern: ps -ef grep login cut -c 50- head and in Enterprise Integration Patterns 13

35 Pipes and Filters Advantages of this pattern 14

36 Pipes and Filters Advantages of this pattern ps -ef grep login cut -c 50- head 14

37 Pipes and Filters Advantages of this pattern ps -ef grep login cut -c 50- head no intermediate variables 14

38 Pipes and Filters Advantages of this pattern ps -ef grep login cut -c 50- head no intermediate variables less (or no) intermediate storage 14

39 Pipes and Filters Advantages of this pattern ps -ef grep login cut -c 50- head no intermediate variables less (or no) intermediate storage lazy evaluation 14

40 Pipes and Filters Advantages of this pattern ps -ef grep login cut -c 50- head no intermediate variables less (or no) intermediate storage lazy evaluation flexible tool-building: 14

41 Pipes and Filters Advantages of this pattern ps -ef grep login cut -c 50- head no intermediate variables less (or no) intermediate storage lazy evaluation flexible tool-building: Write programs that do one thing well. Write programs to work together. 14

42 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); 15

43 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); IntermediateOp IntermediateOp TerminalOp Source Stream<Plan> Stream<Plan> Stream<Plan> 15

44 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); IntermediateOp IntermediateOp TerminalOp Source Stream<Plan> Stream<Plan> Stream<Plan> 15

45 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); IntermediateOp IntermediateOp TerminalOp Source Stream<Plan> Stream<Plan> Stream<Plan> 15

46 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); IntermediateOp IntermediateOp TerminalOp Source Stream<Plan> Stream<Plan> Stream<Plan> 15

47 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); IntermediateOp IntermediateOp TerminalOp Source Stream<Plan> Stream<Plan> Stream<Plan> 15

48 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp Stream<Plan> IntermediateOp Stream<Plan> TerminalOp 15

49 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp l Stream<Plan> IntermediateOp Stream<Plan> TerminalOp 15

50 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp l Stream<Plan> IntermediateOp Stream<Plan> TerminalOp Instance of Mapper<Plan,Plan> 15

51 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp l Stream<Plan> IntermediateOp FilterOp Stream<Plan> TerminalOp Instance of Mapper<Plan,Plan> 15

52 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp l Stream<Plan> IntermediateOp FilterOp l Stream<Plan> TerminalOp Instance of Mapper<Plan,Plan> 15

53 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp l Stream<Plan> IntermediateOp FilterOp l Stream<Plan> TerminalOp Instance of Mapper<Plan,Plan> Instance of Predicate<Plan> 15

54 Pipes & Filters in collection operations deadlinedplans.stream().map(p->checkplan(p)).filter(p->p!=null).findfirst(); Source Stream<Plan> IntermediateOp MapOp l Stream<Plan> IntermediateOp FilterOp l Stream<Plan> TerminalOp l Instance of Mapper<Plan,Plan> Instance of Predicate<Plan> 15

55 Write programs that do one thing well java.util.functions.mapper: public interface Mapper<T, R> { R map(t t); java.util.functions.predicate public interface Predicate<T> { boolean test(t t); 16

56 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p)); 17 19

57 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p)); Collection 17 19

58 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p)); MapStreamIterator(StreamIterator<Plan> upstream, Mapper m) {... Plan next() { return m.map(upstream.next());... Collection 17 19

59 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p)); Collection MapStreamIterator(StreamIterator<Plan> upstream, Mapper m) {... Plan next() { return m.map(upstream.next());

60 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p));.filter(p->p!=null()); Collection MapStreamIterator(StreamIterator<Plan> upstream, Mapper m) {... Plan next() { return m.map(upstream.next());

61 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p));.filter(p->p!=null()); Collection FilterStreamIterator(StreamIterator<Plan> upstream, Predicate pred) { public Plan next() { Plan p = upstream.next();... return pred.test(p)? p : next(); // assume upstream.hasnext() MapStreamIterator(StreamIterator<Plan> upstream, Mapper m) {... Plan next() { return m.map(upstream.next());

62 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p));.filter(p->p!=null()); Collection MapStreamIterator(StreamIterator<Plan> upstream, Mapper m) {... Plan next() { return m.map(upstream.next());... FilterStreamIterator(StreamIterator<Plan> upstream, Predicate pred) { public Plan next() { Plan p = upstream.next(); return pred.test(p)? p : next(); // assume upstream.hasnext()

63 What is a Stream? A sequence of values May be partially evaluated Execution of lazy operations sets the pipeline up: Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p));.filter(p->p!=null()); Collection MapStreamIterator(StreamIterator<Plan> upstream, Mapper m) {... Plan next() { return m.map(upstream.next());... FilterStreamIterator(StreamIterator<Plan> upstream, Predicate pred) { public Plan next() { Plan p = upstream.next(); return pred.test(p)? p : next(); // assume upstream.hasnext()... No evaluation yet! 17 19

64 Lazy and eager operations Execution of lazy operations (IntermediateOps) sets the pipeline up Execution of eager operations (TerminalOps) pulls data down the pipeline Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p)).filter(p->p!=null); planstream.findfirst(); // stop after the first element Collection 18

65 Lazy and eager operations Execution of lazy operations (IntermediateOps) sets the pipeline up Execution of eager operations (TerminalOps) pulls data down the pipeline Stream<Plan> planstream = deadlinedplans.stream().map(p->prepareplan(p)).filter(p->p!=null); planstream.findfirst(); // stop after the first element Collection 18

66 Some Stream methods // get the plans longer than 15 minutes planstream.filter(p -> p.getduration().islongerthan(minutes(15))) // get the total duration of all the plans in a list planstream.map(p -> p.getduration()).reduce(duration.zero, (d1,d2) -> d1.plus(d2)) // each plan belongs to a task; map each task to a collection of its plans planstream.groupby(p -> p.gettask()) // get the first five plans planstream.limit(10) // get all but the first five plans planstream.skip(10) 19

67 Some Stream methods name returns interface used l signature filter Stream<T> lazy Predicate<T> T boolean map Stream<T> lazy Predicate<T> T boolean reduce T eager BinaryOperator<T> (T, T) boolean groupby Map<U,Collection<T>> eager Mapper<T,U> T U limit, skip Stream<T> lazy findfirst T eager Predicate<T> T boolean foreach void eager Block<T> T void sorted Stream<T> lazy Comparator<T> (T, T) boolean 20

68 Presentation Overview The Magic Ingredient Result: Better APIs Pipes and Filters More Finely-Grained APIs Result: More Parallelism 21

69 Making finer-grained APIs Sorting a list using Comparator: Collections.sort(planList, new Comparator<Plan>() { public int compare(plan p1, Plan p2) { return p1.gettask().compareto(p2.gettask()); The method compare must first extract the sort keys and then compare them 22

70 Making methods more precise Suppose instead we have a method that accepts and returns behaviours: Comparator<T> comparing(mapper<t,u> m); Much easier now to create custom Comparators: Comparator<Plan> bytask = Comparators.comparing(p -> gettask()); Comparator<Plan> Comparator<Plan> byduration bytask = Comparators.comparing(p -> p.gettask()); getduration()); 23

71 Composing fine-grained methods Mappers and Comparators can now be composed new Comparator method Collections.sort(planList, bytask.compose(byduration)); and now also planlist.sort(bytask.compose(byduration)); 24

72 Composing fine-grained methods Mappers and Comparators can now be composed new Comparator method Collections.sort(planList, bytask.compose(byduration)); and now also planlist.sort(bytask.compose(byduration)); Plan::getDuration 24

73 Composing fine-grained methods Mappers and Comparators can now be composed new Comparator method Collections.sort(planList, bytask.compose(byduration)); and now also planlist.sort(bytask.compose(byduration)); Plan::getTask Plan::getDuration 24

74 Presentation Overview The Magic Ingredient Result: Better APIs Result: More Parallelism 25

75 External Iteration Foreach loop: for (Plan plan : planlist) { plan.setsection(null); or, equivalently, for (Iterator<Plan> pitr = planlist.iterator(); pitr.hasnext(); ) { pitr.next().setsection(null); 26

76 External Iteration Foreach loop: for (Plan plan : planlist) { plan.setsection(null); or, equivalently, for (Iterator<Plan> pitr = planlist.iterator(); pitr.hasnext(); ) { pitr.next().setsection(null); Client controls the iteration 26

77 External Iteration Foreach loop: for (Plan plan : planlist) { plan.setsection(null); or, equivalently, for (Iterator<Plan> pitr = planlist.iterator(); pitr.hasnext(); ) { pitr.next().setsection(null); Client controls the iteration Loop is inherently sequential 26

78 External Iteration Foreach loop: for (Plan plan : planlist) { plan.setsection(null); or, equivalently, for (Iterator<Plan> pitr = planlist.iterator(); pitr.hasnext(); ) { pitr.next().setsection(null); Client controls the iteration Loop is inherently sequential client would have to manage parallelisation 26

79 Internal iteration Strategy: Supply behaviour to general library methods 27

80 Internal iteration Strategy: Supply behaviour to general library methods planlist.foreach(p -> p.setsection(null)) 27

81 Internal iteration Strategy: Supply behaviour to general library methods planlist.foreach(p -> p.setsection(null)) Much simpler interaction. And now the library controls the iteration: Can use its own iteration tactics: Parallelism, out-of-order execution, laziness 27

82 Example: ConcurrentHashMap ConcurrentHashMap.parallel(ForkJoinPool) - Returns a parallel view of the CHM - Methods: foreach, foreachentry, foreachkey, foreachvalue,... - Consider foreachvalue(concurrenthashmap.action<v> action) - Creates a new ForEachValueTask -subclass of ForkJoinTask -submits that to the ForkJoinPool - ForkJoinPool executes ForEachValueTask on one of its threads 28

83 ConcurrentHashMap.ForEachValueTask static final class ForEachValueTask<K,V> extends BulkTask<K,V,Void> { final Action<V> action; ForEachValueTask (ConcurrentHashMap<K,V> m, Action<V> action) { super(m); this.action = action; ForEachValueTask (BulkTask<K,V,?> p, int b, boolean split, Action<V> action) { super(p, b, split); this.action = public final void compute() { final Action<V> action = this.action; if (action == null) throw new Error(NullFunctionMessage); int b = batch(), c; while (b > 1 && baseindex!= baselimit) { do { while (!caspending(c = pending, c+1)); new ForEachValueTask<K,V>(this, b >>>= 1, true, action).fork(); Object v; while ((v = advance())!= null) action.apply((v)v); trycomplete(); 29

84 ConcurrentHashMap.ForEachValueTask static final class ForEachValueTask<K,V> extends BulkTask<K,V,Void> { final Action<V> action; ForEachValueTask (ConcurrentHashMap<K,V> m, Action<V> action) { super(m); this.action = action; ForEachValueTask (BulkTask<K,V,?> p, int b, boolean split, Action<V> action) { super(p, b, split); this.action = public final void compute() { final Action<V> action = this.action; if (action == null) throw new Error(NullFunctionMessage); int b = batch(), c; while (b > 1 && baseindex!= baselimit) { do { while (!caspending(c = pending, c+1)); new ForEachValueTask<K,V>(this, b >>>= 1, true, action).fork(); Object v; while ((v = advance())!= null) action.apply((v)v); trycomplete(); 29

85 ConcurrentHashMap.ForEachValueTask static final class ForEachValueTask<K,V> extends BulkTask<K,V,Void> { final Action<V> action; ForEachValueTask (ConcurrentHashMap<K,V> m, Action<V> action) { super(m); if (action == null) this.action = action; ForEachValueTask (BulkTask<K,V,?> int p, int b b, = boolean batch(), split, c; Action<V> action) { super(p, b, split); this.action = public final void compute() { final Action<V> action = this.action; if (action == null) throw new Error(NullFunctionMessage); int b = batch(), c; while (b > 1 && baseindex!= baselimit) { do { while Object (!caspending(c = v; pending, c+1)); new ForEachValueTask<K,V>(this, b >>>= 1, true, action).fork(); Object v; while ((v = advance())!= null) action.apply((v)v); trycomplete(); public final void compute() { final Action<V> action = this.action; throw new Error(NullFunctionMessage); while (b > 1 && baseindex!= baselimit) { do { while (!caspending(c = pending, c+1)); new ForEachValueTask<K,V>(this, b >>>= 1, true, action).fork(); while ((v = advance())!= null) action.apply((v)v); 29

86 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); 30

87 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); 30

88 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork 30

89 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork 30

90 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork 30

91 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork 30

92 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork 30

93 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork 30

94 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork 30

95 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork join 30

96 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork join join 30

97 Stream parallelisation Collection.parallel().filter(...).map(...).reduce(...); fork fork fork join join join 30

98 Conclusion Lambdas seem like a small syntactic change, but a big difference in the style of Java code set the library writers free to innovate encourage a functional coding style less mutability = more parallel-friendly 31

99 Conclusion Lambdas seem like a small syntactic change, but a big difference in the style of Java code set the library writers free to innovate encourage a functional coding style less mutability = more parallel-friendly 31

100 Resources 32

101 Resources 32

102 Resources

103 Q&A

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

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

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

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

Streams and Pipelines

Streams and Pipelines Streams 1 / 12 Streams and Pipelines A stream is a sequence of elements. Unlike a collection, it is not a data structure that stores elements. Unlike an iterator, streams do not allow modification of the

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

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

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

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

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

Fontys Hogeschool voor Techniek en Logistiek. March 13, 2018

Fontys Hogeschool voor Techniek en Logistiek. March 13, 2018 Java 8 s and Java 8 Fontys Hogeschool voor Techniek en Logistiek March 13, 2018 and? /FHTenL s and Java 8 March 13, 2018 1/34 talk The other anonymous and? Java 8 and? /FHTenL s and Java 8 March 13, 2018

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

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

Evolving Java. Brian Goetz Java Language Architect, Oracle. Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Evolving Java. Brian Goetz Java Language Architect, Oracle. Copyright 2013, Oracle and/or its affiliates. All rights reserved. Evolving Java Brian Goetz Java Language Architect, Oracle 1 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated

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

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

SFDV3006 Concurrent Programming

SFDV3006 Concurrent Programming SFDV3006 Concurrent Programming Lecture 6 Concurrent Architecture Concurrent Architectures Software architectures identify software components and their interaction Architectures are process structures

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

Java 8 Functional Programming with Lambdas Angelika Langer

Java 8 Functional Programming with Lambdas Angelika Langer Java 8 Functional Programming with Lambdas Angelika Langer Training/Consulting objective learn about lambda expressions in Java know the syntax elements understand typical uses Lambda Expressions in Java

More information

Lambda Expressions and Java 8 Streams. Jan Trienes, adapted by Th. Dorssers, Pieter van den Hombergh. Contents of this talk.

Lambda Expressions and Java 8 Streams. Jan Trienes, adapted by Th. Dorssers, Pieter van den Hombergh. Contents of this talk. Java 8 s and Java 8 van den Hombergh Fontys Hogeschool voor Techniek en Logistiek February 23, 2017 and /FHTenL s and Java 8 February 23, 2017 1/28 talk Expression and Internal/External Iteration Java

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

Project Lambda in Java SE 8

Project Lambda in Java SE 8 Project Lambda in Java SE 8 Daniel Smith Java Language Designer 1 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated

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 in Java 8. Start programming in a more functional style

Lambdas in Java 8. Start programming in a more functional style Lambdas 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

INSTRUCTIONS TO CANDIDATES

INSTRUCTIONS 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 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

The Road To Java 8 Day, EclipseCon Alex Buckley, Oracle

The Road To Java 8 Day, EclipseCon Alex Buckley, Oracle The Road To Lambda @ Java 8 Day, EclipseCon 2014 Alex Buckley, Oracle lambda-dev@openjdk.java.net 1 2 Modernizing Java Java SE 8 is a big step forward for the Java Language Lambda Expressions for better

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

Java8: Stream Style. Sergey

Java8: Stream Style. Sergey Java8: Stream Style Sergey Kuksenko sergey.kuksenko@oracle.com, @kuksenk0 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be

More information

Evolving Java. Brian Goetz Java Language Architect, Oracle. Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Evolving Java. Brian Goetz Java Language Architect, Oracle. Copyright 2013, Oracle and/or its affiliates. All rights reserved. Evolving Java Brian Goetz (@BrianGoetz) Java Language Architect, Oracle 1 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be

More information

COMP6700/2140 Code as Data

COMP6700/2140 Code as Data COMP6700/2140 Code as Data Alexei B Khorev Research School of Computer Science, ANU March 2017 Alexei B Khorev (RSCS, ANU) COMP6700/2140 Code as Data March 2017 1 / 19 Topics 1 What does treating code

More information

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Introduction to Object-Oriented Programming Iterators and Streams Christopher Simpkins chris.simpkins@gatech.edu CS 1331 (Georgia Tech) Iterators and Streams 1 / 20 The Collections Framework A collection

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

ΠΙΝΑΚΑΣ ΠΛΑΝΟΥ ΕΚΠΑΙΔΕΥΣΗΣ

ΠΙΝΑΚΑΣ ΠΛΑΝΟΥ ΕΚΠΑΙΔΕΥΣΗΣ ΠΑΡΑΡΤΗΜΑ «Β» ΠΙΝΑΚΑΣ ΠΛΑΝΟΥ ΕΚΠΑΙΔΕΥΣΗΣ Α/Α ΠΕΡΙΓΡΑΦΗ ΕΚΠΑΙΔΕΥΣΗΣ ΘΕΜΑΤΙΚΕΣ ΕΝΟΤΗΤΕΣ 1. Java SE8 Fundamentals What Is a Java Program? Introduction to Computer Programs Key Features of the Java Language

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

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

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

Java Workshop Lambda Expressions

Java Workshop Lambda Expressions Java Workshop Lambda Expressions AP Java Workshop 2015 Hanno Hüther and Martin Stein Agenda 1. Origin and syntax 2. History and motivation 3. Exercise 1: Refactoring to lambdas 4. Method references 5.

More information

Java Collection Framework

Java Collection Framework Java Collection Framework Readings Purpose To provide a working knowledge of the Java Collections framework and iterators. Learning Objectives Understand the structure of the Java Collections framework

More information

Java 8 Functional Programming with Lambdas Angelika Langer

Java 8 Functional Programming with Lambdas Angelika Langer Java 8 Functional Programming with Lambdas Angelika Langer Training/Consulting objective learn about lambda expressions in Java know the syntax elements understand typical uses Lambda Expressions in Java

More information

Higher-Order Sequential Operations

Higher-Order Sequential Operations Chapter 9 Higher-Order Sequential Operations Many of the operations we wish to perform over lists have common structure. In this chapter, we investigate the most common of these patterns and how we can

More information

CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010

CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections. Tyler Robison Summer 2010 CSE332: Data Abstractions Lecture 23: Programming with Locks and Critical Sections Tyler Robison Summer 2010 1 Concurrency: where are we Done: The semantics of locks Locks in Java Using locks for mutual

More information

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections

A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections A Sophomoric Introduction to Shared-Memory Parallelism and Concurrency Lecture 5 Programming with Locks and Critical Sections Dan Grossman Last Updated: May 2012 For more information, see http://www.cs.washington.edu/homes/djg/teachingmaterials/

More information

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name:

CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, Name: CS-140 Fall 2017 Test 1 Version Practice Practice for Nov. 20, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : If a child overrides

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

JVM ByteCode Interpreter

JVM ByteCode Interpreter JVM ByteCode Interpreter written in Haskell (In under 1000 Lines of Code) By Louis Jenkins Presentation Schedule ( 15 Minutes) Discuss and Run the Virtual Machine first

More information

1z0-813.exam.28q 1z0-813 Upgrade to Java SE 8 OCP (Java SE 6 and all prior versions)

1z0-813.exam.28q   1z0-813 Upgrade to Java SE 8 OCP (Java SE 6 and all prior versions) 1z0-813.exam.28q Number: 1z0-813 Passing Score: 800 Time Limit: 120 min 1z0-813 Upgrade to Java SE 8 OCP (Java SE 6 and all prior versions) Exam A QUESTION 1 Given the code fragment: What is the result?

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

Java Concurrency. Towards a better life By - -

Java Concurrency. Towards a better life By - - Java Concurrency Towards a better life By - Srinivasan.raghavan@oracle.com - Vaibhav.x.choudhary@oracle.com Java Releases J2SE 6: - Collection Framework enhancement -Drag and Drop -Improve IO support J2SE

More information

Object-Oriented Design Lecture 13 CSU 370 Fall 2008 (Pucella) Friday, Oct 31, 2008

Object-Oriented Design Lecture 13 CSU 370 Fall 2008 (Pucella) Friday, Oct 31, 2008 Object-Oriented Design Lecture 13 CSU 370 Fall 2008 (Pucella) Friday, Oct 31, 2008 Laziness For this lecture, I want to return to something that came up during the last homework, the third homework where

More information

Concurrency User Guide

Concurrency User Guide Concurrency User Guide Release 1.0 Dylan Hackers January 26, 2019 CONTENTS 1 Basic Abstractions 3 1.1 Executors................................................. 3 1.2 Queues..................................................

More information

Course introduction. Advanced Compiler Construction Michel Schinz

Course introduction. Advanced Compiler Construction Michel Schinz Course introduction Advanced Compiler Construction Michel Schinz 2016 02 25 General information Course goals The goal of this course is to teach you: how to compile high-level functional and objectoriented

More information

List ADT. Announcements. The List interface. Implementing the List ADT

List ADT. Announcements. The List interface. Implementing the List ADT Announcements Tutoring schedule revised Today s topic: ArrayList implementation Reading: Section 7.2 Break around 11:45am List ADT A list is defined as a finite ordered sequence of data items known as

More information

+ Today. Lecture 26: Concurrency 3/31/14. n Reading. n Objectives. n Announcements. n P&C Section 7. n Race conditions.

+ Today. Lecture 26: Concurrency 3/31/14. n Reading. n Objectives. n Announcements. n P&C Section 7. n Race conditions. + Lecture 26: Concurrency Slides adapted from Dan Grossman + Today n Reading n P&C Section 7 n Objectives n Race conditions n Announcements n Quiz on Friday 1 + This week s programming assignment n Answer

More information

Whether to Include Java 8 Features in Introductory CS Courses

Whether to Include Java 8 Features in Introductory CS Courses CCSC Eastern Conference 2015 Tutorial Whether to Include Java 8 Features in Introductory CS Courses James Heliotis Computer Science Rochester Inst. of Technology jeh@cs.rit.edu 1 Our History in Java Education

More information

CADEC JAVA 8 MAGNUS LARSSON CALLISTAENTERPRISE.SE

CADEC JAVA 8 MAGNUS LARSSON CALLISTAENTERPRISE.SE CADEC 2015 - JAVA 8 MAGNUS LARSSON 2015.01.28 CALLISTAENTERPRISE.SE 1 JAVA 8 NEW FEATURES Overview Lambda Expressions Stream API 2 JAVA 8 NEW FEATURES - OVERVIEW New Date/Time API - Based on Joda-Time

More information

Why do you want to know about functional programming?

Why do you want to know about functional programming? Why do you want to know about functional programming? A look at LinQ in C# and (perhaps) Java Axel T. Schreiner RIT Computer Science http://www.cs.rit.edu/~ats/talks/linq-ieee/ http://www.cs.rit.edu/~ats/cs-2006-1/14_linq.pdf

More information

.NET Database Technologies. Entity Framework: Queries and Transactions

.NET Database Technologies. Entity Framework: Queries and Transactions .NET Database Technologies Entity Framework: Queries and Transactions ORMs and query languages l With an ORM, queries must define data to be returned and criteria in terms of domain model objects and their

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

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

CSE332 Summer 2010: Final Exam

CSE332 Summer 2010: Final Exam CSE332 Summer 2010: Final Exam Closed notes, closed book; calculator ok. Read the instructions for each problem carefully before answering. Problems vary in point-values, difficulty and length, so you

More information

<Insert Picture Here> Evolving Java Project Lambda, and Beyond

<Insert Picture Here> Evolving Java Project Lambda, and Beyond Evolving Java Project Lambda, and Beyond Brian Goetz Java Language Architect Oracle Corporation The following is intended to outline our general product direction. It is intended

More information

Perform Database Actions Using Java 8 Stream Syntax Instead of SQL. Emil Forslund Java Developer Speedment, Inc.

Perform Database Actions Using Java 8 Stream Syntax Instead of SQL. Emil Forslund Java Developer Speedment, Inc. Perform Database Actions Using Java 8 Stream Syntax Instead of SQL Emil Forslund Java Developer Speedment, Inc. About Me Emil Forslund Java Developer Speedment Palo Alto Age of Java Why Should You Need

More information

Phaser volle Energie...

Phaser volle Energie... Phaser volle Energie...... eine Reise ins Paralleluniversum von JDK7 Hartmut Lang, Ericsson July 2011 Hartmut Lang Senior Software Developer Solution Architect Network Management and Customer Solutions

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

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

Programming Languages. Thunks, Laziness, Streams, Memoization. Adapted from Dan Grossman s PL class, U. of Washington

Programming Languages. Thunks, Laziness, Streams, Memoization. Adapted from Dan Grossman s PL class, U. of Washington Programming Languages Thunks, Laziness, Streams, Memoization Adapted from Dan Grossman s PL class, U. of Washington You ve been lied to Everything that looks like a function call in Racket is not necessarily

More information

CSE 332: Data Structures & Parallelism Lecture 17: Shared-Memory Concurrency & Mutual Exclusion. Ruth Anderson Winter 2019

CSE 332: Data Structures & Parallelism Lecture 17: Shared-Memory Concurrency & Mutual Exclusion. Ruth Anderson Winter 2019 CSE 332: Data Structures & Parallelism Lecture 17: Shared-Memory Concurrency & Mutual Exclusion Ruth Anderson Winter 2019 Toward sharing resources (memory) So far, we have been studying parallel algorithms

More information

CS 520 Theory and Practice of Software Engineering Fall 2018

CS 520 Theory and Practice of Software Engineering Fall 2018 Logistics CS 520 Theory and Practice of Software Engineering Fall 2018 Best and worst programming practices September 11, 2018 Reminder Recap: software architecture vs. design Class website: https://people.cs.umass.edu/~brun/class/2018fall/cs520/

More information

Inheritance (Part 5) Odds and ends

Inheritance (Part 5) Odds and ends Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

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

1 Shyam sir JAVA Notes

1 Shyam sir JAVA Notes 1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write

More information

1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

1 Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8 1 Copyright 2012, Oracle and/or its affiliates. All rights Insert Information Protection Policy Classification from Slide 8 Project Lambda: To Multicore and Beyond David Holmes 2 Copyright 2012, Oracle

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

CS 520 Theory and Practice of Software Engineering Fall 2017

CS 520 Theory and Practice of Software Engineering Fall 2017 Logistics CS 520 Theory and Practice of Software Engineering Fall 2017 Best and worst programming practices September 12, 2017 Recap: software architecture vs. design Recap: software architecture examples

More information

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

Copyright 2013, Oracle and/or its affiliates. All rights reserved. 1 Lambda: A peek under the hood Brian Goetz Java Language Architect, Oracle 2 The following is intended to outline our general product direction. It is intended for information purposes only, and may not

More information

LAMBDA EXPRESSIONS. Summer 2018

LAMBDA EXPRESSIONS. Summer 2018 LAMBDA EXPRESSIONS Summer 2018 LAMBDA EXPRESSIONS USES Introduced in Java SE 8, lambda expressions are a way to create single-method classes in your code in a much less cumbersome manner than anonymous

More information

CS 520 Theory and Practice of Software Engineering Fall 2017

CS 520 Theory and Practice of Software Engineering Fall 2017 CS 520 Theory and Practice of Software Engineering Fall 2017 Best and worst programming practices September 12, 2017 Logistics Recap: software architecture vs. design Specification Architecture Development

More information

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the

More information

What s different about Factor?

What s different about Factor? Harshal Lehri What s different about Factor? Factor is a concatenative programming language - A program can be viewed as a series of functions applied on data Factor is a stack oriented program - Data

More information

Selected Java Topics

Selected Java Topics Selected Java Topics Introduction Basic Types, Objects and Pointers Modifiers Abstract Classes and Interfaces Exceptions and Runtime Exceptions Static Variables and Static Methods Type Safe Constants Swings

More information

Java Review: Objects

Java Review: Objects Outline Java review Abstract Data Types (ADTs) Interfaces Class Hierarchy, Abstract Classes, Inheritance Invariants Lists ArrayList LinkedList runtime analysis Iterators Java references 1 Exam Preparation

More information

<Insert Picture Here> Implementing lambda expressions in Java

<Insert Picture Here> Implementing lambda expressions in Java Implementing lambda expressions in Java Brian Goetz Java Language Architect Adding lambda expressions to Java In adding lambda expressions to Java, the obvious question is: what is

More information

Chapter 6 Parallel Loops

Chapter 6 Parallel Loops Chapter 6 Parallel Loops Part I. Preliminaries Part II. Tightly Coupled Multicore Chapter 6. Parallel Loops Chapter 7. Parallel Loop Schedules Chapter 8. Parallel Reduction Chapter 9. Reduction Variables

More information

JVA-103. Java Programming

JVA-103. Java Programming JVA-103. Java Programming Version 8.0 This course teaches programming in the Java language -- i.e. the Java Standard Edition platform. It is intended for programmers with experience in languages other

More information

Vendor: Oracle. Exam Code: 1Z Exam Name: Java SE 7 Programmer I. Version: Demo

Vendor: Oracle. Exam Code: 1Z Exam Name: Java SE 7 Programmer I. Version: Demo Vendor: Oracle Exam Code: 1Z0-803 Exam Name: Java SE 7 Programmer I Version: Demo QUESTION 1 A. 3 false 1 B. 2 true 3 C. 2 false 3 D. 3 true 1 E. 3 false 3 F. 2 true 1 G. 2 false 1 Correct Answer: D :

More information

Pragmatic Functional Refactoring with Java 8

Pragmatic Functional Refactoring with Java 8 Pragmatic Functional Refactoring with Java 8 @richardwarburto insightfullogic.com @raouluk cambridgecoding.com First-class Functions Currying Immutability Optional Data Types Conclusions Step 1: filtering

More information

Functional Programming in Java. CSE 219 Department of Computer Science, Stony Brook University

Functional Programming in Java. CSE 219 Department of Computer Science, Stony Brook University Functional Programming in Java CSE 219, Stony Brook University What is functional programming? There is no single precise definition of functional programming (FP) We should think of it as a programming

More information

After completing Matchers, you will be able to: Describe the advantages of encapsulating verification logic in

After completing Matchers, you will be able to: Describe the advantages of encapsulating verification logic in CHAPTER 3 MATCHERS OBJECTIVES After completing Matchers, you will be able to: Describe the advantages of encapsulating verification logic in matchers. Use built-in matchers from the Hamcrest library. Create

More information

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Communication IPC in Unix Pipes: most basic form of IPC in Unix process-process ps u jon grep tcsh // what happens? Pipe has a read-end (receive)

More information

List of Known Errata. Harnessing Java 7: A Comprehensive Approach to Learning Java. (Volumes 1, 2, and 3) Kishori Sharan

List of Known Errata. Harnessing Java 7: A Comprehensive Approach to Learning Java. (Volumes 1, 2, and 3) Kishori Sharan List of Known Errata In Harnessing Java 7: A Comprehensive Approach to Learning Java (Volumes 1, 2, and 3) By Kishori Sharan Document Last Updated: March 30, 2012 Table of Contents Reporting an Erratum...

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Comp215: More lists. Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved.

Comp215: More lists. Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved. Comp215: More lists Dan S. Wallach (Rice University) Copyright 2015, Dan S. Wallach. All rights reserved. What s a good list interface We now have two different kinds of lists: lazy and eager. (We ll talk

More information

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Communication IPC in Unix Pipes: most basic form of IPC in Unix process-process ps u jon grep tcsh // what happens? Pipe has a read-end (receive)

More information

Overview of Java 8 Parallel Streams (Part 1)

Overview of Java 8 Parallel Streams (Part 1) Overview of Java 8 Parallel s (Part 1) 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

Parallel Nested Loops

Parallel Nested Loops Parallel Nested Loops For each tuple s i in S For each tuple t j in T If s i =t j, then add (s i,t j ) to output Create partitions S 1, S 2, T 1, and T 2 Have processors work on (S 1,T 1 ), (S 1,T 2 ),

More information

Parallel Partition-Based. Parallel Nested Loops. Median. More Join Thoughts. Parallel Office Tools 9/15/2011

Parallel Partition-Based. Parallel Nested Loops. Median. More Join Thoughts. Parallel Office Tools 9/15/2011 Parallel Nested Loops Parallel Partition-Based For each tuple s i in S For each tuple t j in T If s i =t j, then add (s i,t j ) to output Create partitions S 1, S 2, T 1, and T 2 Have processors work on

More information