3 ms·
Defining types is easy and enhances code readability until you go too far. Some type declarations in Haskell or highly templated C++ are hard to read.
by sacado2 9y ago
Defining types is easy and enhances code readability until you go too far. Some type declarations in Haskell or highly templated C++ are hard to read.
- kronos29296 9y agoHighly templated C++ is the highway to hell. If you haven't heard C++ templates are turing complete and so can also have the halting problem.
- Silhouette 9y agoWhile this is a valid point, it's also worth remembering that if you have a data structure of sufficient complexity that writing out its type is cumbersome, then your data is still in that structure whether you choose to be explicit about it or not. Any code reading or modifying some element within that data still needs to correctly find that element, and if writing out the types is a burden then probably finding the correct location every time is also difficult. So if anything, when you have more complicated data structures flying around, and particularly if you work with several similar but different complicated structures, that could make having the types explicit much more useful for ensuring correctness and maintainability.
- tome 9y agoAbsolutely. Sometimes the type is too complex not to be explicit about it.