Is there a case where you wrote something in such a language (e.g. C#, Java), and missed duck typing? (See this question for arguments against duck typing)
That other question had little to do with duck typing. Anyway, assuming this doesn't get closed I'd say the one time I really miss duck typing is when trying to test classes with big API's. We need a separate framework to create mocks of them while in another programming language you could conceivably just pass in a self written class that implements the bare basics of what you need.
For instance, try to mock a JDBC ResultSet in java without a framework, it's a bit of a pain.
Every time you need to work with code that you do not own, and that does not have proper abstraction (HttpContext anyone?). As you can't have a method of yours accept IHttpContext, since HttpContext type does not have that kind of abstraction, you have to settle for an Adapter and/or Factory and such. Would have been extremely nicer if you could have defined the IHttpContext contract in your code, make it look like the HttpContext, set your method to accept IHttpContext, and have a true, real HttpContext object passed in to duck into IHttpContext.
Never. Been using Java since the '90's and Python since '01 or so.
Here's why I never missed duck typing in Java.
The "Duck Typing in Java Question" is really about an absolute failure to understand Polymorphism. If you ever think you need any kind of run-time type identification or "isinstance" functionality, you've failed to grasp Polymorphism and you're doing it wrong.
See the Programmer Ignorance Pet Peeve question. Failure to grasp polymorphism is a huge problem and leads to this "duck typing in Java" mistake.
If you understand polymorphism, you don't need duck typing and you don't miss it when switching between Python and Java.
On a related note, I only use Python's isinstance()
as part of an assertion to make a function that requires integers blow up when it gets a non-integer. isinstance()
is sometimes used with attempts in Java to do duck-typing-like things.
The point is that I'm old (52) and not very smart. So I have to keep to a "strong-ish" class hierarchy in Python or I get confused. I always left a space in a Python design for refactoring into more strict class hierarchy if it become necessary.