3 ms·
> I don't see any static language trying to move in a dynamic direction. C# added "dynamic" keyword in 4.0.
by sanxiyn 11y ago
> I don't see any static language trying to move in a dynamic direction.
C# added "dynamic" keyword in 4.0.
- jerf 11y agoPoint. And it's a non-trivial implementation, from the look of it. A lot of static languages have "a thing that can be passed around as a 'dynamic' value but has to be cast back to a static type to do anything", but the C# feature is much more than that. https://msdn.microsoft.com/en-us/library/dd264736.aspx https://msdn.microsoft.com/en-us/library/dd264736.aspx
- wtetzner 11y agoScala has a dynamic feature as well.
- jerf 11y agoHow long has it been there? Also, I observe on the docs page this little note that says "As of Scala 2.10, defining direct or indirect subclasses of this trait is only possible if the language feature 'dynamics' is enabled." Almost all the static languages have some sort of dynamic feature already, and generally have since day one. The mere existence of "dynamic" features isn't my point. The question is, how often are they used, and is the language tending towards more of them or less of them? I don't do Scala, so I can't speak to it, but does every little Scala program use this dynamic package, or is it something rarely reached for, and even perhaps considered a code smell by the community? If it's the latter, then it's not a huge notch in the "dynamic" belt. I'm discussing the first derivative, not the current state of the world.
- wtetzner 11y agoI don't think it's considered a code smell, but it is intended to be used only for cases where the problem your modelling really is dynamic. Basically, in cases where you end up having classes that have methods like def lookup(name: String): Any you can instead use Dynamic, meaning instead of having calls like this: myObj.lookup("foo") you can do this: myObj.foo So no, Scala isn't really trying to become more dynamic, but it has a feature for dealing with problems that are dynamic anyway.
- incepted 11y agoAnd nobody uses it (besides, Scala is in decline too).
- marcosdumay 11y agoAnd C++ added "auto". But both of them are about type inference, not dynamic types.
- wtetzner 11y agoNo, C#'s dynamic keyword is actually about dynamic types. C#'s var keyword is about type inference.