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

Java is Dead, Long Live Ceylon, Kotlin, etc

Embed Size (px)

Citation preview

Page 1: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 1

Java is DeadLong Live Ceylon, Kotlin, etc.

Dr Russel Winder

email: [email protected]: @russel_winder

Web: http://www.russel.org.uk

Page 2: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 2

Java is Dead

Page 3: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 3

Java is Dying

Page 4: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 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.

● …

Page 5: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 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 been doing great work on this for a while, but )…

● Have a reasonable module system, cf. Jigsaw vs. OSGi.

● Be a real object-oriented language.

Page 6: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 6

Prognosis: not great

Page 7: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 7

Trust me I'm a doctor.

Page 8: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 8

Alternatives?

Page 9: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 9

Create a new language

● Java is a statically typed, compiled language, so create a new statically typed compiled language:

● Kotlin, Ceylon

● Scala, Frege

● Fantom

● Gosu

● ?

Page 10: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 10

Gross oversimplifications…

Page 11: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 11

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.

Page 12: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 12

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.

● Runs on Android.

Page 13: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 13

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.

Page 14: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 14

Frege

● Pure functional language based on Haskell.

● Completely declarative.

● Strong static type checking.

Page 15: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 15

Fantom

● Top-level functions.

● Object-oriented.

● Integrated modules system via pods.

● Targets JVM and CLR.

Page 16: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 16

Gosu

● Top-level functions.

● Object-oriented.

● Scripts.

Page 17: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 17

?

The identity of this statically typed, object-oriented (with functional bits) language for the JVM will remain unnamed at this time to preserve an air of mystery and suspense.

Page 18: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 18

Page 19: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 19

Code!

Page 20: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 20

Page 21: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 21

Page 22: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 22

Page 23: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 23

What is the value of ?

Page 24: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 24

Well that's easy, it's…

Page 25: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 25

Page 26: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 26

Exactly.

Page 27: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 27

It's simples. Александр Орлов 2009

Page 28: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 28

But is it irrational?

Page 29: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 29

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

Page 30: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 30

One possible algorithm

● Use quadrature to estimate the value of the integral which is the area under the curve.–

π=4n∑i=1

n 1

1+(i−0.5n

)2

With n = 3 not much to do, but potentially lots of error. Use n = 107 or n = 109?

Embarrassingly parallel.

Page 31: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 31

Code!

Page 32: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 32

JavaCeylonKotlinScalaFrege

Page 33: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 33

Because addition is commutative andassociative, expression can be

decomposed into sums of partial sums.

Page 34: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 34

a + b + c + d + e + f

=

( a + b ) + ( c + d ) + ( e + f )

Page 35: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 35

Scatter Gather—

map reduce

data parallel

Page 36: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 36

Code!

Page 37: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 37

JavaCeylonKotlinScala

Page 38: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 38

?

Page 39: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 39

Surprise time…

Page 40: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 40

JVM is a Groovy place

Page 41: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 41

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.

Page 42: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 42

Groovy

A statically typed,compiled language.

Page 43: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 43

@TypeChecked

@CompileStatic

Page 44: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 44

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.

Page 45: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 45

Code!

Page 46: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 46

Page 47: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 47

Code!

Page 48: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 48

Java is not the future programming language for

the Java Platform.

Page 49: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 49

Kotlin, Ceylon, Groovy, Scala, Frege, …are the future of static languages

on the Java Platform.

Page 50: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 50

2014-03-18

Page 51: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 51

Java 8Released

Page 52: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 52

Java 8 has been the biggest revolution in Java since 1994.

Bigger than Java 5.

Page 53: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 53

Has Java revived?

Is this a new lease of life?

Page 54: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 54

What's Interesting in Java 8?

● G1 garbage collector.

● Nashorn.

● JavaFX.

● Lambda expressions.

● Default methods in interfaces (traits).

● Enhanced collections.

● Method references.

Page 55: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 55

G1 garbage collector is now the standard: no more PermGen.

Page 56: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 56

Nashorn comes as standard:Server-side JavaScript without Rhino.

Page 57: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 57

JavaFX in the distribution:you will want to use GroovyFX though.

Use Griffon

Page 58: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 58

Lambda expressions, method referencesdefault methods in interfaces,

associated collections enhancements.

Page 59: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 59

Code!

Page 60: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 60

Java is DeadLong Live Kotlin, Ceylon, etc.

Russel Winder

email: [email protected]: @russel_winder

Web: http://www.russel.org.uk

Page 61: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 61

Java is DeadLong Live Java

Russel Winder

email: [email protected]: @russel_winder

Web: http://www.russel.org.uk

Page 62: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 62

Java is DeadLong Live Groovy

Russel Winder

email: [email protected]: @russel_winder

Web: http://www.russel.org.uk

Page 63: Java is Dead,  Long Live Ceylon, Kotlin, etc

Copyright © 2015 Russel Winder 63

Java is DeadLong Live Kotlin, Ceylon, etc.

Russel Winder

email: [email protected]: @russel_winder

Web: http://www.russel.org.uk