Go-lang can also compile to webassembly (WASM). I was trying to make Rye compile to WASM with TinyGo for a while and this weekend I managed to produce a build. TinyGo is an alternative compiler that uses LLVM and should produce much smaller wasm packages. The compilation passed but I wasn't able to make the full interpreter work in a browser.
I could be wrong but it seems
that a PEG parser library that I am using drastically increases the
.wasm size (to 6MB) and compilation time to more than 45 minutes. I
could be wrong. I will explore this option later but I decided not to
take many more 45 minute tries. Consequent compilations can be much much
faster, but if I remove and add the dependency it seems I am back to 40
minutes gone. Another option would be to rewrite a loader in a simpler PEG
parser generator (not a "library"), but not this weekend.
So I
tried the native Go WASM compilation and .wasm in my case was "just" 3MB
(without the PEG parser I think it was 1MB). The compilation was immediate
as usual in Go, and a very nice error message from Go in the browser
console persuaded me to go this route for now.
The goal is not tothink Rye could be used instead of JavaScript in a browser environment,
but it could be a Glue/Declarative component and I can think of many
interesting experiments with Rye or even Spruce in the front-en.
Below is a minimal demo using a browser based code editor component Ace. It evaluates the code when I press Ctrl+X and displays the output and the result of the code below.
Komentarji
Objavite komentar