4 ms·
Never. This is why we write small functions that, as much as possible, depend only on their inputs and avoid mutation. Code becomes simple to reason about. You
by emidln 6y ago
Never. This is why we write small functions that, as much as possible, depend only on their inputs and avoid mutation. Code becomes simple to reason about. You don't need to worry when composing these small pieces like you do when passing mutable objects, using out variables, etc.
- eropple 6y agoSee, that's interesting. 'Cause I do write small functions, I do avoid side effects, I do avoid mutation--and writing code in dynamically typed languages still bites me when I'm forced to do it. (It isn't really any faster to write, either.) So you could be leaps and bounds better than me. Or you could be--let's be generous and call it "optimistic to a fault"--and retrofitting to a narrative about Good Programmers Don't Need Guardrails. And, TBH, I see a lot of people who are the latter and very few who are the former--and most of that very few tend towards statically or at least optionally typed languages by default. So forgive me if I don't believe you.
- ronanyeah 6y agoAnything to justify not learning a new language.
- jimnotgym 6y agoAn experienced developer I know with a dead simple function fell for the classic 10+20+30=102030 bug the other day. Had it not been noticed in production it would have been very costly. It was an edge case he had not encountered in the wild, but had thought to handle just-in-case. Integration tests missed it too. Sure, good unit tests could have caught it, but Typescript would not have allowed it in the first place.