Slide 1

Slide 1 text

Copyright © 2014 Russel Winder 1 Java is Dead Long Live Scala, Kotlin, Ceylon, etc. Russel Winder email: [email protected] twitter: @russel_winder Web: http://www.russel.org.uk

Slide 2

Slide 2 text

Copyright © 2014 Russel Winder 2 Java is Dead

Slide 3

Slide 3 text

Copyright © 2014 Russel Winder 3 Java is Dying

Slide 4

Slide 4 text

Copyright © 2014 Russel Winder 4 What are the symptoms? ● Java is seriously verbose. ● Java has poor type inference. ● Java has only low-level support for concurrency and parallelism. ● Java generates a dependency hell . “ ” ● Java is a 1990s imperative language that isn't really object-oriented. ● …

Slide 5

Slide 5 text

Copyright © 2014 Russel Winder 5 Is there a cure? ● Can Java: ● Be less verbose. ● Have better type inferencing. ● Do concurrency and parallelism better. (Doug Lea, Brian Goetz and others have actually been doing this for a while.) ● Have a reasonable module system, cf. Jigsaw vs. OSGi. ● Be a real object-oriented language.

Slide 6

Slide 6 text

Copyright © 2014 Russel Winder 6 Prognosis: not great

Slide 7

Slide 7 text

Copyright © 2014 Russel Winder 7 Alternatives?

Slide 8

Slide 8 text

Copyright © 2014 Russel Winder 8 Create a new language ● Java is a statically typed, compiled language, so create a new statically typed compiled language: ● Scala ● Kotlin ● Ceylon ● Fantom ● Gosu ● ?

Slide 9

Slide 9 text

Copyright © 2014 Russel Winder 9 Gross oversimplifications…

Slide 10

Slide 10 text

Copyright © 2014 Russel Winder 10 Scala ● Integrates functional and object-oriented. ● Very declarative style of expression. ● Strong support for data parallelism. Also Akka for actors and such-like. ● Strong static type checking with inferencing and reified generic type parameters.

Slide 11

Slide 11 text

Copyright © 2014 Russel Winder 11 Kotlin ● Top-level functions. ● Object-oriented, with functional elements ● Strong static type checking with inferencing. ● Has modules. ● Allows extension methods. ● Compiles to JavaScript or JVM to support end-to-end Web applications development.

Slide 12

Slide 12 text

Copyright © 2014 Russel Winder 12 Ceylon ● Top-level functions. ● Object oriented with functional features. ● Strong static typing with inference. ● Explicit module system. ● JavaScript and JVM backends so as to be end-to-end for Web applications development.

Slide 13

Slide 13 text

Copyright © 2014 Russel Winder 13 Fantom ● Top-level functions. ● Object-oriented. ● Integrated modules system via pods. ● Targets JVM and CLR.

Slide 14

Slide 14 text

Copyright © 2014 Russel Winder 14 Gosu ● Top-level functions. ● Object-oriented. ● Scripts.

Slide 15

Slide 15 text

Copyright © 2014 Russel Winder 15 ? The identity of this statically typed, object-oriented (with functional bits) language for the JVM will remain unnamed at this time to preserve the air of mystery and suspense.

Slide 16

Slide 16 text

Copyright © 2014 Russel Winder 16

Slide 17

Slide 17 text

Copyright © 2014 Russel Winder 17 Code!

Slide 18

Slide 18 text

Copyright © 2014 Russel Winder 18

Slide 19

Slide 19 text

Copyright © 2014 Russel Winder 19 

Slide 20

Slide 20 text

Copyright © 2014 Russel Winder 20

Slide 21

Slide 21 text

Copyright © 2014 Russel Winder 21 What is the value of ?

Slide 22

Slide 22 text

Copyright © 2014 Russel Winder 22 Well that's easy, it's…

Slide 23

Slide 23 text

Copyright © 2014 Russel Winder 23 

Slide 24

Slide 24 text

Copyright © 2014 Russel Winder 24 Obviously.

Slide 25

Slide 25 text

Copyright © 2014 Russel Winder 25 It's simples Александр Орлов 2009

Slide 26

Slide 26 text

Copyright © 2014 Russel Winder 26 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 1+x2 dx

Slide 27

Slide 27 text

Copyright © 2014 Russel Winder 27 One possible algorithm ● Use quadrature to estimate the value of the integral which is the area under the curve. – π= 4 n ∑ i=1 n 1 1+( i−0.5 n ) 2 With n = 3 not much to do, but potentially lots of error. Use n = 107 or n = 109? Embarrassingly parallel.

Slide 28

Slide 28 text

Copyright © 2014 Russel Winder 28 Because addition is commutative and associative, expression can be decomposed into sums of partial sums.

Slide 29

Slide 29 text

Copyright © 2014 Russel Winder 29 a + b + c + d + e + f = ( a + b ) + ( c + d ) + ( e + f )

Slide 30

Slide 30 text

Copyright © 2014 Russel Winder 30 Scatter Gather — map reduce data parallel

Slide 31

Slide 31 text

Copyright © 2014 Russel Winder 31 Code!

Slide 32

Slide 32 text

Copyright © 2014 Russel Winder 32 Scala Kotlin Ceylon

Slide 33

Slide 33 text

Copyright © 2014 Russel Winder 33 ?

Slide 34

Slide 34 text

Copyright © 2014 Russel Winder 34 Surprise time…

Slide 35

Slide 35 text

Copyright © 2014 Russel Winder 35 JVM is a Groovy place

Slide 36

Slide 36 text

Copyright © 2014 Russel Winder 36 Groovy ● Top-level functions. ● Object-oriented with functional features. ● Extension methods. ● Compiles to JVM bytes codes or JavaScript, cf. GrooScript. ● Runs on Android. ● Scripts. ● A dynamic language with a run time meta-object protocol.

Slide 37

Slide 37 text

Copyright © 2014 Russel Winder 37 Groovy A statically typed, compiled language.

Slide 38

Slide 38 text

Copyright © 2014 Russel Winder 38 @TypeChecked @CompileStatic

Slide 39

Slide 39 text

Copyright © 2014 Russel Winder 39 Groovy ● @TypeChecked: ● Traditional dynamic Groovy but with full static (compile-time) type checking. ● @CompileStatic: ● Full static typechecked, compilation to bytecode at compile time. ● No dynamic meta- object protocol.

Slide 40

Slide 40 text

Copyright © 2014 Russel Winder 40 Code!

Slide 41

Slide 41 text

Copyright © 2014 Russel Winder 41

Slide 42

Slide 42 text

Copyright © 2014 Russel Winder 42 Code!

Slide 43

Slide 43 text

Copyright © 2014 Russel Winder 43 Did I mention invokedynamic?

Slide 44

Slide 44 text

Copyright © 2014 Russel Winder 44 Code!

Slide 45

Slide 45 text

Copyright © 2014 Russel Winder 45 Java is Dead!

Slide 46

Slide 46 text

Copyright © 2014 Russel Winder 46 Groovy (or Scala, Kotlin, Ceylon, Fantom, ) … is the future of static languages on the JVM.

Slide 47

Slide 47 text

Copyright © 2014 Russel Winder 47 2014-03-18

Slide 48

Slide 48 text

Copyright © 2014 Russel Winder 48 Java 8 Released

Slide 49

Slide 49 text

Copyright © 2014 Russel Winder 49 Java 8 is the biggest revolution in Java since 1994. Bigger than Java 5.

Slide 50

Slide 50 text

Copyright © 2014 Russel Winder 50 Has Java revived? Is this a new lease of life?

Slide 51

Slide 51 text

Copyright © 2014 Russel Winder 51 What's Interesting in Java 8? ● G1 garbage collector. ● Nashorn. ● JavaFX. ● Lambda expressions. ● Default methods in interfaces (traits). ● Enhanced collections. ● Method references.

Slide 52

Slide 52 text

Copyright © 2014 Russel Winder 52 G1 garbage collector is now the standard: no more PermGen.

Slide 53

Slide 53 text

Copyright © 2014 Russel Winder 53 Nashorn comes as standard: Server-side JavaScript without Rhino.

Slide 54

Slide 54 text

Copyright © 2014 Russel Winder 54 JavaFX in the distribution: you will want to use GroovyFX though.

Slide 55

Slide 55 text

Copyright © 2014 Russel Winder 55 Lambda expressions, default methods in interfaces, associated collections enhancements.

Slide 56

Slide 56 text

Copyright © 2014 Russel Winder 56 Code!

Slide 57

Slide 57 text

Copyright © 2014 Russel Winder 57

Slide 58

Slide 58 text

Copyright © 2014 Russel Winder 58 Code!

Slide 59

Slide 59 text

Copyright © 2014 Russel Winder 59 Java is Dead Long Live Scala, Kotlin, Ceylon, etc. Russel Winder email: [email protected] twitter: @russel_winder Web: http://www.russel.org.uk

Slide 60

Slide 60 text

Copyright © 2014 Russel Winder 60 Java is Dead Long Live Java Russel Winder email: [email protected] twitter: @russel_winder Web: http://www.russel.org.uk

Slide 61

Slide 61 text

Copyright © 2014 Russel Winder 61 Java is Dead Long Live Groovy Russel Winder email: [email protected] twitter: @russel_winder Web: http://www.russel.org.uk