4 ms·
Explicit typing is great until your code is littered with shared_ptr<vector<shared_ptr<map<string,T>>>> everywhere.
by advisedwang 3y ago
Explicit typing is great until your code is littered with shared_ptr<vector<shared_ptr<map<string,T>>>> everywhere.
- idle_zealot 3y agoIf you're using a type like that repeatedly then it probably deserves an alias.
- TillE 3y agoEvery time you want to iterate over a map, for example, you're using std::pair<T,U> or std::unordered_map<T,U>::iterator. This gets very annoying without auto, and making an alias doesn't really address any of the complaints the article has.
- Supermancho 3y agoThe issues around type inference could be an annotation (extra overhead) on a function or line to enable some form of it, for simplicity of mapping or conversion, but leave it out by default. Now you get the best of both worlds.
- wredue 3y agoAliases have their own problems. You may have to propagate the alias, or define different aliases with the same type all over the place. Then you have issues with changing code. Complex composed types just have this issue to be honest, and personally I like having inference as a tool to avoid the litter.
- PaulHoule 3y agoYeah, I think he hasn’t programmed Java.
- swells34 3y agoWhen trying to figure out something's type is the same as trying to fully comprehend a regex pattern, you know things have gone too far.
- blueboo 3y agoBut the bad news, then, is all that complexity is hidden, metastasising
- freedomben 3y agoExactly. Just because you don't have to read it, doesn't mean it isn't there. It's still there, just hidden from you, and worse now you have less incentive to actually simplify it...
- deleted 3y ago[deleted]
- rqtwteye 3y agoYeah. “Auto” was probably one of the best additions to C++ ever.