Monday, April 18, 2011

Generics : Static vs Dynamic typing

Static/strong typing. One of the attractions of Java is that it has what is known as strong typing -- the type of variables (and other elements) is declared and values assigned to the variable must but that type. This causes more busy work when writing the program to get the types right, but the error messages that the compiler produces are much better than allowing code that might assign incorrect types at runtime.

Dynamic/weak typing is used in some languages (eg, Ruby), which allow different type values to be assigned to variables, which then have the type of the last assigned variables. Proponents of this approach say that not having to worry about getting types correctly specified in the source code makes coding faster, and with TDD (Test-Driven Development) any bad assignments are quickly discovered and fixed.
Java uses static/strong typing and the introduction of generics allows even stronger typing.

No comments:

Post a Comment

Chitika