C# in Depth

Cover of C# in Depth
Order now (3rd edition)

Feature in a dynamic language != dynamic language feature

Chapter 13: Elegant code in the new era: 13.1.2

Created: 3/6/2008
Last updated: 3/6/2008

In the book I mention that some of the features in C# 3 which make life more pleasant (such as object/collection initalizers and implicitly typed local variables) look like they come from dynamic languages. However, that's not to say they work the same way in C# as they do in truly dynamic languages. Eric puts it well:

These are features that make statically typed languages look textually more like dynamic languages, but of course none of these are dynamic language features. It's not that dynamic languages just hide the type information from you. In many cases, it is in principle impossible to deduce the type of a thing in a dynamic language. Consider Jscript with "eval", for example, where code at runtime can arbitrarily change the contents of local variables. There’s no "implicity typing" there – there's no typing at all!