4 ms·
> a big problem w/ static languages is that the developers of these languages are not willing to compromise type-safety for simplicity: there are very few 80/20
by Someone 3y ago
> a big problem w/ static languages is that the developers of these languages are not willing to compromise type-safety for simplicity: there are very few 80/20 type systems out there that just say "Well, that's too hard to deal w/ you can bail out to unsafe code" when the implementation gets too crazy.
Very few? Many languages allow you to cast references to other types at will.
C# does one better with its ‘dynamic’ keyword, which makes it much clearer where you are using runtime method lookup. https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/interop/using-type-dynamic https://learn.microsoft.com/en-us/dotnet/csharp/advanced-top...:
“The dynamic type is a static type, but an object of type dynamic bypasses static type checking. In most cases, it functions like it has type object. The compiler assumes a dynamic element supports any operation”
I think Swift copied that. https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations/ https://docs.swift.org/swift-book/documentation/the-swift-pr...:
“When you mark a member declaration with the dynamic modifier, access to that member is always dynamically dispatched using the Objective-C runtime.“
- brabel 3y agoAdd Dart to your list.
- KaiserPro 3y agoI do like c#'s dynamic and unsafe bits. it clearly telegraphs that someone is doing something either clever, stupid, desperate or all three.
- Akronymus 3y agoF# goes even further than c# and allows you to embed IL. Which allows you to do really fun things.
- akkad33 3y agoI'm very curious about F#. Can you give some code examples of how this allows dynamic typing?
- Akronymus 3y agoYou rarely, if ever, need it, except for performance considerations. https://youtu.be/NZ5Lwzrdoe8?t=2364 https://youtu.be/NZ5Lwzrdoe8?t=2364 This is the one thing that comes to mind, for me.
- WorldMaker 3y agoIn C# plenty of things embed IL, they just use the Reflection.Emit APIs to do that and don't have a direct embedded DSL. An advantage to C#'s dynamic over Reflection.Emit is that it uses System.Linq.Expressions under the hood. There's a lot of cool advantages to do that, including higher level caching and sharing a lot of the same infrastructure of IQueryable (and IQbservable, the Q there is not a typo). The DLR remains an underappreciated bit of great .NET engineering. (It doesn't help that most of the Iron languages went to maintenance bitbuckets.) (In a past life I did some amazing things with the DLR.)