scittle

borkdude 2024-04-30T10:37:08.637579Z

scittle should now be easy to use in non-browser contexts or webworkers since the hardcoded dependency on js/document is now made optional

😍 1
1
borkdude 2024-04-30T12:37:41.604069Z

import scittle from 'scittle/dist/scittle.js';
console.log(scittle.scittle.core.eval_string('(+ 1 2 3)'));

john 2024-04-30T20:06:24.331459Z

So that's a bit over 800 KB on disk? Do you know how long the worker startup takes? I'm curious of another strategy of compiling to js first and then sending that to the worker, after booting it with basically no deps. I'm curious if that'd be faster than loading scittle in the worker.

john 2024-04-30T20:07:01.491669Z

I think worker boot up is getting faster for scenarios without a lot of deps

john 2024-04-30T20:07:51.038629Z

Still kinda slow for larger deps

john 2024-04-30T20:08:23.587039Z

This is awesome though

john 2024-04-30T20:10:04.993769Z

But a 5K worker and a 500K worker can serve completely different usecases, in terms of how much longer 500K starts to boot, last time I checked

borkdude 2024-04-30T20:10:11.007599Z

yeah compiling to JS works with #squint

john 2024-04-30T20:12:36.284409Z

Yeah true

john 2024-04-30T20:13:25.011889Z

I didn't finish my port of cljs-thread to squint

john 2024-04-30T20:13:38.355179Z

You can essentially send beans "over the wire" transparently though

borkdude 2024-04-30T20:13:49.574129Z

here is just a silly example I made, triggered by someone who suggested you could also use scittle in a webworker if you remove the dependency on js/document. I have no practical use for it at the moment, but it works https://clojurians.slack.com/archives/C034FQN490E/p1714502074884559

👀 1
john 2024-04-30T20:13:54.105019Z

I guess js folks can pass objects back and forth pretty easily

borkdude 2024-04-30T20:14:10.386259Z

yeah that seems to work

borkdude 2024-04-30T20:14:13.510009Z

not sure what the limitations are

john 2024-04-30T20:14:32.399149Z

A lot of stuff gets serialized

john 2024-04-30T20:14:36.121969Z

apparently

borkdude 2024-04-30T20:14:42.393279Z

to what, a string?

john 2024-04-30T20:14:55.391409Z

a "transferable" but yeah pretty much I think

john 2024-04-30T20:15:08.704189Z

better than a string for somethings

john 2024-04-30T20:15:18.246109Z

if you build a transferable interface for it or something

john 2024-04-30T20:15:43.235619Z

but in my experience it's mostly the same performance as just using strings

john 2024-04-30T20:16:24.735449Z

Probably not for basic objects though

borkdude 2024-04-30T20:16:56.809279Z

I guess if you use the same scittle version on the page and worker, CLJS maps etc should maybe just work, I'll give it a try

john 2024-04-30T20:17:49.062689Z

there's no goog-closure compiler right? Should work better than cljs

john 2024-04-30T20:18:12.596359Z

oh skittle is compiled with it

john 2024-04-30T20:18:30.692989Z

Yeah, that's what works in cljs-thread

john 2024-04-30T20:18:50.509629Z

we're sending compiled versions of the forms "over the wire"

john 2024-04-30T20:19:21.600389Z

And it all has to be from the same artifact to work correctly

john 2024-04-30T20:20:10.947749Z

Or you can use two different builds and only call exported fns between them

john 2024-04-30T20:20:58.667989Z

But scittle forms don't depend on the closure compiler the scittle compiler is compiled with, right?

john 2024-04-30T20:21:17.425109Z

sci gets us around the abi problem, right?

borkdude 2024-04-30T20:22:06.587509Z

abi problem?

borkdude 2024-04-30T20:22:51.539069Z

SCI in scittle is compiled using advanced compilation. you must use the exact same version to exchange CLJS maps or they will be incompatible

john 2024-04-30T20:23:13.162439Z

But can't we send them as strings?

john 2024-04-30T20:23:18.623349Z

how are they different maps?

borkdude 2024-04-30T20:23:30.873439Z

you could convert them first to JS and then back, but otherwise they don't work the same because of closure renaming all the things

borkdude 2024-04-30T20:23:47.464829Z

yes, you could send them as strings, of course, no problem there

john 2024-04-30T20:23:56.238189Z

oh, you mean sending compiled forms over the wire

john 2024-04-30T20:24:01.910589Z

gotcha

borkdude 2024-04-30T20:24:03.799989Z

yes

john 2024-04-30T20:24:47.924169Z

Yeah minified cljs over the wire is actually pretty performant as a intermediate representation for sending code between workers

john 2024-04-30T20:25:17.668569Z

Everything goes a lot faster in cljs-thread in the advanced compiled version

borkdude 2024-04-30T18:34:34.884559Z

https://jsfiddle.net/borkdude/3nmxhwju/

🔥 2