Sunday, June 10, 2007

Delphi, hallelujah

Still love Borland Delphi. Very easy and intuitive to work with (which is important and leaves more time and energy to the intrinsic difficulties of a chess program, or whatever one is working with), and virtually bug-free. In all this time I still haven't encountered a single bug in the environment. It never hangs or crashes or anything. The chess program itself hangs all the time (because of temporal coding errors, like forgetting to increase the counter variable in a loop) but it never affects the environment within which I'm testing the program.

It is very easy to navigate through the code. The chess program currently exceeds 7000 lines of code, and it would be hopeless to work with without a good navigation system.

Some of the semantic features in Delphi are very useful. I've mentioned in an earlier blog post the possibility of starting an array with any index. I've now seen the usefulness of that. My board-representation was an 8x8 array. With a language that makes you start all arrays at zero, the board representation would range from 0 to 7, which is somewhat anti-intuitive compared to 1-8 (I also use constants a-h to represent 1-8, so to access e4 I simply type board[e,4], which is simple to work with. A language with zero-based arrays would use board[4][3] to access e4.)

But the real power of non-fixed starting index became obvious when I expanded my array to become a 12x12 array (in order to make checking for off-the-board coordinates easier.) With a zero-based array you would have rewrite the code so that board[3][3] becomes board[5][5] and so on for all earlier instructions (unless you've used constants, which I bet you haven't, you slacker). But with Delphi you simply make the new array range from -1 to 10 (assuming the old one ranged from 1-8), which means that the old board still applies in the exact same way. You don't have to rewrite a single line of code to make it work (although you do of course have to rewrite some part of the code in order to benefit from new board).

Okay, now I've spent too much time on a detail when the real strength of Delphi is how intuitive and easy to use it is (while still being powerful, as fast as C++ and so on). But to be honest my experience with other environments is somewhat limited, but I know many Delphi users agree with me. (For the record, I'm using Delphi 7 from 2002, so I don't know about other versions.)


Crashdummie said...

Now where is the post abt different series you lured me here with? *confused*

XY said...

Jag lurade dig. HAHAHAHA! Just kidding, se femte Maj. Men det är bara en lista, som dessutom inte har fått b5 infogad i sig.

Locations of visitors to this page