why groovy when java 8 or scala, or…

56
Copyright © 2012 Russel Winder 1 Why Groovy When Java 8, Or Scala, Or… Russel Winder email: [email protected] xmpp: [email protected] twitter: russel_winder

Upload: russel-winder

Post on 28-Jan-2015

117 views

Category:

Technology


0 download

DESCRIPTION

My presentation at Groovy and Grails eXchange 2012. Trying to tease out various issues in the tension between dynamic and static languages on the JVM. Groovy is the only language that can be both a dynamic and a static language.

TRANSCRIPT

Page 1: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 1

Why Groovy When Java 8,Or Scala, Or…

Russel Winder

email: [email protected]: [email protected]

twitter: russel_winder

Page 2: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 2

Aims, Goals and Objectives

● Show that Groovy cannot be complacent about it's place in the JVM-verse.

● Survive till the end of the session…

Page 3: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 3

Structure

A beginning.

A middle.

An end.

Page 4: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 4

Protocol

● Questions or short comments during the session are entirely in order.

● Let me know you have an interjection by raising your hand, and when I come to an appropriate pause, I'll pass you the token.

Questions, answers, comments, etc. appearingto get too long as interjections may get stackedto be unstacked at a break.

Page 5: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 5

Interstitial Advertisement

Page 6: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 6

Frontispiece

Page 7: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 7

Page 8: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 8

Page 9: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 9

A Preface

Page 10: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 10

Friends, programmers, humans,

lend me your ears;

Page 11: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 11

I come to bury Groovy,not to praise it.

Page 12: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 12

A Beginning

Page 13: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 13

Staticallytypedlanguages

Dynamicallytypedlanguages

WAR

Page 14: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 14

Static Typing Mandatory

● Compilers catch:● Incorrect use of types.● Silly spelling errors.

● Need fewer tests.

● Compiled direct to target:● Less overhead.● Faster

● Can work with big code bases because of the testable modularity.

Page 15: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 15

Catch errors early, before execution.

Computational performance is all that matters.

Page 16: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 16

Apart from correct implementation.

Page 17: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 17

And the right functionality

Page 18: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 18

And good user experience.

Page 19: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 19

Dynamic is Inadequate

● Cannot program to interfaces.

● Have to write tests for things a compiler can (and should) catch trivially.

● Have to run the code to find out anything.

● Every action is “interpreted” and so slow.

● Difficult to work with big codebases.

Page 20: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 20

Languages such as

Java, Scala, Kotlin, Ceylon

work where

Groovy, JRuby, Jython, Closure

result in incomprehensible codes.

Page 21: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 21

Staticallytypedlanguages

Dynamicallytypedlanguages

Groovy

Page 22: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 22

Groovy is in the middle of the battlefield by trying to be both dynamic and static.

Page 23: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 23

Guillaume Laforge emphasized@TypeChecked and @StaticCompilein his GGeX 2012 opening keynote.

Page 24: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 24

Guillaume Laforge emphasizedmaking Groovy static by default

in his GGeX 2012 opening keynote.

Page 25: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 25

Why turn a perfectly good dynamic language into a static one?

Page 26: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 26

Let's not worry too much about RPython and CPython and PyPy. Or perhaps we should…

Page 27: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 27

Just use a good designed to be statically-typed language from the outset?

Page 28: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 28

Scala

● Doesn't have the same data model as Java.● Is in it's own world effectively.● So Scala projects generally all Scala.

Page 29: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 29

Ceylon

● Doesn't have the same data model as Java.● Is in it's own world effectively.● So Ceylon projects generally all Ceylon.

Ceylon supports optional typing!

Page 30: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 30

Kotlin

● Doesn't have the same data model as Java.● Is in it's own world effectively.● So Kotlin projects generally all Kotlin.

Page 31: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 31

If a language has to define it's owndata structures library then you begin

to think there is a problem.

Page 32: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 32

Or perhaps the Java Collections framework is fundamentally broken?

Page 33: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 33

Java 8

● Has exactly the same data model as Java.● Is the new world effectively.● So Java 8 projects generally all Java.

The only question is when to upgradefrom Java 5, 6 and 7 to Java 8.

Page 34: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 34

Intermission

Page 35: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 35

http://steveonjava.com/nighthacking/

Page 36: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 36

The fight is

JavaFX

vs.

GroovyFX

Page 37: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 37

But, soft! what light through yonder window breaks?

Page 38: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 38

A Middle

Page 39: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 39

Jave 8 evolves the Collections framework by introducing public defender methods.

Page 40: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 40

Backward compatibility assured.

Page 41: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 41

Data Parallelism in Collections.

Page 42: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 42

Data ParallelismTransform a sequence to another sequence all actions happen at the same time logically.

Page 43: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 43

GPars redundant?

Page 44: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 44

ActorsIndependent processes communicating via asynchronous exchange of messages

CSPSequential processes connected by channels using synchronous message exchange (rendezvous).

DataflowOperators connected by channels with activity triggered by arrival of data on the channels.

Page 45: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 45

ActorsIndependent processes communicating via asynchronous exchange of messages

Page 46: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 46

DataflowOperators connected by channels with activity triggered by arrival of data on the channels.

Page 47: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 47

CSPSequential processes connected by channels using synchronous message exchange (rendezvous).

Page 48: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 48

The End

Page 49: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 49

To Groovy or not to Groovy…

Page 50: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 50

…that is the question.

Page 51: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 51

Page 52: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 52

Is static Groovy a better language than Java 8?

Page 53: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 53

Groovy has 6 months to stake it's claim to hegemony over the JVM space.

Page 54: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 54

Surreptitious Advertisement

Page 55: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 55

DevoxxUK 2013

2013-03-26 & 2013-03-27

http://www.devoxx.com/display/UK13/Home

Page 56: Why Groovy When Java 8 or Scala, or…

Copyright © 2012 Russel Winder 56

Why Groovy When Java 8,Or Scala, Or…

Russel Winder

email: [email protected]: [email protected]

twitter: russel_winder