maksimKorzh wrote: ↑Tue Jan 19, 2021 4:20 pm
Marcel, you've made my day)))
But what is so genuine in working JS chess engine?
Did you have a look at WukongJS's source?
It's very simple and straightforward.
The problem is Javascript. (Or PHP, or Python, or any weak, untyped language). In some of those languages, it's possible for a variable to start out as an array, and end up as an int, being a float and a bool in between. Stuff like that creates subtle and hard to find bugs. If something breaks in Javascript, you often don't get any errors; stuff just stops working and nobody knows why.
My problem is not with Javascript per se; I like Typescript, which is Javascript with types (duh...), and I don't care if a language compiles to Javascript or whatever. (Rust compiles to LLVM's intermediate language, and is then optimized as if the original code was written in C.) I just dislike weakly typed languages, and I utterly hate weakly typed, dynamic languages.
What's the difference in say array manipulation typed vs untyped?
In a weakly typed language, a variable can change type. Lets say, in pseudo-code (non-existing functions, but you get the idea):
Code: Select all
let x = array(); <= x is now an an empty array, obviously.
x = create_some_stuff(); <= here, X is filled up.
x = delete_from_array(x, "bye") <= remove "bye" from X
// Assume "bye" is not in X, thus delete_from_array() returns false (instead of the original array), which doesn't give an error.
// Now... x is false, and it's a bool, not an array.
if (x !== undefined) {
// X isn't undefined... it's "false". But it's not what we expected it to be.
let item = first_item_from_array(x) <= this should be "undefined" if the array is empty, or be x[0], but it crashes because x is no longer an array
...
}
This makes code very error prone and hard to read.
PHP does similar things. I know... I've ported a massive (older) application recently, to a new platform. I've fixed hundreds of these bugs in the last 10 months.
And things like movestack are even simpler to implement compared to C because you can simply .push(move) and .pop() it back
and don't need to care about cleaning memory. Definitely it has some downsides in the performance but one of my subscribers
implemented almost 10x faster movegen just because he's good at optimizing JS code (he didn't use different algorithms).
This helped me to improve my version at least 6x times (his didn't have all the functionality yet, like piece lists, hashes, etc.)
And JS is extremely beneficial if you want to deliver your engine to people willing to play with it!
Javascript is easy to write, but hard to debug. I prefer the other way around: hard to write, but easy to debug
You know why I prefer Rust: because it's strictly and strongly typed, and certainly NOT dynamically typed, so the compiler is able to point out ANY mistake you made, before even compiling. Javascript (and Python, and PHP, etc...) are the complete opposites of Rust.
P.S. Making a product with "bells & whistles" exactly for users to play chess at different levels is my new prior goal now.
I've realized that the vast majority of chess players are 1700-2100 Elo and my engine would be a perfect sparring partner for them.
I still really doubt that I would be able to monetize it one day but at least the youtube community is growing and at very least it opens
some potential opportunities for me as a chess programmer.
At some point, Rustic will also get levels.
Instead of a user interface though, I'll probably lift the DGT-board code from Picochess first, and create a library out of it, so anyone can create a chess program / GUI to talk to a DGT-board. Now it's written in Python, and *IT DOESN'T RUN ON WINDOWS*. Not that I love Windows like nothing else, but if I write software, I don't want to instantly alienate like 80% of the potential users.
Rustic cleanly compiles on Windows, Linux (x64 and the Raspberry), and probably on the Mac too. I'd love to have a DGT-library that can do the same, and then write a Rust version of Picochess on top of it. Better yet, I can use my own chess engine/move generator as a backend for that project.
As you can see, I'm writing stuff for me, myself, and I. It's open source, if people want it they can download it (I've provided my own personal Picochess image) and use it however they like, but the first person I'm writing for is me.