Hacker News new | ask | show | jobs
by naasking 2965 days ago
C# has had a dynamic type built in for years now. It's literally a dynamically typed language embedded within the statically typed C#,which grew out of the work on gradual type systems.
1 comments

dynamic is just based on COM variant type, before .NET even existed.
C#'s dynamic type has nothing to do with COM.
It shows you never had to implement COM interfaces for Visual Basic Variant type via the IDispatch interface.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms2...

The way dynamic is implemented is exactly following the same idea using DynamicObject instead of IDispatch.

https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.d...

And if you actually bother to read MSDN documentation, one of the use cases for dynamic was to simplify COM automation interop.

https://blogs.msdn.microsoft.com/srivatsn/2008/02/04/dynamic...

https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...

That's not why the dynamic type was created, that was just one side benefit. The dynamic type grew out of the IronPython effort which grew into the DLR in order to better support dynamically typed languages on the CLR, by having reusable polymorphic inline caching for efficient dispatch.

COM integration with the CLR has existed since the beginning, which I used quite extensively many years ago, they just took advantage of the DLR to make it easier.

Still given that it was already available as Variant on Visual Basic before .NET was even an idea, it hardly has anything to do with "which grew out of the work on gradual type systems.".
Visual basic is hardly the first language with a dynamic type, and the DLR is clearly descended from Self, Smalltalk and other dynamically typed languages and started with Iron Python:

https://blogs.msdn.microsoft.com/hugunin/2007/04/30/a-dynami...

VB's variants and COM were not a consideration when conceiving of or designing the DLR, merely a convenient application.

Furthermore, integrating a dynamic type into C#'s type system absolutely built in the work on gradual typing. See their published work: https://www.researchgate.net/publication/221496299_Adding_Dy...