Programming language choice, why C\C++ ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Programming language choice, why C\C++ ?

Post by Ras »

abulmo2 wrote:3) In C or C++, a chess engine has some parts tied to the OS (time-management, non blocking input and multithreading), so writing a portable code in C or C++ usually needs wrapper around some OS-dedicated library functions.
I was able to port a C engine where the author only supplied a Windows EXE to a totally different platform that doesn't even have an OS. Good luck trying that with another language.
jdart
Posts: 4367
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Programming language choice, why C\C++ ?

Post by jdart »

Ages ago I had to port an application to MS-DOS. There were some existing implementations on other platforms. The closest one to MS-DOS targeted an embedded system (no OS). MS-DOS was so primitive it might as well not have had any OS functions. So I cross-compiled the app on VMS and targeted a runtime library that was a hacked version of the embedded system's and sat on MS-DOS. The most painful part of this was actually having to use VMS :-).

--Jon
User avatar
edlich
Posts: 8
Joined: Wed Jul 13, 2011 12:00 pm
Location: Berlin

Re: Programming language choice, why C\C++ ?

Post by edlich »

I had the same question about 8 or 9 years ago especially with D! (It looked so great to me).

And some clever guys told me that C/C++ is also better in bit fiddeling if you want to use bitboards!
This might be a strong argument against D, Go, Rust, etc.
But if you don't need bit operations, other languages like D might also be fine.
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Programming language choice, why C\C++ ?

Post by abulmo2 »

edlich wrote:And some clever guys told me that C/C++ is also better in bit fiddeling if you want to use bitboards!
This might be a strong argument against D, Go, Rust, etc.
This is wrong:
D: https://dlang.org/phobos/core_bitop.html
Rust: https://doc.rust-lang.org/std/primitive.u64.html
Go: this is under discussion: https://github.com/golang/go/issues/18616
All those languages also support inline assembly in case the default implementation is too slow.

There is nothing standard in C or C++. You have to use compiler extensions (builtin, intrinsics, etc.), or inline assembly if supported.
Richard Delorme
User avatar
edlich
Posts: 8
Joined: Wed Jul 13, 2011 12:00 pm
Location: Berlin

Re: Programming language choice, why C\C++ ?

Post by edlich »

Oh thanks.
Then my info must be too old.