4 ms·
I think typing isn't my issue (so far), but rather the performance. On one hand, it's one less thing to think about while figuring out a problem, but on the oth
by imedadel 7y ago
I think typing isn't my issue (so far), but rather the performance. On one hand, it's one less thing to think about while figuring out a problem, but on the other hand, it might reduce the performance of my solution, and in that case, going back and refactoring the code to use the correct types would be a waste of time...
- mehrdadn 7y agoOh interesting. Why do you think auto would affect run-time performance? Could you describe an example?
- xorz57 7y agoI think auto won't have any run-time performance since type deduction happens at compile-time. Also read this https://stackoverflow.com/questions/19618759/c-11-auto-compile-time-or-runtime https://stackoverflow.com/questions/19618759/c-11-auto-compi...
- mehrdadn 7y agoI'm already well aware of this. I'm asking why the OP thinks otherwise. It's not outright impossible to make it affect performance [1] but I'm trying to see what the concern is. [1] Like by taking the approach that results in a cast, e.g. here: https://news.ycombinator.com/item?id=20493263 https://news.ycombinator.com/item?id=20493263
- imedadel 7y agoOh, I see. I didn't know that type deduction happens at compile-time :o
- saagarjha 7y agoYeah, that's how type systems work in most languages. That's why we have them: they prevent mistakes before you even run your code :)
- clarkcox3 7y agoWhy would you think that using auto would reduce the performance of your code?
- andrepd 7y agoYou seem to have a misconception of what `auto` entails... It just means "deduce type from the right-hand side of the assignment statement", instead of having to type it explicitly. Doesn't make your program dynamically typed or runtime typed all of a sudden.