I'm not looking forward to the first time I will have to work myself into a code base build around heavy 'auto' use.
I'm not looking forward to the first time I will have to work myself into a code base build around heavy 'auto' use.
And certainly - the case of auto x = T(); is not too bad. It's when the type is determined by template overload, or Koenig lookup, or template traits, that it becomes murky. It will take years for tool to catch up - now when I put my cursor on a variable, it will show me the type in the status bar. For the first few years this will always show 'auto' I'm afraid. In other languages, a collection is a collection (mostly) - in C++ it depends on whether you use a vector, set, hash or list what methods are available. That's quite a difference, from a programming comfort point of view.
that was not really my claim though - types should not be buried in C++. Either the context should be clear enough to know what type it is. Or, like for lots of template code, the type simply should not matter. Obviously in those cases auto shines. In other words: if the code is written properly it shouldn't matter if auto is used or not. (and in my experience if all your functions are nice and short, as they should be 99% of the time)
You do have a good point about the tooling though (which tooling is it you use btw? Haven't used anything but VS lately, and it's ok for the way I use it, but I can imagine having to go from clearly seeing all types to not being able to is an awful experience)
Visual Studio with Visual Assist is what I'm using - I love it but in the future the only way to deduce some types is by compiling code, I'm afraid.
If C++ is too complex for it to work, I'm just going to consider that a strike against C++ and move on. Chalk it up as another piece of evidence that C++ is wildly more complicated than Haskell.
I guess the more I think about it, that that's what scares me the most about 'auto' - instead of having the original author do the type deduction once (which is something he intended in the first place, hopefully), you now (as a maintainer) have to go chase it down, just to save the original author from typing out a hairy type.
Now I do realize the real use case for 'auto' - it's the cases where you don't actually know the type yet, because you're providing an extensible framework through template specialization. I have written quite a bit of such code myself. And yet, despite having suffered through all the 5-line typedefs that that sometimes required, I'd be willing to keep doing that to save myself from code by people who mistake 'auto' for a convenient way to save a few keystrokes (this is not meant as a jab at the parent, I'm just talking in general, in case anyone would interpret me wrong).
Eh... That can only be done by compiling the code in the background, while you're typing. Which is possible, of course, but it sets a very high barrier for tools. It will mean that only the top-3 of IDE's will provide this functionality, and even then, it will take them years to get it working well.