Why C++ instead of C#?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Why C++ instead of C#?

Post by Ras »

lithander wrote: Fri Sep 17, 2021 1:48 pmOn the other hand if someone is sharing the code of a didactic engine I assume he expects others to interact with it in some form?
Not necessarily. Crafty's or TSCP's source code for example have a "look at it, but don't touch it" kind of licence.
Rasmus Althoff
https://www.ct800.net
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Why C++ instead of C#?

Post by mvanthoor »

lithander wrote: Fri Sep 17, 2021 1:48 pm Thanks for the feedback on how to properly compile the C source. I'll give it a try after work.
Just remove mingw64, and install MSYS2 with GCC and Clang.

You can then compile 64-bit versions in MSYS2 MinGW64, and 32-bit in MSYS2 MinGW32. You can treat the program as if it's a Linux program, but a Windows executable will be created. There's a catch if you need "make" though; you need to install "make", but it actually installs "make-mingw32" or something like that. You need to create a "make" symlink to that executable. I don't know if this is by design or a mistake, but it has always been like this in MSYS2.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
klx
Posts: 179
Joined: Tue Jun 15, 2021 8:11 pm
Full name: Emanuel Torres

Re: Why C++ instead of C#?

Post by klx »

lithander wrote: Fri Sep 17, 2021 1:48 pm As so many of you seem interested in the topic I'm thinking about sharing the C# version with you so everyone who wants can replicate the measurements. We could then also try to make the version faster together, leverage the full potential of C# so to speek. Learn more about what micro-optimizations are possible in C# is one of the reasons I undertook this little experiment.

The only thing that's stopping me at the moment (apart from being at work^^) is that I don't know under what terms the author of the QBBEngine meant to share his code. Didn't find an open source license mentioned anywhere specifcally. On the other hand if someone is sharing the code of a didactic engine I assume he expects others to interact with it in some form?
I think you absolutely should share it. You might want to just shoot an email to Fabio and ask for permission, or better yet a proper license.
[Moderation warning] This signature violated the rule against commercial exhortations.
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Why C++ instead of C#?

Post by lithander »

mvanthoor wrote: Fri Sep 17, 2021 2:54 pm Just remove mingw64, and install MSYS2 with GCC and Clang.
When I said compiled using MinGW 64bit I meant the version that came with MSYS2. But I didn't know that just calling gcc wthout any other parameters doesn't optimize the build.

I also didn't manage to compile it out of the box with Visual Studio (not even after installing Clang) because

Code: Select all

clock_gettime(CLOCK_MONOTONIC,&end);
seems to not be available on Windows. *shrug* I'm really not a C expert, never really used it before.
klx wrote: Fri Sep 17, 2021 3:03 pm I think you absolutely should share it. You might want to just shoot an email to Fabio and ask for permission, or better yet a proper license.
I already wrote him a PM yesterday but it's still sitting in the outbox. I guess he doesn't visit the forum every hour like the rest of us ;)
Last edited by lithander on Fri Sep 17, 2021 3:55 pm, edited 2 times in total.
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
klx
Posts: 179
Joined: Tue Jun 15, 2021 8:11 pm
Full name: Emanuel Torres

Re: Why C++ instead of C#?

Post by klx »

lithander wrote: Fri Sep 17, 2021 3:53 pm I already wrote him a PM yesterday but it's still sitting in the outbox. I guess he doesn't visit the forum every hour like the rest of us ;)
Lame. Could try 0xfab10@gmail.com perhaps.
[Moderation warning] This signature violated the rule against commercial exhortations.
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Why C++ instead of C#?

Post by lithander »

Fabio just replied "It has no license you can do what you want with the code. It's a very simple engine." so I guess I can share the C# port later! Yay! :)
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Why C++ instead of C#?

Post by mvanthoor »

lithander wrote: Fri Sep 17, 2021 3:53 pm When I said compiled using MinGW 64bit I meant the version that came with MSYS2. But I didn't know that just calling gcc wthout any other parameters doesn't optimize the build.
I have actually forgotten how to create debug and release builds with GCC since using Rust... I'd have to look it up again. Even so, when compiling a release build, it is _still_ not optimized for a specific CPU. In Rust, you use the --release option, for a release build, but to optimize to a certain minimum cpu level, you have to set the environmental variable RUSTFLAGS = -C target-cpu=cpu_name_here. Similar for C (CFLAGS) and C++ (CXXFLAGS).
I also didn't manage to compile it out of the box with Visual Studio (not even after installing Clang) because

Code: Select all

clock_gettime(CLOCK_MONOTONIC,&end);
seems to not be available on Windows. *shrug* I'm really not a C expert, never really used it before.
That is why I always compile engines on MSYS2. Most open source engines compile on Linux, and therefore they normally compile under MSYS2 too. I never had an engine NOT compile. (Except when actually broken because of errors in it or missing third-party dependencies.)
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Why C++ instead of C#?

Post by mvanthoor »

lithander wrote: Fri Sep 17, 2021 3:55 pm Fabio just replied "It has no license you can do what you want with the code. It's a very simple engine." so I guess I can share the C# port later! Yay! :)
If you manage to create something in C# that actually reaches 75% or more of C / C++'s speed, I think I'm just going to blatantly ignore it, put fingers in my ears, sing "LA-LA-LA-LA", and assume either you did something wrong on the C / C++ side or the C / C++ code is crappy.

Otherwise, I'm a fairly open-minded person though...
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Why C++ instead of C#?

Post by abulmo2 »

Personally I wonder why C++ instead of D.
Richard Delorme
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Why C++ instead of C#?

Post by Ras »

lithander wrote: Fri Sep 17, 2021 3:53 pmI also didn't manage to compile it out of the box with Visual Studio (not even after installing Clang) because

Code: Select all

clock_gettime(CLOCK_MONOTONIC,&end);
seems to not be available on Windows.
Yes, that's a POSIX function. With MingW, you could add the compiler / linker options -mthreads -pthread -lpthread.
Rasmus Althoff
https://www.ct800.net