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.
Thanks! I have lots to read now.
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
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.
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
Hoplon macros should not be a problem. But we depend on javelin and those are a bit more complicated to fix.
more difficult, but not impossible
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
you could maybe have fast-path by first just evaluating the whole macro namepaces inside of SCI instead of making them external
and then just use copy-ns for the normal functions
if that works, you can optimize by making the macros external functions
@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__))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 CLJSoh it does, but it's not exposed in SCI I guess
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)
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?right now I'm already making a SCI config for javelin, I hope to make it work within an hour
no, there is more to it to make hoplon work
but this is the hardest step as you said
This is amazing! Thank you for helping!
@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
Thank you so much, this is incredible!
(set! *print-fn* attach-msg) TIL about printing to dom 🤯
@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
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