The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
I would not call it abuse and it doesn't even remotely resemble void* declarations. With auto the compiler figure out the appropriate type to use and gives you an error if it can't. A void* declaration has no type so it is a completely different thing.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
With auto the compiler knows exactly the appropriate type to use and gives you an error if it can't figure it out.
If it "knows exactly", how can it not "figure it out"? Sounds like a chick/egg scenario to me.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
At first glance var does seem lazy, I use it regularly while working on a large codebase with a lot of 'technical debt'.
I use it quite a lot in my professional code development having been encouraged to do so.
There again I work in an environment where comments are frowned upon, the thinking being that well written code should not have to be documented - a philosophy which I don't agree with.
I think the use of var fits in with this 'no comments' philosophy as it is not explicitly stated what the type of the variable is and you have to figure it out with intellisense or by inspecting the method's return type.
“That which can be asserted without evidence, can be dismissed without evidence.”
auto is a huge benefit for iterators and such. Do you really want to be typing out std::vector<Something*>::iterator... when auto can save you time and typing? You would twist your fingers and brain up remembering the correct syntax for more complex structures, such as maps.
Don't use it for your data definitions, but use the hell out of it everywhere else! You will save a huge amount of time. And it will be easy to tell the intent by the way it is used: auto it = someVector.begin();
It is getting stupid, but then again much of modern C++ is some sort of attempt to try to make it into exactly what it really isn't. It's like we've been infected with people whose idea of software is a javsascript web site.
When you are righting serious code that you will have to support and upgrade over decades, being as explicit as you can is always a good thing. You'll write it once, but you'll have to read and modify it many, many times. Auto makes it way too to make silent mistakes during modifications, because it just takes on whatever you assign it. If the type you wrongly assign is syntactically similar enough, and that's not hard to happen given how much people do with operators and other templates and such, it will just silently change the code.
If you explicitly indicate the type, you have to screw up two different ways as once, which just makes it that much less likely to happen silently.
I'm tellin ya, every time I read stuff on r/cpp, I start to suspect more and more that Russia is putting stupid pills in our water. I mean there are people now arguing for stuff that was so utterly bad in the 1980s that pretty much an entire industry switched to OOP to get rid of it. And they are arguing for this stuff like it's some sort of modern, magic hipster technology to fix all of the evils of OOP.