12 votes

I am disappointed by dynamic typing

3 comments

  1. Eji1700
    Link
    I was never a huge fan of dynamic typing just because of all the unintentional consequences and bugs it could introduce. They weren't worth the payoff of the supposed benefits. I was going to...

    I was never a huge fan of dynamic typing just because of all the unintentional consequences and bugs it could introduce. They weren't worth the payoff of the supposed benefits.

    I was going to stick to C# because of this, but really think languages will all start handling it more like F# (which infers the type wherever possible, errors if it can't until you type it).

    Most of their examples just seem to be a much higher level of the discovery I already went through.

    3 votes
  2. em-dash
    Link
    I think the thing I'm missing here is why any of the author's proposed features depend on dynamic typing. For example: Lots of statically typed languages have callable non-function objects! Fewer...

    I think the thing I'm missing here is why any of the author's proposed features depend on dynamic typing. For example:

    We can replace a function with an object that can be called for the exact same behavior, but also gives us an information sidechannel.

    Lots of statically typed languages have callable non-function objects! Fewer let you replace functions, but that's not a dynamic typing thing, that's a "considering globally-defined functions to be constants" thing. That the two tend to correlate is a property of how languages influence each other, not of the type system.

    For example, here's a direct C++ translation of the Python example from the article, using a mutable function reference since you can't overwrite the function directly.

    2 votes
  3. teaearlgraycold
    Link
    At a fundamental level what I really want is a language that is all-pointers and has managed memory. Dealing with Rust memory constraints is annoying. Sometimes you need to operate at that level,...

    At a fundamental level what I really want is a language that is all-pointers and has managed memory. Dealing with Rust memory constraints is annoying. Sometimes you need to operate at that level, but mostly it's not necessary. Most dynamically typed languages are easier to work in because the size of each variable/parameter is constant, thus making every variable a universal value slot. In addition I don't want to think much about when memory is allocated or released because the stuff I work with doesn't operate in "real time".

    My favorite dynamically typed language is TypeScript. Any person pretending like they don't need to declare the types in their dynamically typed code is a fool. Thankfully TypeScript gives you a few escape-hatches. JSON.parse returns any. Thrown objects are unknown. Maybe you know a few of the most likely options for a parameter but there are others of unknown type.

    type MyUnion =
      | { type: "a"; value: string }
      | { type: "b"; value: number }
      | { type: "c", value: unknown };
    

    That's dynamic typing and not something you can do as easily in a statically typed language. A statically typed language might have a void * type of escape hatch. But in C there's no built in reflection so you're at a dead end unless you know what the type is. Static languages with reflection kind of approach this same solution from the other side. Actually, I feel like we're slowly getting towards a middle point. We've taking dynamic languages and given developers the tools to make them behave more like they're static. And we've taken static languages and given developers the tools to make them behave more like they're dynamic.

    1 vote