4 ms·
We all have an attention budget. If a static type system frees us from thinking about certain types of errors, then we can direct that attention to other areas
by elihu 9y ago
We all have an attention budget. If a static type system frees us from thinking about certain types of errors, then we can direct that attention to other areas of the task at hand. That's usually a good thing.
Having to be careful because there's no type system checking your work is a useful skill to learn in some contexts, but I think the current state of the software industry is a pretty good argument that human programmers will never be careful enough. So, we should do what we can to accommodate human fallibility and use machines to check our work early and often.
- mcphage 9y ago> We all have an attention budget. If a static type system frees us from thinking about certain types of errors, then we can direct that attention to other areas of the task at hand. A static type system also requires continuous attention. The question is, does it free attention faster than it consumes it?
- mercurial 9y agoThe thing is, it's pretty good at telling you when you haven't been paying enough attention.
- Terr_ 9y ago> A static type system also requires continuous attention. I'm not sure what you mean by this, or how it constitutes an increase over the demands of a runtime or weak type system.
- mcphage 9y agoIt means that every time you define a function, or declare a variable, or build a class, you need to explain to the compiler what exactly it is. And if your needs for that variable or class or function change, you need to explain to the compiler the differences. Some languages make it easy to explain to the compiler what's going on, some make it very difficult. > how it constitutes an increase over the demands of a runtime or weak type system It's the difference between "I understand X", and "I have to figure out how to describe X in my language". And the difference between "my understanding changed", and "I have to figure out all of the places in my program where I need to update the code because of my new understanding".
- Terr_ 9y ago> you need to explain to the compiler what exactly it is I would not call that "continuous attention", because most of the time you're simply writing down a decision you've already made, and would have had to make even in a dynamic language. In contrast, I think "continuous attention" is having to remember the current kinds of data being held in different variables in a long data-flow. > And if your needs for that variable or class or function change, you need to explain to the compiler the differences. Yes, but that's because the compiler is remembering your "checklist" for you. In a dynamic language you'd need to make all the same decisions, but you'd have to waste more brainpower (or introduce more bugs) by trying to manage it all yourself.
- mcphage 9y ago> but you'd have to waste more brainpower (or introduce more bugs) by trying to manage it all yourself. I'll be honest, I've never wasted much brainpower trying to remember the difference between covariant and contravariant, or whether I want Try[Future[String]] or Future[Try[String]], or anything like that, when working in a dynamic language. You just don't do shit like that.
- Terr_ 9y agoYeah, but that's because all the wasted-brainpower goes into preventing even dumber errors, like a method that can't quite decide whether a variable is a string or an object or an array. Part of my job is maintaining a PHP/JS codebase that's 10+ years old, and I wish I had days where it was all about covariance, rather than the stupid stuff.