Clear coding ?

Discussion of chess software programming and technical issues.

Moderator: Ras

Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Clear coding ?

Post by Henk »

flok wrote:Henk,

You're not serious, right?

Does it matter. If it reduces complexity it might be interesting. But looks like it does not. So read it in reverse mode or be a good interpreter.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: Clear coding ?

Post by mvk »

You can make your program run faster with

Code: Select all

#define while if
Handy for tournaments.
[Account deleted]
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Clear coding ?

Post by bob »

mvk wrote:
Henk wrote:Maybe OO programming is safe if you make all objects immutable. Don't know if that works in practice.
Encapsulating state is generally considered a key defining property of OO. It would be Value Oriented programming if there were no mutable state. Some also call that functional programming of course. There is empirical evidence that that can work in the sense that products are made with it and people make their living that way.
I suppose one could tackle this in something like SISAL or whatever. Certainly not MY cup of tea for chess, however.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Clear coding ?

Post by Henk »

Functions compose well. Free or global variables usually cause problems.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Clear coding ?

Post by bob »

Henk wrote:Functions compose well. Free or global variables usually cause problems.
Unfortunately you will always have global variables if you use threads, if you want the search to be anything even close to reasonably efficient...
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Clear coding ?

Post by Henk »

bob wrote:
Henk wrote:Functions compose well. Free or global variables usually cause problems.
Unfortunately you will always have global variables if you use threads, if you want the search to be anything even close to reasonably efficient...
I don't know if a twenty times slower transposition table will become the main computational bottleneck during normal move search otherwise using balanced trees might become an option.
flok

Re: Clear coding ?

Post by flok »

bob wrote:
Henk wrote:Functions compose well. Free or global variables usually cause problems.
Unfortunately you will always have global variables if you use threads, if you want the search to be anything even close to reasonably efficient...
I disagree.
When you initiated the pool of threads that you use, you can setup a structure with pointers and values etc of parameters that would be global instead. That structure can then be passed to the threads at creation time.

Global variables are bad mkay.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Clear coding ?

Post by bob »

flok wrote:
bob wrote:
Henk wrote:Functions compose well. Free or global variables usually cause problems.
Unfortunately you will always have global variables if you use threads, if you want the search to be anything even close to reasonably efficient...
I disagree.
When you initiated the pool of threads that you use, you can setup a structure with pointers and values etc of parameters that would be global instead. That structure can then be passed to the threads at creation time.

Global variables are bad mkay.
How is that different from global variables? The problem with globals is that any procedure can modify them even when they are not formal parameters. How is that different that passing around a pointer that points to a large structure? You have the SAME problem. You can't tell which procedure modifies what unless you look.

This sounds like the "goto's are horrible" group, yet they use continue, break, switch, etc... I suppose that "#define letsgohere goto" would be just as effective and yet not have a goto in the code, just a lot of "letsgohere <label>" lines.

You are going to have to convince me how a pointer to a bunch of things is different from a global in the context of software engineering and programming.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Clear coding ?

Post by bob »

Henk wrote:
bob wrote:
Henk wrote:Functions compose well. Free or global variables usually cause problems.
Unfortunately you will always have global variables if you use threads, if you want the search to be anything even close to reasonably efficient...
I don't know if a twenty times slower transposition table will become the main computational bottleneck during normal move search otherwise using balanced trees might become an option.
It HAS to be fast. It HAS to be hashed, not searched.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: Clear coding ?

Post by mvk »

bob wrote:You are going to have to convince me how a pointer to a bunch of things is different from a global in the context of software engineering and programming.
A lot of sw engineering is about reuse (either in time or in space). Imagine trying to provide a libcrafty. You'll have to put each instance in its own address space to create new instances of its globals. Some people call that fork.

Now look at zlib and see how that is different and faster. It doesn't limit itself to one instance per address space.
[Account deleted]