Groovy & Java

Preview:

Citation preview

Groovy vs Java

NOV 2011

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.

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

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 ?

DEMOS

What are you doing?

Let's go to see CODE !!!

https://github.com/pablomoretti/ppt-groovy-vs-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

@elsantob

Questions ?

Recommended