tag:blogger.com,1999:blog-3579312376304629754.post3873052347439058900..comments2023-02-24T05:54:19.593-08:00Comments on Randy Gaul's Game Programming Blog: Tokenizing Example: SquareCecilSunkurehttp://www.blogger.com/profile/16129986119923492789noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-3579312376304629754.post-33023964371920119922009-12-14T22:26:59.871-08:002009-12-14T22:26:59.871-08:00There's two possibilities:
1. Your dad works o...There's two possibilities:<br />1. Your dad works on low level stuff, that isn't compiler optimized. This is what I'd guess, considering that IBM does some of that stuff, and he's worrying about speed.<br />2. Your dad writes bad code.<br /><br />I mean he's right, that function calls do have some overhead, but the point is that any sane compiler will inline function calls to remove that overhead if doing so will make the program faster.<br /><br />Anyways when coding in a high level language, (which C++ definitely is, C is borderline), the rule is first you profile, then you optimize. People like to think that they can tell perfectly what code runs fast and what code doesn't. Even if this is true for extremely experienced developers, it's certainly not true for any of us. That's why we have profilers.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3579312376304629754.post-19324285806206767372009-12-09T12:54:58.419-08:002009-12-09T12:54:58.419-08:00@scwizard: Weird, my dad said that they were slow,...@scwizard: Weird, my dad said that they were slow, and he works for IBM. And I also heard the same thing from a profesional programming teacher at summer camp. I'll talk to dad and ask what he meant. (Not saying I don't believe you, of course.)Patrick (Biophysicist)https://www.blogger.com/profile/06914456036973134379noreply@blogger.comtag:blogger.com,1999:blog-3579312376304629754.post-805578539455290672009-12-06T22:46:34.740-08:002009-12-06T22:46:34.740-08:00"NEVER have unneccessary function calls. Call..."NEVER have unneccessary function calls. Calling a function is actually pretty slow. You should have put the code to input data and draw the square in your main function."<br />You have no idea what you're talking about.<br /><br />Don't listen to this advice, it's terrible advice.<br /><br />We have these things called compilers, they're not stupid. They do this thing called inlining. Learn what it means before you teach poor Cecil stuff he'll have to unlearn later.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3579312376304629754.post-33912788706095850612009-12-06T22:44:34.001-08:002009-12-06T22:44:34.001-08:00Just to make you feel bad:
http://codepad.org/KiHQ...Just to make you feel bad:<br />http://codepad.org/KiHQEuicAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3579312376304629754.post-83628855688491384782009-12-02T21:08:00.671-08:002009-12-02T21:08:00.671-08:00About number 1, thanks. I just assumed that multip...About number 1, thanks. I just assumed that multiple function calls would be better coding practice for while I'm learning.<br /><br />And for two, it just makes writing out the code a bit simpler -that's all.CecilSunkurehttps://www.blogger.com/profile/16129986119923492789noreply@blogger.comtag:blogger.com,1999:blog-3579312376304629754.post-68465706472909173282009-12-02T12:24:45.626-08:002009-12-02T12:24:45.626-08:00A few things.
1) NEVER have unneccessary function...A few things.<br /><br />1) NEVER have unneccessary function calls. Calling a function is actually pretty slow. You should have put the code to input data and draw the square in your main function.<br /><br />2) Wtf is with the "define n '/n'? I see what you're doing, but not why you're doing it.<br /><br />Sorry to be so critical. >.> You're doing really well for the amount of experience you have.Patrick (Biophysicist)https://www.blogger.com/profile/06914456036973134379noreply@blogger.com