Code talks. Talk walks. Where is your RUST chess engine ? Show me the code, and we'll see if RUST is really "simpler" than C.mvanthoor wrote: ↑Wed Jul 29, 2020 8:43 pmC isn't a bad language.
It has been in development for almost 50 years. It can be optimized down to the last instruction nowadays. It does show some cracks however. Setting up a working build system that works across compilers across operating systems is much harder in C than it is modern languages. (That is not a language problem per se; it could be done, but no-one seems to be doing it for C.) Writing C that doesn't create undefined behavior is hard. Writing C that is memory safe is harder.
C is not an easy language to use right.
Although I prefer Rust nowadays for several reasons, if it hadn't existed, I would have probably written my engine in C. The only reason for not writing it in C, is because there are so many C engines already.
On the one hand, I love C for all of its power it gives you over the computer, the simplicity of the core language, and the speed.
On the other hand, I hate C because it'll blow your head off if you put an * or & in the wrong spot. Under water, Rust basically has the same memory management, but it handles all of the * (derefs) by itself, except in certain cases.
Let's say you have:
x = &y;
If you now print x in C, you get the memory address of y. If you wanted y, you'd need to print *x.
In C, this is correct, because x DOES contain the memory address of y.
x = &y
means "x is a reference to y", not "it contains the memory address of y". Under water, x DOES contain the memory address, obviously, but because of the different philosophy, if you print/use x, you will get y in Rust; because the language assumes you want to be using the thing x references to, not that things memory address. (You can use the memory address if you want to, but that is not the default.)
C gets complicated if you have pointers to pointers... in Rust, the compiler keeps track of that for you, and does all the de-referencing automatically, to give you the original struct/stuff you're pointing to. (If you don't tell it to do something else.)
This, and the semantic code analyzer built into the compiler, are the two main reasons for me to prefer Rust nowadays. I can do without, and I can use C, but... well... maybe I'll port my engine to C at some point after I finish it, just to have a C version, but I don't know yet.
A few years ago, D was supposed to be the C killer (instead of C++ which everyone agrees is an abortion). Now D is dead, and joining the ranks of COBOL (according to TIOBE for what it's worth). And before that, there were countless others. ADA and Erlang for example, probably many more. Who's to say RUST won't bite C's dust like everyone else, and be the COBOL of the 2030s ?