by staticassertion · 5y ago · 0 comments
`x = call_some_function()`
What can I do with x now? Does it have methods? Which ones? Is it sometimes null? Sometimes a list?
In a typed language I can just look up the type definition, and just as importantly, my IDE will know what I can do as well.
A well designed function/class will have a descriptive name and descriptive parameters, which should give you good hints about their usage. And if it that isn't enough, a quick scan of the code will show you exactly how the function works - a good idea (even in typed languages) if you have any doubts about what you're calling.
The fact that people can program effectively without types is demonstrated by the enormous volume of code in non-typed languages.
At some point you have to convey the type or I have no idea wtf you're giving me, and I'd rather have you convey the type in a way my computer can understand than have you convey it through the godawful way that people name things.
That people manage to do so is no endorsement. Humans managed for quite a while without antiseptic but I don't hear anyone endorsing going around with shit on their hands.
Honestly, I've been programming in both typed and untyped languages for ages and it I am asking how you manage this problem, because I find IDEs radically less effective in dynamically typed languages, I find that I have to ask more questions, do more manual work, etc. In typed languages these things become trivial.
B) I largely agree but I still don't get how people manage without types, though I get why it occurs. People have different brain styles and hence different programming styles. Personally I dislike dealing with untyped code with "descriptive" names, because it's rarely descriptive enough.
I'd take a strong type system with methods like .call(), .string(), .get(), .issue() with an IDE vs overly-descriptive methods like .frob_the_snozzberries() and .squelch_parrots() any day. It's not composable, it's not predictable - wait was it .frob_snozzberries()? There's no symmetry. That style usually accompanies very dynamic code, since if your interface is very specific, .post() only can mean one thing.