Greach Lightning Talk
1st Career
2nd Career
OCI Grails Team
Cruisin' to easy migration and interop
Caution for potholes & speed bumps
Stopping for rework or collisions
Anywhere you see a parrot means this inconsistency with Java will be changing when the new "parrot" grammar changes are available in Groovy 3.0 and maybe as options in 2.5.x
trait Singer {
int songLength
void sing() {
println "Oh say can you see..."
}
}
class Teacher implements Singer { }
class Student implements Singer {
void sing() {
println "Twinkle twinkle little star..."
}
}
Java 8 introduced streams, method references and lambdas
Groovy doesn't support lambdas and Java method references, but has its own method reference mechanism)
== means compareTo(obj) or equals(obj)
"spacheship" operator means compareTo
In Java, x == y means: Is x same obj ref as y?
a.is(b)
a === b
@CompileStatic bypasses Groovy MOP
Note Groovy method pointers
Groovy has never supported do/while
To Groovy, do { } looks like do(Closure)
In Groovy, all types are objects so the variable five is not an int, but an Integer. This means the method(Integer) will be called.
Output in Java:
In Java, promotion has higher precedence than autoboxing
Migration from Java and interop with Java is almost trivial
There are a few issues arising from the differences between Groovy and Java, but these are easy to remedy
Very few issues are irreconcilable, such as keyword conflicts.