Author: David Rasmussen
Date: 11:04:20 01/21/03
Go up one level in this thread
On January 21, 2003 at 12:08:08, Uri Blass wrote: >I finished the time of my evaluation of checking bounds. > What is "checking bounds"? Where can I download that? There are many boundscheckers available. Valgrind is free. >I talk about it with other programmers(not of chess programs and not in C). > >They suggested the following ideas: >1)Not many people buy checking bounds and this is the reason that the price is >so high. >2)checking bounds may be effective to check some work of other programmers but >programmers who work about their program do not need it. > > >They suggested that it is better if I write functions to do it and replace all >A[i]= with some f(A,i) that will also check for me if i is inside the bounds >that are defined by A. >I said that I think that if I do it then my code will be at least twice slower. > I was about to suggest the same thing, although in C++, where you have the immense benefit of uniform interfaces of such things. So you can make a boundschecked array that you use in debug builds and a normal array or whatevery you want, in release builds. All you do is change one line when you want bounds checking. That's the way I do it. I just define whether it's a release or a debug build, and the debug build is slow and safe, the release build is fast and also safe (if the debug build was). This kind of thing comes natural in C++, even if you use C++ only as a better C, that is, you (almost) only use the C constructs of C++. If I had to do the same thing in C, it would be much harder and would involce ugly #define macros that do not obey scope or type rules etc. Bottom line: Less headache, fewer bugs, faster development, as fast or faster program. This kind of thing can be done for a lot more things (and more complex ones) than bounds checking. It can in general be used to secure the sanity of all your data. >I can also do a special slower code for debug(something that I do not do today) >but I do not like the idea that every time that I add code then I will need to >add also code for debugging. >This may also make me slower in finding specific place that I want to change. > In C++ you would once and for all define a boundschecked array type that was interchangable with a normal array for release builds (same interface). You do it once, you use it 10000000 times for the rest of your life, and you safe money for boundscheckers. >1)Did checking bounds help you? Yes. >2)Do you usually add code for debugging inspite of having checking bounds? Yes, because there are lot other bugs than bounds bugs. >If 1 and 2 are positive then question 3 > >3)Do you decide to use less debugging code thanks to checking bounds? > No. Correctness is extremely important to me. /David
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.