Can someone educate me in why dicts are uncool for explained reasons, but clojure (which seems to be highly recommended on hn) seems to suffer the same issues when dealing with a map as a parameter (ring request etc).
I know how to deal with missing values or variability in maps, and so do a lot of people.. what am I missing here?
Dicts are great when the data is uniform and dynamic, like an address book mapping names to contact info. You never assume that a key must be in there. Lookups can always fail. That's normal for this kind of use-case.
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.
This should be the top answer. It's not about using dicts in their primary use case, it's about abusing them as a catch all variadic parameter for quick prototyping and "future expansion"
I think the problem is that different data containers have completely different interfaces.
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.
Maps arent nearly as problematic in clojure because data is immutable by default on top of the functional paradigm where your program is basically a big composition of functions and the language is built around using maps. In Python I largely agree with the author. In clojure I love my maps.
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
In Clojure, maps don’t have either of the flaws highlighted in the article. They are neither opaque (they are self-describing with namespaces keys) nor mutable.
As a result, they are very powerful and simple to use.
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.
Yes, it was a lot easier to do this as a single guy without a family and pretty minimal material desires.
Mostly it was just living from savings - the first time was a working holiday overseas doing seasonal work with long stretches of time off in between. Later on in my career I was able to save more by keeping my standard of living low (and not buying a house, perhaps unfortunately).
Ultimately I don't think you need to quit everything to see through these beliefs. Meditation was a big part of the process for me and I didn't spend that long doing it. If you watch the mind close enough it becomes clear that so much of what seems so true and real is nothing more than a belief.
He is not speaking for me but all enterprise projects I worked was like that. When devs (me included) run out of high priority tasks we ask or are directed to more high priority tasks, not fix the minor label/input issue, or the border of the disabled button in resolutions smaller than 400px, or whatever the PM/Scrum master didn't prioritize. Tired of bad management, developers just do what master Jira tell us to do.
I do my best to fix all open bugs in my own software, tho.
For example, would you debate with every flat earther you see? It's simply not worth the time spent. Maybe they fall into the idiot category though.