6 ms·
started losing me at exceptions. the philosophy bit is quite nice, but seeing auto in the example... not for me. not even close. its a shame we are ruining C++
by jheriko 11y ago
started losing me at exceptions. the philosophy bit is quite nice, but seeing auto in the example... not for me. not even close.
its a shame we are ruining C++. can't we just have something better... :/
- Pyxl101 11y agoWhat's wrong with auto in the example? (I didn't downvote you, but I think you're being downvoted because you said that C++ is being ruined without explaining why these suggestions are problematic or arguable, which doesn't add to the discussion)
- jheriko 11y agonothing, and in fact the idea behind auto is sound if you take it out of the context of C++. in the context of adding to such a powerful and already overloaded with features language it creates subtle gotchas... i've hit them and seen them being hit, so i don't use it. the usual examples of it shortening iterators are not a problem i have day to day... i also find arguments about typing less and avoiding typing mistakes seem to miss what programming is really about in the wild. i spend 20% of my time at absolute most actually converting my ideas into code and typing them into some document...
- rleigh 11y agoauto can be a great aid to readable and maintainable code. It can also be used to obfuscate when not used in moderation. for(const auto& elem : container) is vastly more readable than for(my_long_type<specialised_type>::const_iterator iter = container.begin(); iter != container.end(); ++iter) I recently had to rewrite some C++11 code to C++98 to fit into a project. Using nothing but auto and range-based for loops, it nearly doubled in size by switching back to the older more verbose syntax. So long as you don't go to the other extreme, these have much value.
- jheriko 11y agoits also a death trap in winrt when combined with templates in the way they do. debugging that typoing a callback signature results in nothing happening in asynchronous code controlled by the ppl task library is a massive pain for even an experienced programmer. auto is nice in principle, but it is introduced in such a powerful and dangerous environment that there are subtle gotchas in real world use cases. including targetting a major platform by using its system libraries. programming is about thinking, not typing and programmer convenience. i don't enjoy auto for that reason either... if it were to save me time it would be little. i find using the stl algorithms and avoiding the nasty stl iterator pattern like the plague means the problem you describe just doesn't exist for me as a day-to-day case.