You tell me! C and C++ compilers share the same backend.
I wrote before that they didnt do a 1:1 translation but changed al lot of code too for the translation. You can see it Cfish commit history.
Maybe you know another reason?
You tell me! C and C++ compilers share the same backend.
I wrote before that they didnt do a 1:1 translation but changed al lot of code too for the translation. You can see it Cfish commit history.
Maybe you know another reason?
You say it yourself, the red.
Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
90% of coding is debugging, the other 10% is writing bugs.
RdM: 'C is not automatically faster than C++, I have to find speed ups to make it faster. Some of the speed ups have found their way back into Stockfish, such as my SEE implementation.'
Rebel wrote: ↑Sun Dec 05, 2021 3:28 pm
Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
No rebel its the other way around. With C++ you have templates, constexpr, consteval, a strong typesystem, STL, and a lot of keywords that dont exist in C to make simple code faster like [[likely]] and [[unlikely]]. You can directly talk to the compiler with C++. With C you are limited to mere hints like inline.
Thats why its really suprising to me that C is faster in Cfish.
The real answer is they optimized the C code a lot and some of these optimisations went back to upstream C++ Stockfish.
Rebel wrote: ↑Sun Dec 05, 2021 3:28 pm
Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
No rebel its the other way around. With C++ you have templates, constexpr, consteval, a strong typesystem, STL, and a lot of keywords that dont exist in C to make simple code faster like [[likely]] and [[unlikely]]. You can directly talk to the compiler with C++. With C you are limited to mere hints like inline.
Thats why its really suprising to me that C is faster in Cfish.
The real answer is they optimized the C code a lot and some of these optimisations went back to upstream C++ Stockfish.
The author of Cfish simply out-smarted the compiler, that should not be something new for you.
90% of coding is debugging, the other 10% is writing bugs.
Rebel wrote: ↑Sun Dec 05, 2021 3:28 pm
Or in a nutshell, with C++ you leave many things to the compiler, with C you have much more control over the compiler.
No rebel its the other way around. With C++ you have templates, constexpr, consteval, a strong typesystem, STL, and a lot of keywords that dont exist in C to make simple code faster like [[likely]] and [[unlikely]]. You can directly talk to the compiler with C++. With C you are limited to mere hints like inline.
Thats why its really suprising to me that C is faster in Cfish.
The real answer is they optimized the C code a lot and some of these optimisations went back to upstream C++ Stockfish.
The author of Cfish simply out-smarted the compiler, that should not be something new for you.
It is not. Its more that other people trolled me with comments and that got under my skin.