3 ms·
I prefer dynamic typing when writing code that I perceive as "volatile". This is especially true when it's a piece of code that's currently only being worked on
by woojoo666 5y ago
I prefer dynamic typing when writing code that I perceive as "volatile". This is especially true when it's a piece of code that's currently only being worked on by me. Static typing adds boilerplate that feels cumbersome, especially when the types of the variables are already made obvious by the variable names.
However when a piece of code becomes mature, doesn't change often, and starts to be depended on by other people (eg a core library), then I start adding types for additional safety and documentation. This system of gradually adding types when needed is why Typescript is so great for me.
- aranchelk 5y ago> Static typing adds boilerplate That’s not necessarily true anymore. Languages like Haskell have both strong static typing and very good type inference. > However when a piece of code becomes mature, doesn't change often, and starts to be depended on by other people (eg a core library), then I start adding types for additional safety and documentation. That’s a practice in Haskell development as well, but the safety and guarantee of consistency are already present prior to the annotations.
- woojoo666 5y agotype inference is a beautiful thing and I hope Typescript adds it someday
- dllthomas 5y agoI can see that, but find myself with different preferences. When I know I'll be making changes, I want to be working in a setting where I can tell some checker what I'm assuming, so that it lets me know when work elsewhere invalidates that assumption. Assumptions that will be mechanically checked are assumptions I can (metaphorically) page out in my head as I focus on other things, to be alerted when they again become relevant. I definitely agree that all of this becomes even more important when those assumptions need to be shared between the heads of different individuals.