Dynamic Typing

Dynamic typing relaxes the typing requirements. We let the language figure out the type based on the context.

What’s the advantage of dynamic typing? Is it worth forgoing the benefit of type verification or confirmation at compile time or code-editing time? Dynamic typing provides two main advantages, and the benefits outweigh the costs.

We can write calls to methods on objects without nailing down the details at that moment. During runtime, objects dynamically respond to methods or messages. We can achieve this dynamic behavior to a certain extent using polymorphism in statically typed languages. However, most statically typed languages tie inheritance to polymorphism. They force us to conform to a structure rather than to ...

Get Programming Groovy 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.