Hacker News new | ask | show | jobs
by roel_v 4483 days ago
Yes, certainly as you say, which is what concerns me - the notion that types are something that is best buried, by an influx of new users.

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.

1 comments

the notion that types are something that is best buried

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)

No I realize you're not saying that, I'm afraid that some people will come to C++ thinking that, that was what I was trying to say.

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.