2 ms·
The tradeoff is that I have to explicitly say (and know) what type I'm dealing with at every point in the program. But I'm not sure that's much of a tradeoff.
by AnimalMuppet 4y ago
The tradeoff is that I have to explicitly say (and know) what type I'm dealing with at every point in the program.
But I'm not sure that's much of a tradeoff. If I don't know what type this thing is, how do I know what operations I can safely do on it? How do I know that I can make it do what I'm trying to do? Or will it blow up at runtime when I do that?
I consider "I coded it, it's done, but it might blow up at runtime" to be highly unprofessional. "We covered that with unit tests" is theoretically OK, if you've got 100% test coverage. But you don't, and you never will.
Having to say everywhere what the type is gets tedious. Autocomplete (and "auto", for those languages that have it) help a bit here, but only a bit.
- pca006132 4y agoMost modern languages can do type inference and doesn't require explicit type annotation for variables. Hack, even C++ gots auto! For declarations, I think it does make sense to ask for the annotation because it can also serve as documentation. Have you ever tried scala, rust, haskell or typescript?