RoadWarrior wrote:diep wrote:'cryptographically-secure pseudo-random'
that's a huge sentence, tough to parse for me, especially for Bill Gates toylanguage.
uhhhh?
What's the difference with a RNG?
The first difference is that a CSPRNG is designed to pass rigorous statistical randomness tests such as those in the Diehard and Dieharder suites. This gives you confidence that the numbers produced are useful in specific contexts like Zobrist hashing.
The second difference isn't applicable to chess programming, but is very important for cryptography. A CSPRNG is designed to hold up under serious attack, even when its initial or running state becomes available to an attacker.
diep wrote:Optimization in C# seems more complex than in C.
Not surprisingly. Usually microbenchmarks you can keep speed difference under control. Factor 4 or so slower than well written C.
The real problem comes of course when a program grows a tad bigger.
Yet if i see the struggle here, then i'm glad i program in C
A managed language like C# removes whole categories of bugs, such as the heap corruptions and array-index-out-of-bound errors that so often lead to frustrating late-night debugging sessions. So you can get more done with less effort, especially using the rich functionality provided by the .NET base class library.
The trade-off, however, is that you have to work further away from the hardware and with a relatively high-level language. Which means that your mental model of the language spec and the JIT compiler has to be fairly good.
Note that the list of optimisations performed by the JIT compiler is impressive given that it's done in "wall clock" time:
Code: Select all
Constant folding
Constant and copy propagation
Common subexpression elimination
Code motion of loop invariants
Dead store and dead code elimination
Register allocation
Method inlining
Loop unrolling (small loops with small bodies)
The result is comparable to traditional native code - at least in the same ballpark. I think your "factor of 4" is an exaggeration. If I'm faced with performance issues, I don't usually look at the language - I look in the mirror.
Mark, the chessprogrammers aren't beginners. Stuff like out of bounds you have boundscheckers for. The fact that default C# is doing automatic boundschecking slows down the language bigtime, i don't see it as an advantage of the language for low level codes like game tree search where you put in a lot of time per line of code and try to regurarly optimize what you wrote before.
In fact it's no secret my code runs in C on many different platforms, yet if i see how total inefficient most compilers, even in C, deal with the code, the only problem in low level development is the quality of the compilers.
Now where compared to all other languages C/C++ compilers are pretty decent by any standard, they are not for any other language.
Even then the mistakes i see the C/C++ compilers make is huge.
C++ code of c ourse i only mention because it CAN be similar to C. Not because it practically is. Maybe 1 or 2 coders on the planet manage to write C++ same speed, practical the rest is factors slower.
Just the nature of object oriented languages already implicitly forces you to subclass everything and make new classes, using a number of layers of classes already assures you of the huge slowdown of course, which imperative languages like C and Fortran do not have.
The thing that caused JAVA and C# to be there IMHO is the clumsy and total nerd manner how they've 'standardized' C++ at ISO. It took till 1999 or so and they have allowed too much and just have kept adding to it, with too many nerd features, making it worlds most complex language.
Just 0 business sense. Then Java came there by Sun years before they managed to finalize an iso in C++ (which was a total messed up ISO of course if you look from it from a company viewpoint that wants to get things done). Java so called had no pointers and only single inheritence.
The initial compilers for it were a crap.
It rescued Sun for a few years, and by now we know that java has outlived Sun.
m$ then responded with C# onto Java.
C# would never have existed without Java having seen the light.
Java would not have been there i guess if they would've been more decisive about C++.
That's why we have the mess right now as it is.
Vincent
p.s. i don't want this to end up in a yes/no between languages, but we have to face reality that C# and Java are of similar speed, about 3x slower than C if both get written by excellent programmers, for larger pieces of code.
That is - if your C# and Java isn't gonna defragment the memory while your proggie is running
Note that for company codes, which are massive the difference is bigger. Usually a 100+. However we also must note that C is not a nice language from company viewpoint to manage when you have many programmers of varying experience in programming.