Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.
-
Upload
russel-winder -
Category
Technology
-
view
1.219 -
download
3
description
Transcript of Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.
![Page 1: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/1.jpg)
Copyright © 2014 Russel Winder 1
Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.
Russel Winder
email: [email protected]: [email protected]
twitter: @russel_winder
http://www.russel.org.uk
![Page 2: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/2.jpg)
Copyright © 2014 Russel Winder 2
is a programming language.
![Page 3: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/3.jpg)
Copyright © 2014 Russel Winder 3
is a dynamic programming language.
![Page 4: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/4.jpg)
Copyright © 2014 Russel Winder 4
Dynamic language rarely
exhibit high performance.
![Page 5: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/5.jpg)
Copyright © 2014 Russel Winder 5
This is generally not a problem as
most dynamic languages are
usually used in I/O-bound contexts.
![Page 6: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/6.jpg)
Copyright © 2014 Russel Winder 6
In CPU-bound contexts however,
it is a REAL problem.
![Page 7: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/7.jpg)
Copyright © 2014 Russel Winder 7
The biggest issue for Groovy performance
is that floating point values are
BigDecimal by default.
![Page 8: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/8.jpg)
Copyright © 2014 Russel Winder 8
We need an example.
![Page 9: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/9.jpg)
Copyright © 2014 Russel Winder 9
![Page 10: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/10.jpg)
Copyright © 2014 Russel Winder 10
What is the Value of ?
Easy, it's known exactly.
It's .
Obviously.
![Page 11: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/11.jpg)
Copyright © 2014 Russel Winder 11
Putative joke involving Alexander Orlov (*)and the phrase It's simples. elided as UK“ ”television-related comedy doesn't travel.
(*) A fairly cute meerkat.
![Page 12: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/12.jpg)
Copyright © 2014 Russel Winder 12
Approximating
● What is it's value represented as a floating point number?● We can only obtain an approximation.● A plethora of possible algorithms to choose from, a
popular one is to employ the following integral equation.
4=∫0
1 1
1x2dx
![Page 13: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/13.jpg)
Copyright © 2014 Russel Winder 13
One Possible Algorithm
● Use quadrature to estimate the value of the integral – which is the area under the curve.
=4n∑i=1
n 1
1i−0.5n
2
With n = 3 not much to do, but potentially lots of error. Use n = 107 or n = 109?
Embarrassingly parallel.
![Page 14: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/14.jpg)
Copyright © 2014 Russel Winder 14
Because addition is commutative and
associative, expression can be
decomposed into sums of partial sums.
![Page 15: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/15.jpg)
Copyright © 2014 Russel Winder 15
a + b + c + d + e + f
=
( a + b ) + ( c + d ) + ( e + f )
![Page 16: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/16.jpg)
Copyright © 2014 Russel Winder 16
Scatter – Gather
map reduce
fork join
Data parallel
![Page 17: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/17.jpg)
Copyright © 2014 Russel Winder 17
Back to the BigDecimal issue…
![Page 18: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/18.jpg)
Copyright © 2014 Russel Winder 18
…to the code:
![Page 19: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/19.jpg)
Copyright © 2014 Russel Winder 19
As with (almost) all programming language,
Groovy is focussed on sequential activity.
![Page 20: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/20.jpg)
Copyright © 2014 Russel Winder 20
In a multicore world, we harness all the
cores to improve performance.
![Page 21: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/21.jpg)
Copyright © 2014 Russel Winder 21
The Java Platform offers threads,
Java, and hence Groovy, can use them.
![Page 22: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/22.jpg)
Copyright © 2014 Russel Winder 22
Shared memory multithreading is an
infrastructure technique.
![Page 23: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/23.jpg)
Copyright © 2014 Russel Winder 23
java.util.concurrent
![Page 24: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/24.jpg)
Copyright © 2014 Russel Winder 24
![Page 25: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/25.jpg)
Copyright © 2014 Russel Winder 25
Concurrency can be used for
I/O-bound systems, but…
![Page 26: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/26.jpg)
Copyright © 2014 Russel Winder 26
…concurrency can also be used
for CPU-bound systems.
Parallelism .
![Page 27: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/27.jpg)
Copyright © 2014 Russel Winder 27
Parallelism is about performance.
![Page 28: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/28.jpg)
Copyright © 2014 Russel Winder 28
Look at some code…
![Page 29: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/29.jpg)
Copyright © 2014 Russel Winder 29
Dynamism and parallelism are
rarely good bedfellows.
![Page 30: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/30.jpg)
Copyright © 2014 Russel Winder 30
@CompileStatic is about…
…eliding dynamism.…about performance.
![Page 31: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/31.jpg)
Copyright © 2014 Russel Winder 31
invokedynamic is about…
…supporting dynamism.…performance.
![Page 32: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/32.jpg)
Copyright © 2014 Russel Winder 32
Java 8
The greatest revolution ofJava since 1994.
A far bigger revolution ofJava than Java 5.
![Page 33: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/33.jpg)
Copyright © 2014 Russel Winder 33
Java 8
Introduces various things, the most important of which are:
Lambda expressions.Default methods in interfaces.
![Page 34: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/34.jpg)
Copyright © 2014 Russel Winder 34
Java 8
as a consequence oflambda expressions introduces:
Streams†.
† And parallelism, and parallelism is about performance.
![Page 35: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/35.jpg)
Copyright © 2014 Russel Winder 35
More codes…
![Page 36: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/36.jpg)
Copyright © 2014 Russel Winder 36
Needs You…
![Page 37: Groovy, GPars, @CompileStatic and invokedynamic. And Java 8.](https://reader036.fdocuments.in/reader036/viewer/2022081720/547d1c2bb379593f2b8b51ba/html5/thumbnails/37.jpg)
Copyright © 2014 Russel Winder 37
Groovy, GPars, @CompileStatic and invokedynamic. And Java 8
Russel Winder
email: [email protected]: [email protected]
twitter: @russel_winder
http://www.russel.org.uk