paip-lisp icon indicating copy to clipboard operation
paip-lisp copied to clipboard

Run Common Lisp in Browser?

Open norvig opened this issue 6 years ago • 20 comments

Is it possible that each code fragment could be runnable and editable, right in the browser?

One way to get there is to create a docker container with the book, the code, a Common Lisp compiler, and an IDE.

Another way is to run code on a server and embed links to it. Some tools for this:

More attractive is to run right in the browser. But I couldn't find any tool that translates a big enough subset of Common Lisp to javascript; they were all too limited. It would be great if someone finds one that works. Here are some that will not work for various reasons:

norvig avatar Mar 01 '18 19:03 norvig

This is not exactly what you were asking: https://github.com/next-browser/next but related.

binarycrayon avatar Mar 01 '18 19:03 binarycrayon

JSCL is a start and still under development.

aarvid avatar Mar 02 '18 14:03 aarvid

JSCL looks promising! But not currently very active.

norvig avatar Mar 03 '18 21:03 norvig

Looks like there's at least one common lisp jupyter kernel for common lisp.

It'd still probably be a good idea to dockerize it though.

DwordPtr avatar Mar 04 '18 04:03 DwordPtr

Does anybody have experience with cl-Jupyter? https://github.com/fredokun/cl-jupyter/blob/master/about-cl-jupyter.ipynb

norvig avatar Mar 16 '18 00:03 norvig

Don't like the idea of JSCL, I'd expect Common Lisp compiles to WebAssembly rather than interpreted in js. I think it's possible to compile embedded common lisp or clasp with emscripten. The https://repl.it use emscripten to create client side REPL for many languages (unfortunately no CL). I'll give a try this weekend. If it doesn't work well I'll try cl-Jupyter.

ailisp avatar Mar 23 '18 14:03 ailisp

No comments about the notebook idea ? It maybe worth to try ...

arademaker avatar Apr 07 '18 03:04 arademaker

I am jscl author. I could give it a try to run examples in it. If some fragment doesn't work it is actually a good reason to activate the development a bit :-)

davazp avatar Apr 16 '18 12:04 davazp

@davazp it would nice to compare the jscl approach with jupyter notebooks . The Lean Theorem Prover is using a nice tool for produzing all their documentations too

https://leanprover.github.io/theorem_proving_in_lean/

Can we adapt it to run CL?

arademaker avatar Apr 16 '18 14:04 arademaker

@davazp, that would be great -- I'm looking forward to seeing what you can do.

norvig avatar Apr 16 '18 16:04 norvig

Slip: missing &key etc.

@norvig support for &key arguments could be achieved by redefining DEFUN and LAMBDA as macros on top of DESTRUCTURING-BIND, for which there is a fairly complete implementation. The reason I didn't do it is that (as I mentioned) it was really slow — but it could still be okay for didactical usage. More notably, however, SLip is missing LOOP, VALUES and CLOS (there's a TinyCLOS-based object system, but I wouldn't expect any real CLOS examples to work with it).

BTW I meant to say that SLip started out as a playground based on chapter 23 "Compiling Lisp" from this very book. While it remained just a playground, it was still a mind-blowing experience for me to work on it. Thank you for that chapter, and for the whole book!

mishoo avatar Aug 15 '18 14:08 mishoo

I wonder how practical it'd be to compile an interpreted Common Lisp to WebAssembly. As a preliminary, I just built CLISP for x86/Linux, and it looks like the stripped native binary and the memory image add up to a bit over 6MB:

$ ls -l lisp.run lispinit.mem 
-rw-r--r-- 1 parallels parallels 3140504 Apr  5 16:33 lispinit.mem
-rwxr-xr-x 1 parallels parallels 3195288 Apr  5 16:44 lisp.run

I tried to look up typical relative sizes for x86 binaries vs. WebAssembly, but didn't find it online.

darius avatar Apr 05 '19 23:04 darius

That seems like too much to download over a slow connection.

norvig avatar Apr 09 '19 22:04 norvig

Could cl-notebook be useful in this context? It's not fully browser-based, but I think it'd be possible to deploy a sandboxed instance somewhere (or even a set of on-demand instances).

inaimathi avatar May 05 '19 15:05 inaimathi

I have long held that Javascript is an abomination. I think that browsers should have en embedded lisp interpreter, not necessarily Common LIsp.

leed25d avatar Nov 18 '19 14:11 leed25d

I have used cl-jupyter and it worked fine for me.

mark-watson avatar Nov 18 '19 14:11 mark-watson

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

https://epiphany.pub/@shi-yan/Test-ClojureScript

(purely browser based, no backend)

Intro: https://epiphany.pub/@shi-yan/introduction

shi-yan avatar Nov 18 '19 14:11 shi-yan

Hello there, Hacker News!

pronoiac avatar Nov 18 '19 17:11 pronoiac

Glad to hear it Marc! So are you back in Arizona?

-rpl

Télécharger Outlook pour Androidhttps://aka.ms/ghei36


From: Mark Watson [email protected] Sent: Monday, November 18, 2019 3:09:18 PM To: norvig/paip-lisp [email protected] Cc: Subscribed [email protected] Subject: Re: [norvig/paip-lisp] Run Common Lisp in Browser? (#10)

I have used cl-jupyter and it worked fine for me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/norvig/paip-lisp/issues/10?email_source=notifications&email_token=AAKYSSTVFEQPCGW76K4WKA3QUKOY5A5CNFSM4ETDP2AKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEKRPXA#issuecomment-555030492, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAKYSSUO3CD3NTS44FWGPW3QUKOY5ANCNFSM4ETDP2AA.

delaray avatar Nov 18 '19 20:11 delaray

Maybe https://github.com/viebel/klipse?

arademaker avatar Nov 19 '19 14:11 arademaker