why groovy when java 8 or scala, or…

Post on 28-Jan-2015

117 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

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

Copyright © 2012 Russel Winder 1

Why Groovy When Java 8,Or Scala, Or…

Russel Winder

email: russel@winder.org.ukxmpp: russel@winder.org.uk

twitter: russel_winder

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…

Copyright © 2012 Russel Winder 3

Structure

A beginning.

A middle.

An end.

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.

Copyright © 2012 Russel Winder 5

Interstitial Advertisement

Copyright © 2012 Russel Winder 6

Frontispiece

Copyright © 2012 Russel Winder 7

Copyright © 2012 Russel Winder 8

Copyright © 2012 Russel Winder 9

A Preface

Copyright © 2012 Russel Winder 10

Friends, programmers, humans,

lend me your ears;

Copyright © 2012 Russel Winder 11

I come to bury Groovy,not to praise it.

Copyright © 2012 Russel Winder 12

A Beginning

Copyright © 2012 Russel Winder 13

Staticallytypedlanguages

Dynamicallytypedlanguages

WAR

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.

Copyright © 2012 Russel Winder 15

Catch errors early, before execution.

Computational performance is all that matters.

Copyright © 2012 Russel Winder 16

Apart from correct implementation.

Copyright © 2012 Russel Winder 17

And the right functionality

Copyright © 2012 Russel Winder 18

And good user experience.

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.

Copyright © 2012 Russel Winder 20

Languages such as

Java, Scala, Kotlin, Ceylon

work where

Groovy, JRuby, Jython, Closure

result in incomprehensible codes.

Copyright © 2012 Russel Winder 21

Staticallytypedlanguages

Dynamicallytypedlanguages

Groovy

Copyright © 2012 Russel Winder 22

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

Copyright © 2012 Russel Winder 23

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

Copyright © 2012 Russel Winder 24

Guillaume Laforge emphasizedmaking Groovy static by default

in his GGeX 2012 opening keynote.

Copyright © 2012 Russel Winder 25

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

Copyright © 2012 Russel Winder 26

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

Copyright © 2012 Russel Winder 27

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

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.

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!

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.

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.

Copyright © 2012 Russel Winder 32

Or perhaps the Java Collections framework is fundamentally broken?

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.

Copyright © 2012 Russel Winder 34

Intermission

Copyright © 2012 Russel Winder 35

http://steveonjava.com/nighthacking/

Copyright © 2012 Russel Winder 36

The fight is

JavaFX

vs.

GroovyFX

Copyright © 2012 Russel Winder 37

But, soft! what light through yonder window breaks?

Copyright © 2012 Russel Winder 38

A Middle

Copyright © 2012 Russel Winder 39

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

Copyright © 2012 Russel Winder 40

Backward compatibility assured.

Copyright © 2012 Russel Winder 41

Data Parallelism in Collections.

Copyright © 2012 Russel Winder 42

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

Copyright © 2012 Russel Winder 43

GPars redundant?

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.

Copyright © 2012 Russel Winder 45

ActorsIndependent processes communicating via asynchronous exchange of messages

Copyright © 2012 Russel Winder 46

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

Copyright © 2012 Russel Winder 47

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

Copyright © 2012 Russel Winder 48

The End

Copyright © 2012 Russel Winder 49

To Groovy or not to Groovy…

Copyright © 2012 Russel Winder 50

…that is the question.

Copyright © 2012 Russel Winder 51

Copyright © 2012 Russel Winder 52

Is static Groovy a better language than Java 8?

Copyright © 2012 Russel Winder 53

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

Copyright © 2012 Russel Winder 54

Surreptitious Advertisement

Copyright © 2012 Russel Winder 55

DevoxxUK 2013

2013-03-26 & 2013-03-27

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

Copyright © 2012 Russel Winder 56

Why Groovy When Java 8,Or Scala, Or…

Russel Winder

email: russel@winder.org.ukxmpp: russel@winder.org.uk

twitter: russel_winder

top related