This chapter covers
- Incorporating static typing in a dynamic language
- Using the @TypeChecked annotation
- Type inference and flow typing
- Static compilation and the @CompileStatic annotation
- Type checking extensions
We shall not cease from exploration, and the end of all our exploring will be to arrive where we started and know the place for the first time.
T. S. Eliot
There are endless debates in computer programming. vi or emacs? Tabs or spaces? Interfaces or abstract classes? Likewise, the debate over the benefits of static versus dynamic languages is never ending. You’ll find people telling you that static languages are the best because you can find errors at compile time, while on the other side, people will empathize how powerful and concise dynamic code can be. In most languages, you have to choose one or the other. Not so in Groovy.