
PAIP: Run Common Lisp in Browser? - register
https://github.com/norvig/paip-lisp/issues/10
======
aidenn0
Something not mentioned here is that ABCL[1] will run in DoppioJVM[2], but the
startup time is on the order of an hour last time I tried, so it's not yet
practical.

1: [https://common-lisp.net/project/armedbear/](https://common-
lisp.net/project/armedbear/)

2: [https://plasma-umass.org/doppio-demo/](https://plasma-umass.org/doppio-
demo/)

[edit]

With the doppio demo linked, I get a REPL in about 2 minutes on chromium and
under 5 on firefox. That's a huge improvement since I last tried.

Performance is not great though; I ran the gabriel "boyer" test and it was
0.288 second on openjdk 1.8 and 63 seconds on Doppio in chromium.

~~~
rademaker
In my machine it took seconds.

~~~
aidenn0
Which version of ABCL were you running? I tested with the 1.5.0 binary jar.

------
wooby
I am working on a CL for JS that I will likely share at some point. I post
updates about it occasionally to Mastodon [1] if anyone is interested in
following my progress. I'm also happy to discuss rationale, design, and
implementation -- it's been really fun to work on.

1\.
[https://mytoot.net/@alandipert/103120653862853368](https://mytoot.net/@alandipert/103120653862853368)

------
billconan
I'm making a programmable blog, aiming to become a platform for interactive
e-textbooks. (thinking Medium.com + Jupyter Notebook)

I recently added support for ClojureScript

[https://epiphany.pub/@shi-yan/Test-ClojureScript](https://epiphany.pub/@shi-
yan/Test-ClojureScript)

An Intro: [https://epiphany.pub/@shi-
yan/introduction](https://epiphany.pub/@shi-yan/introduction)

------
NoahTheDuke
I wonder why Clojurescript succeeded where Common Lisp hasn’t: compiling a
lisp to javascript. Is Common Lisp particularly tricky in some way that
Clojure isn’t?

~~~
patrec
a) Common lisp was already in undead state when Javascript became big. Semi-
dead languages as a rule have worse tooling for "new" stuff.

b) Clojure didn't really fully succeed, there were annoying differences
between Clojure and Clojurescript last time I looked. There are compilers for
incomplete subsets of CL to JS as well, although presumably much worse ones.

c) There's some stuff in Common Lisp that's quite hard to do efficiently on
top of most existing language runtimes. For example resumable exceptions and
lua/CL-style optional multiple return values. In assembler or without concern
for efficiency the last one is trivial, otherwise, not so much.

d) Clojurescript could bootstrap existing fancy JVM platform stuff (closure
compiler) to do quite a lot of heavy lifting.

~~~
aidenn0
B & C are good points, but...

A) Writing a new Common Lisp implementation is a major undertaking, but a new
implementation was creates specifically for C++ interop[1], and that
implementation is certainly post javascript being big.

D) Anything targeting JS can run the output through closure; I've done so with
Parenscript, for example.

1: [https://github.com/clasp-developers/clasp](https://github.com/clasp-
developers/clasp)

~~~
patrec
A) I'm well aware of clasp, and its a cool project (and post javascript, as
well) but it's hardly anywhere near production quality right now (unlike say,
clojurescript). So I don't think it's a counters my argument about the CL
ecosystem (I'm sceptical that it would make much of a dent even if it becomes
a technical success beyond Dr Meister's wildest dreams).

D) Of course, but if you require some additional JVM based tooling for a JVM
language like clojure, you lose 0% of your potential audience and introduce no
additional friction, which is not at all the case for CL (nor would it be for,
say C++ or Lua).

------
Megranium
This topic comes around every couple of months, here and elsewhere.

I tried to run some of my CL stuff in JSCL, but the browser just froze, so I
quickly gave up on that. Guess it can't handle more complex stuff.

I wonder if someone ever tried to compile a C-based CL implementation (like
sbcl) to WebAssembly (i.e. using emscripten) ? I'd be surprised if nobody ever
tried that, but I never read any reports regarding success or failure.

------
mark_l_watson
To answer Peter’s original question, cl-jupyter works fine, at least when I
used it in 2018.

------
pcr910303
I would like to implement a web front end or a Common Lisp LSP server based on
swank/slynk if I had time...

Does anyone know about prior works I could potentially contribute to?

------
regularfry
The thought that immediately springs to mind is bootstrapping CL on top of
parenscript.

~~~
regularfry
...and [https://github.com/jscl-
project/jscl/blob/master/src/compile...](https://github.com/jscl-
project/jscl/blob/master/src/compiler/codegen.lisp) makes it look like that's
almost what's going on here, but not quite.

------
zelly
clasp (LLVM frontend for Common Lisp) to Emscripten would be interesting.

~~~
aidenn0
Does LLVM self-host in emscripten yet? It didn't last time I checked.

~~~
zelly
It doesn't, that's a shame. It would definitely have to be a custom fork of
either Clasp or Emscripten anyway because CL's "memory dump" way of creating
executables would be too cumbersome to run in browsers. Someone might as well
make a CL -> WASM compiler directly--in CL so that it could be more easily
self-hosted.

~~~
aidenn0
I did a quick scan of the WASM standard, and there don't appear to be any
instructions that let you e.g. add new functions, so it's not even clear to me
how you would call WASM that you had newly generated.

------
gowld
could a bit of JS code in the page upload the snippet to tio.run or repl.it
for execution?

Or someone could semi-manually create links for all the snippets?

