Hi,
I've been toying around with the idea to run ecl in the browser since it is now easy to build it using emscripten.
I have successfully interacted with the runtime using the extremely awkward "window.prompt" native javascript pop up.
My experience in using ECL is in embedding it in C/C++
Has someone successfully used it to run in the browser without using the "wasm-draw-to-canvas" and "windows.prompt" REPL
I'm assuming that this has nothing to do with ECL and is purely how emscripten works.
Can I write a more embedded version which does not require me to interact through the REPL in the browser.
If anyone has done any similar things I'd really like to hear about them.
Kindest regards.
Jon Hallur
Hey,
I've only made a puny javascript thing, but it is possible to have a "normal" repl. I've been approached by the author of "eclweb" - this person used xterm magic to make it more compelling:
https://opensource.chee.party/chee/eclweb
There's also an online repl:
I'm not offiliated with them, so I don't know how long the online version will persist.
Best regards, Daniel
-- Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland TurtleWare - Daniel Kochmański | www.turtleware.eu
"Be the change that you wish to see in the world." - Mahatma Gandhi
On Saturday, December 30th, 2023 at 14:39, Jón Hallur Haraldsson jonhallur@gmail.com wrote:
Hi,
I've been toying around with the idea to run ecl in the browser since it is now easy to build it using emscripten.
I have successfully interacted with the runtime using the extremely awkward "window.prompt" native javascript pop up.
My experience in using ECL is in embedding it in C/C++
Has someone successfully used it to run in the browser without using the "wasm-draw-to-canvas" and "windows.prompt" REPL
I'm assuming that this has nothing to do with ECL and is purely how emscripten works.
Can I write a more embedded version which does not require me to interact through the REPL in the browser.
If anyone has done any similar things I'd really like to hear about them.
Kindest regards.
Jon Hallur
Awesome, thanks for the info!
On Sat, 30 Dec 2023 at 13:50, Daniel Kochmański daniel@turtleware.eu wrote:
Hey,
I've only made a puny javascript thing, but it is possible to have a "normal" repl. I've been approached by the author of "eclweb" - this person used xterm magic to make it more compelling:
https://opensource.chee.party/chee/eclweb
There's also an online repl:
I'm not offiliated with them, so I don't know how long the online version will persist.
Best regards, Daniel
-- Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland TurtleWare - Daniel Kochmański | www.turtleware.eu
"Be the change that you wish to see in the world." - Mahatma Gandhi
On Saturday, December 30th, 2023 at 14:39, Jón Hallur Haraldsson < jonhallur@gmail.com> wrote:
Hi,
I've been toying around with the idea to run ecl in the browser since it is now easy to build it using emscripten.
I have successfully interacted with the runtime using the extremely awkward "window.prompt" native javascript pop up.
My experience in using ECL is in embedding it in C/C++
Has someone successfully used it to run in the browser without using the "wasm-draw-to-canvas" and "windows.prompt" REPL
I'm assuming that this has nothing to do with ECL and is purely how emscripten works.
Can I write a more embedded version which does not require me to interact through the REPL in the browser.
If anyone has done any similar things I'd really like to hear about them.
Kindest regards.
Jon Hallur
Dear Jon,
interacting between Lisp and javascript in a browser can be done by directly calling functions from ECL's C interface from javascript or vice-versa using the available methods to call javascript from C and ECL's C foreign function interface. A description for how to call C from javascript and vice-versa can be found at https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interactin...
Another thing to keep in mind is the asynchronous nature of javascript running in a browser which does not integrate easily with the synchronous IO interface of Common Lisp. If you want to keep the Lisp runtime running in the background, waiting for input to arrive, there are two options: either compile with LDFLAGS="-sASYNCIFY" (https://emscripten.org/docs/porting/asyncify.html) or run ECL in a separate thread (by means of a WebWorker) while communicating with the UI thread via Atomics.wait and SharedArrayBuffer's.
For an example of the latter option, you can look at the ECL repl https://repl.chee.party/ that Daniel has linked to or also at https://sourceforge.net/u/mgerbershagen/maxima/ci/emscripten-port/tree/ which contains a very rough early-stage port of the maxima computer algebra system to a browser environment (in particular the wasm subdirectory and the src/ecl-port.lisp file are relevant).
Best regards,
Marius Gerbershagen
Am 30.12.23 um 14:39 schrieb Jón Hallur Haraldsson:
Hi,
I've been toying around with the idea to run ecl in the browser since it is now easy to build it using emscripten.
I have successfully interacted with the runtime using the extremely awkward "window.prompt" native javascript pop up.
My experience in using ECL is in embedding it in C/C++
Has someone successfully used it to run in the browser without using the "wasm-draw-to-canvas" and "windows.prompt" REPL
I'm assuming that this has nothing to do with ECL and is purely how emscripten works.
Can I write a more embedded version which does not require me to interact through the REPL in the browser.
If anyone has done any similar things I'd really like to hear about them.
Kindest regards.
Jon Hallur
Hi all,
Thanks for this thread, I've been very interested in getting my common lisp project to run in ECL and Emscripten. A little before the release, I managed to hack my way through the instructions to get an ECL Emscripten build working with the dialog prompted ECL terminal. I'd like to try and work out how to put together the following 2 proof of concepts as a springboard for future work.
1. Figuring out how to just bundle my entire ASDF project with enough of it's dependencies, so that I can instantiate something (like a class or a struct) from my project in the REPL. 2. Figure out how to get an OpenGL triangle working using cl-opengl along with the glfw or sdl2 support built into Emscripten.
I'm more or less totally new to Emscripten, and I'm in the process of getting my source to run on ECL (it at least fully loads now and can run the unit tests with a few passing. It currently has dependencies on Lispworks, but i'm making fair progress with it getting closer to ECL and SBCL).
If there are any small projects lying around or pointers I should look for this bootstrapping process it'd be appreciated.
Thanks! Steve
On 12/31/23 8:17 AM, Marius Gerbershagen wrote:
Dear Jon,
interacting between Lisp and javascript in a browser can be done by directly calling functions from ECL's C interface from javascript or vice-versa using the available methods to call javascript from C and ECL's C foreign function interface. A description for how to call C from javascript and vice-versa can be found at https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interactin...
Another thing to keep in mind is the asynchronous nature of javascript running in a browser which does not integrate easily with the synchronous IO interface of Common Lisp. If you want to keep the Lisp runtime running in the background, waiting for input to arrive, there are two options: either compile with LDFLAGS="-sASYNCIFY" (https://emscripten.org/docs/porting/asyncify.html) or run ECL in a separate thread (by means of a WebWorker) while communicating with the UI thread via Atomics.wait and SharedArrayBuffer's.
For an example of the latter option, you can look at the ECL repl https://repl.chee.party/ that Daniel has linked to or also at https://sourceforge.net/u/mgerbershagen/maxima/ci/emscripten-port/tree/ which contains a very rough early-stage port of the maxima computer algebra system to a browser environment (in particular the wasm subdirectory and the src/ecl-port.lisp file are relevant).
Best regards,
Marius Gerbershagen
Am 30.12.23 um 14:39 schrieb Jón Hallur Haraldsson:
Hi,
I've been toying around with the idea to run ecl in the browser since it is now easy to build it using emscripten.
I have successfully interacted with the runtime using the extremely awkward "window.prompt" native javascript pop up.
My experience in using ECL is in embedding it in C/C++
Has someone successfully used it to run in the browser without using the "wasm-draw-to-canvas" and "windows.prompt" REPL
I'm assuming that this has nothing to do with ECL and is purely how emscripten works.
Can I write a more embedded version which does not require me to interact through the REPL in the browser.
If anyone has done any similar things I'd really like to hear about them.
Kindest regards.
Jon Hallur