scittle

2023-10-24T19:13:48.257399Z

Hey, I want to continue the investigation that Alan started a while ago about how to get Hoplon working with scittle (https://clojurians.slack.com/archives/C034FQN490E/p1681589879531369) I would like to confirm that jvm based macros are a problem and what would be the options to get it working as a scittle plugin. I think I read something about using sci to run the macros, but I'm not really sure.

2023-10-25T17:54:21.324879Z

Thanks! I have lots to read now.

borkdude 2023-10-26T10:02:26.834009Z

If you need any help, let me know, I can guide you in a similar way as I did with @holyjak . I don't know hoplon but I've never had a project so far that with enough porting (macros) didn't work with a SCI configuration. cc @alandipert

2023-10-26T12:56:03.095799Z

I think that another option is going full self-hosting, I think that should also work right? I also need to work first on a setup that allow me to see what is not working and needs to change.

borkdude 2023-10-26T13:08:54.226579Z

self-hosted could also work, whatever you want. looking at those macros, it shouldn't be hard to make it work with SCI I think

2023-10-26T13:10:54.351819Z

Hoplon macros should not be a problem. But we depend on javelin and those are a bit more complicated to fix.

borkdude 2023-10-26T13:14:01.979179Z

more difficult, but not impossible

borkdude 2023-10-26T13:14:57.707449Z

a quick look: I think you only have to replace cljs.analyzer with something else, but since you're only using macroexpand-1 and a/specials this should not be a problem

borkdude 2023-10-26T13:16:05.967159Z

you could maybe have fast-path by first just evaluating the whole macro namepaces inside of SCI instead of making them external

borkdude 2023-10-26T13:16:13.397179Z

and then just use copy-ns for the normal functions

borkdude 2023-10-26T13:16:31.117849Z

if that works, you can optimize by making the macros external functions

borkdude 2023-10-26T13:39:17.610769Z

@mynomoto @alandipert I downloaded javalin.core as javelin_core_macros.cljc and made a few tweaks. this works with nbb (which is a SCI environment):

(ns script)

(create-ns 'cljs.analyzer)

(intern 'cljs.analyzer 'specials '#{& case* defrecord* try ns* loop* do letfn* if new ns deftype* let* js* fn* recur set! . var quote throw def})

(intern 'cljs.analyzer 'macroexpand-1 macroexpand-1)

(create-ns ')

(require '[javelin-core-macros :as m])

(prn (macroexpand '(m/prop-cell 1)))
;;=>
(let* [ret__587__auto__ (javelin-core-macros/cell 1)] (js/setInterval (fn* [] (clojure.core/reset! ret__587__auto__ 1)) 100) (javelin-core-macros/cell= ret__587__auto__))

borkdude 2023-10-26T13:40:35.234789Z

the only tweaks I needed to make were:

#?(:cljs (def Exception js/Error))
and changing pprint/write into something else since that doesn't exist in CLJS

borkdude 2023-10-26T13:40:53.047059Z

oh it does, but it's not exposed in SCI I guess

borkdude 2023-10-26T13:41:29.436709Z

but this is a minor detail, the point is, that the macros could just be evaluated inside of SCI itself, rather than copy/pasting them into a SCI config (which eventually might be better for performance)

2023-10-26T14:43:59.803589Z

Ok, let me see if I understood. We would need to do this: > the only tweaks I needed to make were: >

#?(:cljs (def Exception js/Error))
> and changing pprint/write into something else since that doesn't exist in CLJS And hoplon/javelin would work using scittle?

borkdude 2023-10-26T14:46:44.006559Z

right now I'm already making a SCI config for javelin, I hope to make it work within an hour

borkdude 2023-10-26T14:47:12.925699Z

no, there is more to it to make hoplon work

borkdude 2023-10-26T14:47:38.778909Z

but this is the hardest step as you said

2023-10-26T15:09:44.755249Z

This is amazing! Thank you for helping!

borkdude 2023-10-26T19:07:47.980129Z

@mynomoto it took a bit longer than I thought and fixed/added some things in SCI but here it is: https://babashka.org/sci.configs/?gist=e83da19df3d2739861334171779f79d5

2023-10-26T19:18:55.303239Z

Thank you so much, this is incredible!

2023-10-26T19:19:46.374619Z

(set! *print-fn* attach-msg) TIL about printing to dom 🤯

borkdude 2023-10-24T20:22:12.134749Z

@mynomoto There was a recent addition to sci.configs for fulcro: https://github.com/babashka/sci.configs doing a similar thing for hoplon would work. yes, macros (of course) need to exist at runtime as functions else you cannot use them from SCI

borkdude 2023-10-24T20:23:36.135029Z

You can follow the conversation that @holyjak and I had in #sci about this here: https://app.slack.com/client/T03RZGPFR/C015LCR9MHD#:~:text=Friday%2C%20September%2029th-,12%3A59%20PM,-Jakub%20Hol%C3%BD%20(HolyJak