Advertisement

Next Logical Step...

Started by January 07, 2015 02:04 AM
12 comments, last by Jay Pascua 10 years ago

Even more important, how do you know that trick will actually be faster than using an intermediate variable? It's bad to assume you actually know what's better than the compiler because in a lot of cases you don't, in fact, know better.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!



Glass_Knife, on 07 Jan 2015 - 8:16 PM, said:
http://handmadehero.org/

Haven't seen this one yet, but it looks awesome. Definitely gonna start from video one, and check it out. Thank you Glass_Knife.

I think even if you don't follow along and code the game, the beginning C++ videos will be very helpful!

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

Advertisement
Yep, it's a neat trick smile.png On of many that C++ has to offer. And although it is good to know them, please be careful to use it in your code. Unless you are trying to squeeze the last bit of performance and/or available resources - the readable code is much more important. You WILL return to your code after some time and the easier it will be to understand the faster you will fix that bug or add this new feature.

Further, the xor swap trick can actually be slower than doing the more obvious thing (although the contexts are unlikely to be useful to a beginner). It also cannot swap two values that are the same ("a xor a" is zero).
As you said, simple, clear code is almost always better, and almost always fast enough to not be the critical path. Especially for a beginner.

Even more important, how do you know that trick will actually be faster than using an intermediate variable? It's bad to assume you actually know what's better than the compiler because in a lot of cases you don't, in fact, know better.

That's true, I don't. Definitely will keep that in mind.

Yep, it's a neat trick smile.png On of many that C++ has to offer. And although it is good to know them, please be careful to use it in your code. Unless you are trying to squeeze the last bit of performance and/or available resources - the readable code is much more important. You WILL return to your code after some time and the easier it will be to understand the faster you will fix that bug or add this new feature.

Further, the xor swap trick can actually be slower than doing the more obvious thing (although the contexts are unlikely to be useful to a beginner). It also cannot swap two values that are the same ("a xor a" is zero).
As you said, simple, clear code is almost always better, and almost always fast enough to not be the critical path. Especially for a beginner.

Same, thanks. Just going to forgo anything like that and continue focusing on the fundamentals. Practice practice practice.



Glass_Knife, on 07 Jan 2015 - 8:16 PM, said:
http://handmadehero.org/

Haven't seen this one yet, but it looks awesome. Definitely gonna start from video one, and check it out. Thank you Glass_Knife.

I think even if you don't follow along and code the game, the beginning C++ videos will be very helpful!

Indeed, so far cleared up a lot regarding Windows Programming for me, also had a lot of random computer history tidbits that I enjoyed. Been chugging along on these hour long videos >_< lol

This topic is closed to new replies.

Advertisement