What's the rationale for adding dynamic typing to C#?
Is it only to support interop with dynamic languages (Iron*)?
I'm not against the idea but it seems like a minor use-case to add a major language feature for. Unless there's something else I'm missing.
In the past, C# added new language features in order to support some specific goal.
Extension methods, lambdas and expression trees were added mainly to support LINQ. They're good features on their own, for sure, but the reason they were added is because the language team wanted to do LINQ.
I've tried to come up with which use-cases make sense for C#'s dynamic as well..
Where I mostly could figure that it would really help is with COM interop. Working with something like MS Office is fairly painful in C#3, since you have to pass the "Missing" argument to each of the 20-30 arguments that every method can take, and cast the result of every method.. The named arguments feature would also be useful there.
I've been fortunate enough to avoid having to interop with COM that directly recently, so haven't had to find out whether or not it makes a difference.
I know in C# 5 they're planning on adding compilers as a service - the dynamic keyword might be necessary for that scenario but I'm not sure why the existing implicit typing system wouldn't work either.
COM interop is a popular culprit for this subject too.
Another possibility, although one that is somewhat dimmed by the virtual demise of Iron* within Microsoft, is that Microsoft wanted C# to be able to interop with other dynamic languages like IronRuby and IronPython. I can imagine a scenario where an IronRuby application could pass off a dynamically typed object to a shared library implemented in C# which supported DLR (dynamic language runtime) for some set of common functionality. I don't know much about what's possible today with respect to CLR objects passing between the DLR and the statically typed portions of the CLR, but I figured it was worth hazarding a guess.
I just looked this up on Jon Skeet's website, and apparently he doesn't know either. Here is a lively thread where he posed the question to his readers:
Is it only to support interop with dynamic languages (Iron*)?
I'm not against the idea but it seems like a minor use-case to add a major language feature for. Unless there's something else I'm missing.
In the past, C# added new language features in order to support some specific goal.
Extension methods, lambdas and expression trees were added mainly to support LINQ. They're good features on their own, for sure, but the reason they were added is because the language team wanted to do LINQ.
What's the larger goal here?