3 ms·
> it's also much simpler and faster for the programmer to write one function with one return type, and later modify it to add a return type if the requirements
by steveklabnik 12y ago
> it's also much simpler and faster for the programmer to write one function with one return type, and later modify it to add a return type if the requirements change.
How is this different? When you compile, your compiler will say "Hey, the requirements have changed, your code is wrong here, here, here, and here," and you modify those things, and you're done.
- tormeh 12y ago....and then you've forgot what you were actually trying to solve.
- steveklabnik 12y agoWhy? Aren't you trying to solve the change in interface? And wouldn't you be making the same changes in a dynamically typed language?
- the_af 12y agoWhat is the alternative? You change the code, the behavior gets changed but the compiler doesn't warn you. At this point you have two possible paths: 1- You wrote tests which start failing. You must now spend time changing them. You don't manage to avoid working in order fix your safety net (be it static type checking or your test suite). 2- You didn't write the right tests, and don't notice the change in behavior. The program later fails in production.
- lmm 12y agoI find the type system a great help with remembering what I was actually trying to solve. I can "start at the end" and then work backwards, solving one compile error at a time until there aren't any left, at which point I'll know I've done what I wanted to.