Clear coding ?

Discussion of chess software programming and technical issues.

Moderator: Ras

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Clear coding ?

Post by bob »

mvk wrote:
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.
Except I don't use fork, because I WANT shared data (trans/ref, killers, split blocks, etc, etc, and etc...

BTW Fork doesn't duplicate everything. Only that which is modified. global data that is not modified remains in all address spaces that you create with fork, not to mention the code.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: Clear coding ?

Post by mvk »

This is not really a discussion.

There are two hidden metrics/definitions of "clear coding" in this thread. One is how easily other programmers understand the code by browsing through it (Folkert). The other is as a tool for oneself to produce the desired result, to help organise ones own mind (Henk, you).

I have no idea what Henk uses, because we only see him complain about his own bugs, but never a snippet of his code.

Crafty uses an additional method to assist both uses: many very detailed comments of the code's intent. Crafty can be very difficult to understand without them (for non-bobs), and throwing all variables in a globals section is part of the reason. Not only speed related variables are there. Even the input buffer is. But that is compensated by its outstandingly nice to read comments, I would say. Obviously you don't have problems to achieve the desired result. And obviously Henk has.

[PS: About sw engineering: if you want to reuse Crafty in a different context, for example as a support function linked to an ICS, you really have a problem unless you fork. Now I don't support the dogma "globals are bad" BTW, as less as I support "code reuse is the goal of sw engineering", but many do. I support "does as intended within budget". Trying to make a program "reusable in a different context" often causes unnecessary complications.]
[Account deleted]
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Clear coding ?

Post by Henk »

bob wrote:
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.
If it has to be fast then functional programming fails for there is no fast functional implementation for a transposition table.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Clear coding ?

Post by Henk »

Instead of

Code: Select all

a && (
          b 
          || c
        ) 
I prefer

Code: Select all

a && (false 
         || b 
         || c
         )
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
Any better solutions ? Don't forget code must be as fool proof as possible.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Clear coding ?

Post by mcostalba »

Henk wrote:Instead of

Code: Select all

a && (
          b 
          || c
        ) 
I prefer

Code: Select all

a && (false 
         || b 
         || c
         )
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
Any better solutions ?
Not that I am so much interested, but this account is _clearly_ a troll.

Can I ask what are the moderator policies regarding trolling?
Roger Brown
Posts: 782
Joined: Wed Mar 08, 2006 9:22 pm

Re: Clear coding ?

Post by Roger Brown »

mcostalba wrote:
Henk wrote:Instead of

Code: Select all

a && (
          b 
          || c
        ) 
I prefer

Code: Select all

a && (false 
         || b 
         || c
         )
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
Any better solutions ?
Not that I am so much interested, but this account is _clearly_ a troll.

Can I ask what are the moderator policies regarding trolling?
Hello Marco,

Allow to me to attempt a succinct clarification.

I simply despise the "he is a troll posts" particularly as prior to that question, you express your disinterest (which is your right incidentally) in the answer anyway.

Complain to a moderator.

This way is simply not the way to do it; yet a number of persons insist on doing it this way.

I have removed examples of Henk's posts before and may do so again, but without the assistance of the programmers in particular, I cannot assess what is, and what is not, trolling here.

Later.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Clear coding ?

Post by mcostalba »

Roger Brown wrote:
mcostalba wrote:
Henk wrote:Instead of

Code: Select all

a && (
          b 
          || c
        ) 
I prefer

Code: Select all

a && (false 
         || b 
         || c
         )
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
Any better solutions ?
Not that I am so much interested, but this account is _clearly_ a troll.

Can I ask what are the moderator policies regarding trolling?
Hello Marco,

Allow to me to attempt a succinct clarification.

I simply despise the "he is a troll posts" particularly as prior to that question, you express your disinterest (which is your right incidentally) in the answer anyway.

Complain to a moderator.

This way is simply not the way to do it; yet a number of persons insist on doing it this way.

I have removed examples of Henk's posts before and may do so again, but without the assistance of the programmers in particular, I cannot assess what is, and what is not, trolling here.

Later.

Hi Roger,

I am a programmer and I can state that his posts make no sense.

His scheme is to craft carefully chosen semi-random words picked up in technical jargon dictionary in a non sense line that is written so to provoke the reaction of people reading it.

It is really a conscious trolling scheme IMO.
Roger Brown
Posts: 782
Joined: Wed Mar 08, 2006 9:22 pm

Re: Clear coding ?

Post by Roger Brown »

mcostalba wrote:
Roger Brown wrote:
mcostalba wrote:
Henk wrote:Instead of

Code: Select all

a && (
          b 
          || c
        ) 
I prefer

Code: Select all

a && (false 
         || b 
         || c
         )
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
Any better solutions ?
Not that I am so much interested, but this account is _clearly_ a troll.

Can I ask what are the moderator policies regarding trolling?
Hello Marco,

Allow to me to attempt a succinct clarification.

I simply despise the "he is a troll posts" particularly as prior to that question, you express your disinterest (which is your right incidentally) in the answer anyway.

Complain to a moderator.

This way is simply not the way to do it; yet a number of persons insist on doing it this way.

I have removed examples of Henk's posts before and may do so again, but without the assistance of the programmers in particular, I cannot assess what is, and what is not, trolling here.

Later.

Hi Roger,

I am a programmer and I can state that his posts make no sense.

His scheme is to craft carefully chosen semi-random words picked up in technical jargon dictionary in a non sense line that is written so to provoke the reaction of people reading it.

It is really a conscious trolling scheme IMO.

Hello Marco,

This would have been more properly conducted by pm, but, as the original fault is mine, allow me to conclude here.

I know that you are a programmer.

:-)

I appreciate the insight, because, although I am not in your category (or indeed, of anyone who posts here), I assumed that there was something to the content as Henk has written and run a Winboard compatible engine in HG's monthly tournament.

Also, he engages HG, Sven Schule and Dr. Hyatt regularly in this forum and I cannot imagine a trio of that caliber responding to nonsense posts for long.

I will consult with the other two moderators (who are superb programmers) for their take.

Thanks for your input.

Later.
Ferdy
Posts: 4852
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Clear coding ?

Post by Ferdy »

Roger Brown wrote:
mcostalba wrote:
Henk wrote:Instead of

Code: Select all

a && (
          b 
          || c
        ) 
I prefer

Code: Select all

a && (false 
         || b 
         || c
         )
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
Any better solutions ?
Not that I am so much interested, but this account is _clearly_ a troll.

Can I ask what are the moderator policies regarding trolling?
Hello Marco,

Allow to me to attempt a succinct clarification.

I simply despise the "he is a troll posts" particularly as prior to that question, you express your disinterest (which is your right incidentally) in the answer anyway.

Complain to a moderator.

This way is simply not the way to do it; yet a number of persons insist on doing it this way.

I have removed examples of Henk's posts before and may do so again, but without the assistance of the programmers in particular, I cannot assess what is, and what is not, trolling here.

Later.
1. A fine statement from him.

Code: Select all

a && (
          b 
          || c
        ) 
2. Then he offers his preference, which is fine too.

Code: Select all

a && (false 
         || b 
         || c
         )
3. Then he showed that his preferred code is wrong by excluding b and c thru //
But this gets wrong when:

Code: Select all

a && (false 
      //   || b 
      //   || c
         )
4. And then he asks for better solution.

Code: Select all

Any better solutions ?
The better solution is in (1), but he does not like it and he will show you his prefered (2), then he breaks it in (3) then asks for better solution in (4).
So we go on circles here. I recommend (1), he likes (2) he breaks it in (3) and ask in (4), you recommend (1), he likes (2) ... We go on infinite loop :).
He probably has some problems and needs some help.
Henk
Posts: 7251
Joined: Mon May 27, 2013 10:31 am

Re: Clear coding ?

Post by Henk »

Maybe it's best to simply write

Code: Select all

a && ( b 
          || c 
         ) 
instead of

Code: Select all

a && ( 
          b 
          || c 
         ) 
for it makes it more difficult to make a compile error.