This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-12
Channels
- # bangalore-clj (4)
- # beginners (77)
- # boot (71)
- # cider (10)
- # clara (1)
- # cljs-dev (52)
- # cljsjs (28)
- # cljsrn (1)
- # clojure (390)
- # clojure-dev (5)
- # clojure-india (1)
- # clojure-italy (5)
- # clojure-nl (24)
- # clojure-poland (4)
- # clojure-russia (123)
- # clojure-spec (71)
- # clojure-taiwan (2)
- # clojure-uk (8)
- # clojurescript (236)
- # core-matrix (6)
- # cursive (19)
- # datomic (16)
- # defnpodcast (2)
- # editors (1)
- # emacs (36)
- # garden (2)
- # hoplon (5)
- # jobs (1)
- # jobs-discuss (10)
- # juxt (47)
- # luminus (4)
- # lumo (6)
- # off-topic (207)
- # om (1)
- # onyx (20)
- # pedestal (40)
- # perun (2)
- # re-frame (8)
- # reagent (48)
- # ring (2)
- # ring-swagger (2)
- # specter (13)
- # unrepl (89)
- # vim (6)
as most operations will be async
and the normal model really relies on sync
and blocking
and the JS side is not pure RPC because of the async nature: when the RPC returns processing may still be going on.
this is the JS side of the node REPL .. it is connected to a websocket that gets messages from the server (CLJ)
but the client can decide how to handle that message, ie. the browser impl is different
To summarize: there’s no generic way to write a repl in selfhosted CLJS because:
1/ there’s no agreed upon *in*
(or equivalent), so no R
2/ there’s no agreed upon eval
(planck has one), so no E
bonus/ bindings conveyance requires hack unless you want dynvars (print-fn ns etc.) to leak from one repl to the other
(for the last point, start lumo
in socket server, open two repls, changing ns in one, change the ns in the other)
I disagree on “anything that works with normal can work self-hosted” because most of a normal CLJS repl is CLJ and uses blocking IO
selfhosted is easier than normal because there’s not two envs to deal with, it’s closer to CLJ (minus sync IO) but needs some gaps to be filled.
selfhosted is also very limited and not very useful for big apps (and not an option for browser targets)
so I really wouldn't write anything server side in pure CLJS not because of self-hosted but because of JS
9 years ago I started working with Clojure because I got badly burnt doing server-side JS 😄
yeah dunno, I don't get how you could write a serious server application in a runtime that was strictly built and optimized for the browser
heck I spent soo much time even trying to get my browser apps performant enough to be acceptable and that is just one user at a time.
@cgrand, well node.js has streams, which do resemble *in*
and *out*
but bindings are no good if they don't survive across events
well, only if you can print synchronously, right?
but yeah typically you can print synchronously, even in browsers
that’s why in evented-reader I introduce a Stream abstraction to create *in*
. Then the author of the root repl may provide an impl
(nrepl-bridge/repl & nrepl-args)
recreates a pair of stdin/stdout to a clojure.main/repl on top of nrepl
; the following example upgrades the running repl to mirror the replized nrepl :-)
(mirror (repl :port 62005))
So now we can work either with a socket repl or a nrepl (as long as the client is written in Java…)
is there an nRepl
protocol spec somewhere?
when an op has been handled, a message must be sent over that transport with a :status
including "done"
in the result
if a message has an :id
it should come back with an :id
(it's possible that this is done by merging into the incoming map, but I'm not certain)
uhm, seems quite easy to replicate indeed
@cgrand The middleware is really just an implementation detail of tools.nrepl. I'm "out there" and I have 4 middlewares in my profile.
Middlewares are based on dependency ordering using a topological sort. It's not super easy, I'll admit. But it isn't crazy (in fact, it's already done!)
https://github.com/stuartsierra/dependency makes it easier
@cgrand you're extremely productive. I wanted to ask how you approach problems & get stuff done.
Seriously I don't consider myself as extremely productive. I'm productive by bursts when ideas have been on the back burner (or hammock) long enough