dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
2018-12-13T15:25:15.000700Z

I am looking for an example project that uses Boot, anyone have one?

2018-12-13T16:47:23.001200Z

AFAIK, boot-cljs-devtools had support at some point: https://github.com/boot-clj/boot-cljs-devtools/blob/master/src/powerlaces/boot_cljs_devtools.clj#L74

2018-12-13T17:06:18.001700Z

Yeah, i've seen that but the source is really opaque to debug, looking to just natively do it

2018-12-13T18:07:46.003200Z

Darwin, has there been any discussion about level of effort to bring this to browsers running self-hosted clojurescript? (A very weird idea, just curious if it has been thought about before)

2018-12-13T18:08:46.003800Z

some people on reddit mentioned it in the past, where I replied, but I’m not aware of any discussion

2018-12-13T18:09:21.004600Z

it can be done, but I’m not sure how useful it would be, Dirac is meant as a “pro” tool, not a toy for someone to play with cljs in browser console

2018-12-13T18:09:39.004800Z

^ my personal opinion

2018-12-13T18:10:10.005500Z

haha yes but in the future selfhost may be pro tool 🙂 Have you seen http://hyperfiddle.net ? Very much not a toy

2018-12-13T18:10:57.006200Z

I’m aware of hyperfiddle, but quite frankly I didn’t understand much of it, it was over top of my head… 😕

2018-12-13T18:11:13.006600Z

but I understand that a massive ton of work went into it

2018-12-13T18:12:22.007300Z

i am cofounder of hyperfiddle - when you say "it can be done" what is the level of effort required? E.g. a month, six months, longer

2018-12-13T18:13:54.008500Z

wait maybe I misunderstood your question now when I’m reading it again, I was under impression, that you wanted hosted-clojurescript REPL in Dirac, not Dirac being part of a normal browser installation

2018-12-13T18:14:25.009Z

i am wondering what it would take to offer the dirac debugging experience in prod

2018-12-13T18:14:35.009300Z

for userland clojurescript stored in a database

2018-12-13T18:15:06.009500Z

but compiled in browser, not compiled in nrepl

2018-12-13T18:17:00.009700Z

thinking…

2018-12-13T18:32:50.016700Z

well, I think getting basic REPL evaluations working would be a weekend project, when user enters something in DevTools Console in Dirac Prompt, sendEvalRequest[1] is called, current implementation needs to behave like a nREPL client, send it to nREPL server, which compiles the cljs code to js, sends it back to weasel-like client, which requests its evaluation in app’s js context and then result is sent back*, see[2] in case of self-hosted cljs it would be much simpler: the request would be sent to app’s javascript context helper function, which would compile it using self-hosted compiler, eval it and send result back (*technically it is not needed, because output is printed into console as a side-effect, I call it “short-circuiting-presentation”) but this would be a barebone thing, people maybe expect some repl-special commands to work, like in-ns, doc etc. is there a working REPL implementation for self-hosted clojurescript? [1] https://github.com/binaryage/dirac/blob/master/resources/unpacked/devtools/front_end/console/ConsoleView.js#L1006 [2] https://github.com/binaryage/dirac/blob/master/docs/about-repls.md#dirac

2018-12-13T18:34:27.017700Z

If there is not a self-hosted REPL it is possible to build though right? I guess the question is how much involvement from clojure/core team?

2018-12-13T18:35:45.018500Z

I don’t think we would need any special support from core team. Assuming we would not hit some bugs in self-hosted implementation.

2018-12-13T18:36:35.019300Z

I just need working self-hosted compiler in app’s js context. That would be primarily a job of hyperfiddle to setup it properly.

2018-12-13T18:36:57.019800Z

I need something like compile-cljs and eval I have in js by default

2018-12-13T18:37:47.020900Z

but it would be more involved, we want to execute those functions from devtools so they work even when app’s js context is stopped on a breakpoint, but that is a minor detail

2018-12-13T18:39:17.021800Z

I see

2018-12-13T18:39:58.022900Z

Antonin thanks for writing this down, i will save it off. What you've done with Dirac is very impressive, and i know you incur quite the burden maintaining and supporting installation etc

2018-12-13T18:41:52.024500Z

just note that hosted-clojurescript compiler must be in app’s js context, to match version of app’s cljs code - I cannot “embed” it into Dirac itself, because that could be version mismatch, also other Dirac features (like code completion) rely on non-minified code and sourcemaps, so hyperfiddle (even in prod) must contain them for these to work properly

2018-12-13T18:42:56.025500Z

Yeah, i understand. I think we might even already be saving off analyzer state from the build and sending it down to initialize the browser compiler. Have i understood what you're saying?

2018-12-13T18:43:23.025800Z

(^ That could be wrong, my co-founder handles this stuff)

2018-12-13T18:46:35.028Z

I think this is another thing, I’m talking about situation when Dirac would have self-hosted compiler embedded and used it instead of in-page compiler, that could lead to unexpected compatibility issues, because “REPL” evaluations would be produced by a different compiler version

2018-12-13T18:47:03.028700Z

oh, of course, i see now

2018-12-13T18:47:21.029100Z

you are talking about cljs compiler state (which is needed for each new compilation job), that is related to self-hosted REPL implementation, something like that must be implemented

2018-12-13T18:48:08.030400Z

e.g. I want to say (in-ns ...) and that means, I’m mutating compiler state for next compilation job

2018-12-13T18:48:32.031200Z

if I don’t have in-ns available, I would need to specify all symbols with fully qualified names

2018-12-13T18:49:16.031900Z

SO basically Hyperfiddle itself has to be self-hosted and compiled in browser, and then dirac would plug into the same compiler process used to bootstrap hyperfiddle – now have I understood?

2018-12-13T18:51:38.033300Z

what do you now compile with self-hosted compiler?

2018-12-13T18:51:43.033500Z

in hyperfiddle

2018-12-13T18:51:57.033900Z

I assume, you use it for user’s code stored in database

2018-12-13T18:52:16.034500Z

but hyperfiddle “engine” itself is compiled as usual

2018-12-13T18:53:02.035400Z

That's correct today, but it is problematic for reasons unrelated to dirac, i think we are going to bootstrap the whole thing. (We have a "prod mode" that is not interactive so we can bake stuff as usual, eventually do advanced mode etc)

2018-12-13T18:54:50.036900Z

ok, depends what you want your REPL users to be able to do, if you want them being able to go into existing namespace and see “what’s there”, then you need your compiler state to be aware of that namespace, in other words, all forms of that namespace must be already compiled at least once using that compiler state

2018-12-13T18:55:18.037500Z

yeah

2018-12-13T18:55:42.038Z

if this was not possible, user would have to read that file in the REPL again

2018-12-13T18:56:00.038500Z

right

2018-12-13T18:56:28.039100Z

and the question is how this would be implemented in pure-browser env,

2018-12-13T18:57:00.039600Z

e.g. we could have some REPL helpers to do that by specifying URL or something like that

2018-12-13T18:57:17.040300Z

so better would be to have it available “automatically”

2018-12-13T18:57:20.040400Z

Like how Klipse downloads cljc files by url

2018-12-13T18:57:49.040900Z

Sorry if my questions are dumb, im still learning about this

2018-12-13T18:58:35.041700Z

no, I also don’t have deep understanding, I forgot most of it when I finished initial dirac impl

2018-12-13T18:58:43.042Z

lol.

2018-12-13T18:58:55.042400Z

“As you probably know traditionally you had to make effort to keep your REPL environment in-sync with your runtime environment being evolved by hot-reloading.”

2018-12-13T18:59:16.042800Z

that’s the problem I’m talking about,

2018-12-13T19:03:01.045200Z

it all boils down to use one single compiler state(cache) for initial compilation and all subsequent evaluations on top of that (this is what figwheel does), otherwise you need to understand how internals work to understand why you are not seeing what you are expected to see

2018-12-13T19:03:25.045500Z

and how to fix that by using load-file or something like that

2018-12-13T19:04:00.045800Z

Yeah ok i understand

2018-12-13T19:04:16.046400Z

Thanks for all of this and for taking the time. We are not that close to implementing this, but eventually

2018-12-13T19:04:52.046800Z

ok, think about it, I’m willing to implement a proof of work for this, if you decided to move ahead

2018-12-13T19:05:01.047Z

I mean proof of concept

2018-12-13T19:07:03.047700Z

Okay, definitely, i have a lot of homework to do first and we have some competing priorities but in the medium term this seems really valuable and interesting

👍 1