7

I am experiencing deju vu:
https://reddit.com/r/csharp/...

dude: Why doesn't C# do this dynamic "like" thing?

community: How dare you like something from another language?! Don't you know C# is strongly type?! Dynamic is a curse on your children! <gets out torches and pitchforks>

random dude: Why don't you use <this method> to do this?

dude: Thanks "random dude", this does what I was looking for with a bit different syntax than I was expecting.

lol

Programmers are awesome!

Comments
  • 1
    is that awesome

    is it
  • 4
  • 1
    To be fair though. When I did it I just insulted C# and probably deserved the hate.
  • 1
    IIRC, dynamic has also an impact on runtime performance. One more reason to avoid it.
  • 3
    There are very specific pretty advanced scenarios where you should mention `object`, usually related to the universal operations defined by Object which are equality, hashing, destruction, synchronization and reflection. If your use case isn't one of these, or something else I forgot that is defined by Object, you're holding it wrong.
  • 1
    Terrible news everyone, C# does in fact support Pythhon-style dynamic typing:

    https://learn.microsoft.com/en-us/...

    It's obviously way slower than normal C#, but thhis is now a supported uuse case :(
  • 1
    You can write dynamically typed stuff using C#/.NET. Years ago there was the Boo Programming Language.

    It hasn't been maintained in years though. There are .NET bindings and implementations for Python, and other non-typed languages.
  • 0
    @djsumdog I don't actually want dynamically typed stuff. My first post was not being able to just read a json file without creating class shells for serialization. I found from that post that there is a way to deserialize json which seems similar to Qt (C++) deserialization of json. I just found the responses humorous. I have learned quite a bit from both those posts.
  • 1
    @djsumdog I mean, if transpilation is fair game then you can write dynamic code for any platform. I'm not sure how the DLR works and I'm hesitant to learn .NET internals because despite market demand I don't want to become a .NET developer, but one way to implement dynamic with the base CLR would have been to just translate property access and method call into reflection.
  • 0
    Ew, Reddit.
Add Comment