Advantages of C++11 for Chess?
Moderators: hgm, Rebel, chrisw
-
- Posts: 7220
- Joined: Mon May 27, 2013 10:31 am
Re: Advantages of C++11 for Chess?
Multi-threading is even worse than Bit boards. Giving all kinds of annoyance when debugging. Especially when you don't have time.
-
- Posts: 1221
- Joined: Wed Mar 08, 2006 8:28 pm
- Location: Florida, USA
Re: Advantages of C++11 for Chess?
Thanks for all the input. This thread has been more useful than I had hoped.
The string manipulation routines in C++11 look awesome. They are a massive improvement from plain old C.
Thanks - Steve
The string manipulation routines in C++11 look awesome. They are a massive improvement from plain old C.
Thanks - Steve
http://www.chessprogramming.net - Maverick Chess Engine
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Advantages of C++11 for Chess?
Thank you for adding value to the discussion, once again.Henk wrote:Multi-threading is even worse than Bit boards. Giving all kinds of annoyance when debugging. Especially when you don't have time.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
-
- Posts: 1437
- Joined: Wed Apr 21, 2010 4:58 am
- Location: Australia
- Full name: Nguyen Hong Pham
Re: Advantages of C++11 for Chess?
You have not asked (I guess you may know already) about the main disadvantage of using C++ over plain CSteve Maughan wrote: The string manipulation routines in C++11 look awesome. They are a massive improvement from plain old C.
It is a tradeoff about 5-10% of chess speed, according to some old posts and I guess that is still true (it will be great if you can check again via your work).
However it is not really important nowadays since you may gain more from having better codes, using hardware / threads more efficiently.
-
- Posts: 931
- Joined: Tue Mar 09, 2010 3:46 pm
- Location: New York
- Full name: Álvaro Begué (RuyDos)
Re: Advantages of C++11 for Chess?
I would need to see a recent test before I believe this. My current estimate of the C++ slowdown is 0%. I am willing to be convinced otherwise, but only by data.phhnguyen wrote:You have not asked (I guess you may know already) about the main disadvantage of using C++ over plain CSteve Maughan wrote: The string manipulation routines in C++11 look awesome. They are a massive improvement from plain old C.
It is a tradeoff about 5-10% of chess speed, according to some old posts and I guess that is still true (it will be great if you can check again via your work).
-
- Posts: 366
- Joined: Thu Jun 05, 2014 2:14 pm
- Location: Iran
- Full name: Mehdi Amini
Re: Advantages of C++11 for Chess?
Anyone tried atomic introduced in C11 ?Evert wrote:Have you considered C11?
Personally, I use a library called TinyCThread that implements the C11 threads interface on top of whatever native threads you have (Posix or Windows). Seems to work well.
If you want to move to C++, go for it, but if threads are the only reason for doing so, that's probably overkill.
http://en.cppreference.com/w/c/atomic
Farewell.
-
- Posts: 2929
- Joined: Sat Jan 22, 2011 12:42 am
- Location: NL
Re: Advantages of C++11 for Chess?
I'm using them. Didn't compare to possible alternatives though.Look wrote:Anyone tried atomic introduced in C11 ?Evert wrote:Have you considered C11?
Personally, I use a library called TinyCThread that implements the C11 threads interface on top of whatever native threads you have (Posix or Windows). Seems to work well.
If you want to move to C++, go for it, but if threads are the only reason for doing so, that's probably overkill.
http://en.cppreference.com/w/c/atomic
It's a case where operator overloading would have been nice though.
-
- Posts: 1437
- Joined: Wed Apr 21, 2010 4:58 am
- Location: Australia
- Full name: Nguyen Hong Pham
Re: Advantages of C++11 for Chess?
No way for similar code because C++ accesses data and functions via class pointers and virtual tables, not directly as plain C.AlvaroBegue wrote: My current estimate of the C++ slowdown is 0%.
-
- Posts: 931
- Joined: Tue Mar 09, 2010 3:46 pm
- Location: New York
- Full name: Álvaro Begué (RuyDos)
Re: Advantages of C++11 for Chess?
That only applies to virtual functions, which you shouldn't be calling in the tight loops of search. Free functions and non-virtual member functions are accessed in C++ the same way functions are accessed in C. You can get the functionality of virtual functions in C using function pointers, and those are also slow.phhnguyen wrote:No way for similar code because C++ accesses data and functions via class pointers and virtual tables, not directly as plain C.AlvaroBegue wrote: My current estimate of the C++ slowdown is 0%.
I don't even know in what sense accessing data is different in C and C++.
-
- Posts: 12541
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Advantages of C++11 for Chess?
All of the expensive things (virtual functions, RTTI, try/catch) are used by choice.AlvaroBegue wrote:That only applies to virtual functions, which you shouldn't be calling in the tight loops of search. Free functions and non-virtual member functions are accessed in C++ the same way functions are accessed in C. You can get the functionality of virtual functions in C using function pointers, and those are also slow.phhnguyen wrote:No way for similar code because C++ accesses data and functions via class pointers and virtual tables, not directly as plain C.AlvaroBegue wrote: My current estimate of the C++ slowdown is 0%.
I don't even know in what sense accessing data is different in C and C++.
If you take a compilable subset of C and compile it with a C++ compiler, it will run the same speed as C code.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.