Recompile Java Chess Programs To WebAssembly

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

User avatar
towforce
Posts: 12724
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Recompile Java Chess Programs To WebAssembly

Post by towforce »

Some time ago (late 1990s as best I remember) I used to tell everyone that Java was the future. At that time, JavaScript was slow (for programs with large numbers of loops or recursions - not its original function of doing little tasks in the browser page - it was always fast enough for that), and lacked important language features like type safety and decent objects. Having a good language that compiled to byte code and could be run in a browser page seemed like the ideal solution. Also, we already knew that Java would run on a large number of platforms, so it looked like the great universal language that would be good for almost all requirements. Since then, some disappointing (from the Java perspective) things happened:

* uptake wasn't as high as expected

* JavaScript got a lot faster

* questions arose about Java security

* finally, browsers dropped Java support

That last event was a killer! Lots of people who had written Java applications to run on a web page, making them convenient for users to use, woke up one morning to find that this no longer worked! I know that some chess programs were written in Java, and it's a tragedy that one can no longer use them by doing nothing more arduous than opening a web page.

However - nearly all the main web browsers now support something kind of similar: webassembly (link). It's blazingly fast (much faster than even today's JavaScript), and supports any language that can be compiled to its assembly language - which means, more or less, almost any language!

I am mystified as to why the browser community killed Java and has provided webassembly in its place - but it does provide an opportunity to put those Java programs back onto web pages where they belong!

Here's one compiler - link. Here's some information about compiling Java to webassembly - link.

I have used Blazor, which compiles to webassembly, myself to build a demonstration single page application in C#. Having used Blazor, I don't want to ever go back to any other way of building web applications. It's MILES better:

* development is MASSIVELY quicker
* objects can be passed right into the browser code
* unit testing can go right into the browser code

If you like your current method of building web applications, probably best not to tell your team about Blazor: I'm not the only one who has tried it and realised how bad the old ways of doing things are - lots of other developers feel the same way.
Human chess is partly about tactics and strategy, but mostly about memory
User avatar
towforce
Posts: 12724
Joined: Thu Mar 09, 2006 12:57 am
Location: Birmingham UK
Full name: Graham Laight

Re: Recompile Java Chess Programs To WebAssembly

Post by towforce »

Companies with chess servers (e.g. chess.com) should consider moving development to a webassembly platform. Where chess analysis is done in JavaScript, it would almost certainly be better done in webassembly:

* use a language of choice with type safety, good class structure etc

* better performance

* better front end to back end integration

etc.
Human chess is partly about tactics and strategy, but mostly about memory