7
Groovy vs Java NOV 2011

Groovy & Java

Embed Size (px)

Citation preview

Page 1: Groovy & Java

Groovy vs Java

NOV 2011

Page 2: Groovy & Java

The real battle is static vs dynamic typingIn other words:

● Static : The type of each variable (or expression) must be known at compile time.

● Dynamic: Type information is known only at runtime.

Page 3: Groovy & Java

Which are their super powers ?

● Static Typing–Errors are often detected earlier and with better error messages–Better IDE support–Better optimisations are often possible

● Dynamic Typing–Speeds up development through duck-typing–Allows more expressiveness through DSLs

Page 4: Groovy & Java

We choose the dynamic way

Many of the rules and patterns we have been taught no longer apply

1. Patterns to review○ Singleton○ Resources○ Delegation○ ...

2. Performace○ Java always wins ?○ We need win ?

Page 5: Groovy & Java

DEMOS

What are you doing?

Let's go to see CODE !!!

https://github.com/pablomoretti/ppt-groovy-vs-java

Page 6: Groovy & Java

Lessons ● Testing the Duck:

Used when flexibility is important, but it has appropriate tests in place.

● Static Typing isn't the bad guy of the movie:Used when we know that code doesn´t need to be dynamic; typing is useful to shed some light on code.

● Interface-oriented design:The use of interfaces is not necessary, but they are useful.

● Performance:In Groovy, the sensitive parts can always be written in Java

Page 7: Groovy & Java

@elsantob

Questions ?