(no title)
ungamedplayer | 1 year ago
I know how to deal with missing values or variability in maps, and so do a lot of people.. what am I missing here?
ungamedplayer | 1 year ago
I know how to deal with missing values or variability in maps, and so do a lot of people.. what am I missing here?
bloppe|1 year ago
When the data is not uniform (different keys point to differently-typed values), and not as dynamic (maybe your data model evolves over time, but certain functions always expect certain keys to be present), a dict is like a cancer. Sure, it's simple at first, but wait until the same dict gets passed around to a hundred different functions instead of properly-typed parameters. I just quit my job tech at a company that shall remain nameless, partially because the gigantic Ruby codebase I was working on had a highly advanced form of this cancer, and at that point it was impossible to remove. You were never sure if the dict you're supplying to some function had all the necessary keys for the function it would eventually invoke 50 layers down the call stack. But, changing every single call-site would involve such a major refactor that everybody just kept defining their functions to accept these opaque mega-dicts. So many bugs resulted because of this. That was far from the only problem with that codebase, but it was a major recurring theme.
I learned this lesson the hard way.
cornholio|1 year ago
scotty79|1 year ago
If getting a filed of your object had the same syntax as getting a value from a dict you could easily replace dicts with smarter, more rigid types at any point.
My dream is a language that has the containers share as much interface as possible so you can easily swap them out according to your needs without changing most of the code that refers to them. Like easily swap dict for BTreeMap or Redis.
I think the closest is Scala but it fallen out of favor before I had a chance to know it.
lispisok|1 year ago
Here is Rich Hickey with an extreme counter example although I would argue he's really demonstrating against getters and setters. https://www.youtube.com/watch?v=aSEQfqNYNAc
unknown|1 year ago
[deleted]
nlitened|1 year ago
As a result, they are very powerful and simple to use.
orf|1 year ago
The issue is that the concrete types are implicit. Depending on the language, runtime or type system expressing the type in a “better” way might be very hard or un-ergonomic.