by KallDrexx · 6y ago · 0 comments
var person = new Person();
var car = selectCarById(carId); // Car
if type is not obvious, it should be explicitly declared.`doSomethingToACar(selectCarById(carId));`
Kind of weakens the argument. I'm not sure what's the best approach, but I'm usually ok with autos even when the type is not explicitly known - when reading code, I do not really need to know what exact type a variable has ("it's a car, goddamnit, it says so in the name!"), just how it's used (and then meaningful function names become very important).
for(auto iter = vec.begin(); iter!=vec.end(); iter++)
for(std::vector<project_namespace::class_name>::iterator iter = vec.begin(); iter!=vec.end(); iter++) for (auto i : vec)Especially when that "auto i : vec" should have instead been "auto& i : vec" or "const auto& i : vec" and now you are at best wasting cycles and at worst writing to copies that will soon be discarded, ending up with a bug that can be very hard to spot.
The debate is about all the other cases.
I know i do not use any of the languages you mention, for example - and if i did, i'd explicitly write any type names.
How do you reconcile that world view with the fact that people are shipping billions of line of codes that obviously work in languages where until recently you couldn't even write any type anywhere (JS, Python) ?
But honestly i can only talk about me here, i can't guess why some imaginary other developer who dislikes a feature does dislike it.
For others, it was worrisome because it made code easier to compile, and rightly so. If it complies it doesn't mean it's correct.