Do we have a browser connected REPL ?

95 views
Skip to first unread message

Pranav Bhaskar

unread,
Jun 26, 2021, 4:53:52 PM6/26/21
to BiwaScheme
Hi, 
I am a beginner in scheme and lisp languages in general. I've been learning clojure/script for about 6 months. 
I just learned about biwascheme today and am fascinated by it. 
I was building a tic-tac-toe game and loved working in my emacs, having an `npx biwascheme` repl open in a buffer and sending and evaluating expressions as i code. 
Now when i am thinking about building views for this app. I was wondering if there is a way i can have a repl connected with the browser like they have in clojurescript. so that i can evaluate browser specific functions like (alert "") etc., from my emacs buffer.

Thanks 

Thomas Elam

unread,
Jun 27, 2021, 7:21:57 AM6/27/21
to biwas...@googlegroups.com
I’d be very interested in that, too!

You should also be aware of Gambit Scheme. They have a very active group on the messaging platform. Gambit can be built to target JavaScript and can run in the browser. You could ask Prof. Marc Feeley about connecting Emacs to Gambit in the browser.

BiwaScheme loads very fast in the browser because it is so small, but with enough optimisation Gambit Scheme can be about 640kB of JavaScript.

--
You received this message because you are subscribed to the Google Groups "BiwaScheme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biwascheme+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biwascheme/6e02760d-ea75-4268-902b-8562ad6ed7ecn%40googlegroups.com.
--
Tom

ArooBaito Art

unread,
Jul 28, 2021, 3:39:16 AM7/28/21
to BiwaScheme
I think this would be a pretty easy project to do using websockets. The design of BiwaScheme makes it very easy to drop a repl in anywhere, I've done it for several node/electron and browser projects, so I haven't bothered to set up a full connection to the browser and emacs like Cider, but I'll put it on my list of things to do and I'll post a git repo. 

The reason I prefer BiwaScheme over Gambit is because Gambit creates one of those long ugly obfuscated js files like ClojureScript does, while BiwaScheme lets you host the actual SCM files since they're meant to be interpreted in real-time. 

In any case I'll post one up as soon as I'm done participating in this Lisp game jam. BiwaScheme works amazing with the 3D webGL libraries, I really can't say enough positive things about it! 

It can literally go anywhere javascript can! I modified my Discord client to have a BiwaScheme repl built into it using BiwaScheme itself, and I also coded a box that automatically pulls Scheme programming Tweets from Twitter. The sky is the limit with this labguage I tell you! 

unknown-9.png

Thomas Elam

unread,
Jul 29, 2021, 6:13:36 AM7/29/21
to biwas...@googlegroups.com
Aroo, I'm very interested in your work. Please keep us posted here.

On Wed, Jul 28, 2021 at 1:09 PM ArooBaito Art <arooba...@gmail.com> wrote:
I think this would be a pretty easy project to do using websockets. The design of BiwaScheme makes it very easy to drop a repl in anywhere, I've done it for several node/electron and browser projects, so I haven't bothered to set up a full connection to the browser and emacs like Cider, but I'll put it on my list of things to do and I'll post a git repo. 

The reason I prefer BiwaScheme over Gambit is because Gambit creates one of those long ugly obfuscated js files like ClojureScript does, while BiwaScheme lets you host the actual SCM files since they're meant to be interpreted in real-time. 

I've been wondering how (load "a-scheme-file.scm") would work with Gambit on JavaScript. I'll be looking into that, but maybe not anytime soon.
 

In any case I'll post one up as soon as I'm done participating in this Lisp game jam. BiwaScheme works amazing with the 3D webGL libraries, I really can't say enough positive things about it! 

Would you mind to post any particular pointers to online examples?
 

ArooBaito Art

unread,
Jul 29, 2021, 4:55:27 PM7/29/21
to biwas...@googlegroups.com
Thank you, I appreciate it!

Yes, I can think of a way for Gambit to load SCMs in real-time too if you had a NodeJS server running to execute the compiler and relay the compiled javascript back to the browser. I still think Gambit is a fantastic and very flexible Scheme, of course, since it's the "go anywhere" Scheme with its elaborate inter-op, but I prefer BiwaScheme and Gauche personally. They're easily my top 2. I usually host my static files with a Gauche Makiki server while I'm developing my 3D web apps, mostly out of habit since since BiwaScheme can do that just fine as well. Or I think Node itself even has a simple one-off "serve this folder" command somewhere.

As for examples, most of my own have a bunch of macros that may only be conducive to my own use, so I'll just code up a simple framework real fast and post it up here and on github!
I'll send it out when I get a chance later today. Here are a couple more examples of my work with BiwaScheme though:

My current big project is a re-creation of the Nintendo game Splatoon using the PlayCanvas webGL engine and the YUKA AI library, and maybe eventually SocketIO and Simple-Peer if I want to make it multiplayer. I'm extremely familiar with all 4 of these libraries, I highly recommend them. In any case, I call it LispLatoon since all the interfacing code and game logic (everything that's mine instead of the framework) is 100% in BiwaScheme:





Also, I used to work as a 3D artist in college! I sculpted all of the assets and created all the textures in Blender. You can also see in the bottom picture there's a developer's console you can open that will interpret any BiwaScheme you type into it. Like I said, it's ridiculously easy to shove BiwaScheme interpreters everywhere hahaha

And here's another example of my modified Discord client:



Here you can see that with Yutaka Hara's convenient RESTful macros your Scheme code has direct access to all kinds of services, like Discord's webhook bots. I also updated my ui elements to be draggable and resizable yesterday instead of hiding them with a hotkey like I was before, all in BiwaScheme.

It goes without saying that JavaScript has a ton of utility libraries that do really cool things, and with BiwaScheme you get access to all of those and the awesome power of macros and list processing that comes with Lisp. I've been using it for years and I still can't help but nerd out about it hahaha

I'm a pretty big fan. I only recently started joining Lisp communities though, I never knew BiwaScheme had a mailing list! In any case, my hat is off to Hara for the incredible implementation.
I'll post up that 3D framework in a bit!

ArooBaito Art

unread,
Jul 29, 2021, 11:54:40 PM7/29/21
to BiwaScheme
Alright, it's all set!


And you can also find it hosted live and running here:

https://aroobaito.itch.io/biwascheme-playcanvas-example

Let me know if you have any questions!

Thomas Elam

unread,
Jul 30, 2021, 3:22:05 PM7/30/21
to biwas...@googlegroups.com
Aroo, thanks a lot for the update! That's awesome tech! You have left me breathless!

Yes, Hara's work is really awesome, too. Perhaps I should double down on my study of it. I had a concern that conditions might not be handled completely. If I can, I will post an example. I think I saw a case where an error like divide by zero threw the interpreter into a global error handler. In my case it left a JavaScript handler enabled, when it was not supposed to be enabled. Or something like that. Sorry, I can't remember for sure. 😶

Tom


Thomas Elam

unread,
Jul 30, 2021, 3:22:50 PM7/30/21
to biwas...@googlegroups.com
I'll take a look after a few hours. Thanks for sharing! 😀
Tom


ArooBaito Art

unread,
Jul 30, 2021, 3:51:36 PM7/30/21
to biwas...@googlegroups.com
Oh that is unfortunate! I can't say I've run into any problems that weren't my fault yet hahaha

And you're welcome! I left in the quality of life JS from the PlayCanvas team which includes a simple loading screen, but I have actually translated start.js, loading.js, and modules.js to scms for my own project.

It works fine, but I wouldn't recommend it unless you're just dying that the entire project aside from playcanvas.min.js and biwascheme.js are in javascript, because otherwise it's just pointless busy work hahaha

Really that's what .gitattributes *.js linguist-detectable=false is for. You don't have to re-write boilerplate and your git project still goes under the Scheme language section!

Anyway, I appreciate the compliments, and let me know if you need anything else! I'll post up my own version of Clojure's Cider with Emacs + BiwaScheme when I get around to it sometime next week!

Thomas Elam

unread,
Jul 31, 2021, 3:08:48 AM7/31/21
to biwas...@googlegroups.com
Looking forward to a SLIME-type interface to Biwascheme!  That's what you'll be posting, right?

Tom


ArooBaito Art

unread,
Jul 31, 2021, 9:55:23 AM7/31/21
to biwas...@googlegroups.com
Yeah, pretty close! My original one is going to run on inferior Scheme and use that to relay the code from Emacs to the browser through a simple CLI, but I may eventually write a superior BiwaScheme mode for emacs in Elisp. It depends on how well it works really hahaha

I expect there to be a small delay between executing the command and seeing it in the browser this way, and if it annoys me enough I'll just write a superior mode for it.

ArooBaito Art

unread,
Jul 31, 2021, 6:18:03 PM7/31/21
to biwas...@googlegroups.com
I got my first pass of it working today! It works really well with inferior Scheme. I was wrong, there's actually no delay at all since I got it working in the same way that superior Lisps work after all.

image.png

You can select any block of code in emacs, press CTRL + X, CTRL + E, and then it'll send that code over to the server, evaluate it, and then send the answer back to emacs.
I just have to write the browser client for it to evaluate in the browser and the first version will be all done!

I was thinking about calling the library Shamisen as a pun on Biwa, but I suppose we'll see.

I'll have to do some more thorough testing before I release it, but I'm feeling pretty good about the progress so far. I'll keep you guys updated!

Thanks!

ArooBaito Art

unread,
Aug 1, 2021, 1:03:52 PM8/1/21
to biwas...@googlegroups.com
I wrote the browser client today, and it seems to be working exactly as expected!

image.png


The gif is a little large, so it might take a minute to load:



Anyway, I'll post the github link up later this week after I've fixed some rough edges!

Pranav Bhaskar

unread,
Aug 4, 2021, 3:49:06 PM8/4/21
to BiwaScheme
This is amazing, exactly what I needed. ArooBaito. Thank you for this.
I was about to ask for the github link, searched around and found it. https://github.com/ArooBaito/biwa-shamisen
Thanks. 🤩

ArooBaito Art

unread,
Aug 4, 2021, 6:06:43 PM8/4/21
to biwas...@googlegroups.com
You're welcome, that's great to hear!
I'm glad I could help, and I'm pretty stoked to make more tools and project with BiwaScheme, Yutaka Hara has really brought it to an amazing level of polish! 

Let me know if you find any bugs with Shamisen here or in the issues tab! 

You received this message because you are subscribed to a topic in the Google Groups "BiwaScheme" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/biwascheme/8-qQpfAgwo4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to biwascheme+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biwascheme/cea1d53d-d61c-4f8d-b35b-f09dd634c703n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages