3 ms·
Surely type checking on the keys of effectively arbitrary maps is just a folly. Maps shouldn’t be used for these purposes. If you know the members at compile ti
by Xophmeister 7mo ago
Surely type checking on the keys of effectively arbitrary maps is just a folly. Maps shouldn’t be used for these purposes. If you know the members at compile time, then put them in a proper record type, like a struct or dataclass, etc.
- hirsin 7mo agoRight - it feels like going skin deep on types and then complaining they didn't solve for very deep problems. Like yes, it would be nice for Map(ICar[] cars, keys).wingspan to throw a type error because cars is typed and we know keys can't include things not in ICar. But to say that Map(Any[] things, keys) should have ahead of time type checking seems like you're not really using types except when inconvenient. Which might be taken as a no true scotsman or "holding it wrong" argument but... Maybe they are holding it wrong. (Speaking as a former Windows/CLR PM now working in a Ruby monolith... It's hell and indeed trying to add types via sorbet has been miserable and useless)
- jiehong 7mo agoThe basis of Erlang/Elixir/Clojure is that structs are just inflexible maps. So, this is trying to tackle and type this instead. It’s not wrong, just a different vision.
- ddellacosta 7mo ago> The basis of Erlang/Elixir/Clojure is that structs are just inflexible maps. I mean the difference is that Erlang and Elixir have high-quality pattern matching baked in, not to mention stuff like dialyzer and set-theoretic types. Clojure has multi-methods I guess, and stuff like defrecord that no one uses...and the turd that is spec. In my experience every Clojure codebase turns into map soup at some point without a tremendous amount of manual labor. ...so it's not as black and white as you're saying, I guess is my point. And for example, I'd always take Haskell over Erlang or Elixir even though Haskell's records are widely and justifiably derided, because the language taken as a whole is that much nicer to use, and stuff like lens smooths some of the rough edges over pretty well.
- ddellacosta 7mo agoI dream of a day when everyone is using statically typed languages that support row polymorphism a la PureScript (https://book.purescript.org/chapter4.html#record-patterns-and-row-polymorphism https://book.purescript.org/chapter4.html#record-patterns-an...)...
- jaen 7mo agoTypeScript has row polymorphism at home.
- ddellacosta 7mo agoI lol'ed