Re: OpenEuphoria and WebASM
- Posted by petelomax Aug 15, 2018
- 1483 views
I gave it another spin... After creating and building the hello world in C example on https://webassembly.studio/ I downloaded it and tried to run it locally, at which point I got
Fetch API cannot load file:///C:/Users/Pete/Downloads/wasm-project/out/main.wasm. URL scheme must be "http" or "https" for CORS request.
So I uploaded it to my web page and ran it, to get a green screen with a 0 on it, and I had to open Developer Tools and click on Console to see the "Hello World".
I conclude that decent examples are still very hard to find, and that
Edit->Run
would become
Edit->Compile to wasm->Login to cPanel->Zip->Upload->Unzip->Open web Page->Open Developer Tools->Open Console->Scratch Head->Rinse, Cycle, Repeat
as compared to [or maybe not, see last point below]
Edit->Compile to Javascript->Run Locally->Scratch Head->Rinse, Cycle, Repeat
and I'm still not really getting what wasm offers that js does not...
To end on one positive idea stemming from all this though:
Just as main.js in that wasm example contains
let x = '../out/main.wasm'; fetch(x)
a js-only solution might look more like
<script src="./compiled.js"></script> <script src="./main.js"></script>
and in that way we might only have to create fairly straightforward data (il/bytecode of our own design) rather than actual js code.
(Of course we still have to write main.js which contains lots of js code, what I am saying is we might not have to write a program which writes lots of complex js code.)
(Plus, we could possibly have a main.e (and a compiled.e pretty similar to the compiled.js) which emulates main.js in a local/debug-able fashion...)
Pete
PS: This looks quite interesting, and all done in a single source file of just 6087 lines of fairly readable vanilla js: http://tau-prolog.org/
PPS: An even simpler starting point (<250 lines of js): https://www.codeproject.com/Articles/345888/How-to-write-a-simple-interpreter-in-JavaScript