Speed up your engine Part 3

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Angrim
Posts: 97
Joined: Mon Jun 25, 2012 10:16 pm
Location: Forks, WA
Full name: Ben Nye

Re: Speed up your engine Part 3

Post by Angrim »

It mostly depends on if you have a state of the art pascal compiler. The C compilers are really good now, so it seems possible that you would gain some speed. For a quick and easy start on the conversion, I would try P2C which is a simple translator.
https://schneider.ncifcrf.gov/p2c/

Most speed gains would probably depend on using C language specific stuff, and Pascal isn't intrinsically slow, but you might get lucky.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Speed up your engine Part 3

Post by lucasart »

lauriet wrote:Hi,
My program is written using FreePascal for LINUX.
I am about the furthest thing away from a C programmer and do not want to start a religious wars thread so....

Would a simple minded conversion to C provide any benefit, or do you need to change "style" to take advantage of
any C benefits ?

I could do a conversion but it would essentially be a Pascal program with C syntax.

Thanks

Laurie.
Boot is written in Pascal, and probably hundreds of elo stronger than your program, so Pascal is not the problem. Your code is the problem :)

First, write code that is correct and verifiable (unit tests, assert, test suites).

Second, write code that is clear, and concise, hence maintainable.

Third, write code that runs faster, by using a profiler and measuring (never optimize by guessing).

That's far more important. If Pascal is what you know best, use that. Good Pascal code is better than bad C code.

The main reason why C is faster than Pascal is because C compilers are incredibly good at optimizing code. But that could change. Maybe FreePascal will one day get close to GCC's C compiler performance, who knows ?
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Henk
Posts: 7216
Joined: Mon May 27, 2013 10:31 am

Re: Speed up your engine Part 3

Post by Henk »

In the long run you have to rewrite your code ten times or more. So initial implementation is not that important unless you want to stick to it. Also it may be that after some time you don't understand your code anymore for it got too complicated. So rewriting it several times is unavoidable. It might even be that after rewriting it ten times you come to the conclusion that first implementation was best.
Aleks Peshkov
Posts: 892
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia

Re: Speed up your engine Part 3

Post by Aleks Peshkov »

Henk wrote:In the long run you have to rewrite your code ten times or more. So initial implementation is not that important unless you want to stick to it. Also it may be that after some time you don't understand your code anymore for it got too complicated. So rewriting it several times is unavoidable. It might even be that after rewriting it ten times you come to the conclusion that first implementation was best.
I agree. Poor choice is to fix into the current code base.

If you want to study low-level programming -- study C language.