Fork me on GitHub
#off-topic
<
2020-10-17
>
borkdude11:10:20

What's a good word for the category "socket" vs "stdin/stdout" and another word for the category "edn"/"json"? The latter I would call format. The first one I would call... channel? don't know!

borkdude11:10:03

Use case: I have software communicating either via sockets or stdin/stdout and exchanging messages in edn/json, so I need something like this:

{:??? :socket :format :edn}

orestis12:10:16

Transport?

borkdude12:10:20

I came across this word in the nREPL docs but it seems they're using transport to describe the format rather than the socket mechanism

borkdude12:10:56

I do think that word is more fitting for the mechanism of transport rather than the format of the messages being transported

hiredman12:10:11

Transport is both in nrepl, the serialization mechanism is tied to the communication mechanism

orestis12:10:56

In twisted python, there’s transport (tcp/udp etc) and protocol (http, etc)

borkdude12:10:50

@hiredman Right, I guess you could have a nREPL transport edn+http or something

jcburley13:10:25

“encoding”?

borkdude13:10:17

socket isn't really an encoding I think

borkdude13:10:39

I'll go with transport

jjttjj14:10:45

are there any good hacker-news-esque "startup/programming fusion" slack/discord/chat rooms out there?

lread18:10:07

nothing like doing a little Java programming to make me re-appreciate the pure simplicity of Clojure! simple_smile

😱 12
borkdude20:10:34

Does anyone of you have a case of reify in their code with more than one interface/protocol?

borkdude20:10:16

Nice. Also something non-ui related maybe?

phronmophobic20:10:12

https://github.com/phronmophobic/membrane/blob/09e14e3f152a53f47c257ada592f577f9d0328b7/src/membrane/ui.cljc#L289, it's used with ui code, but the purpose is to be able to memoize functions with potentially infinite lazy sequences as arguments which could be used outside of ui

phronmophobic20:10:15

and another example that hasn't been pushed publicly yet: in cljs

(reify
  IPending
  (-realized? [_]
    (not (identical? @atm obj)))
  IDeref
  (-deref [_]
    (let [val @atm]
      (assert (not (identical? val obj)))
      val)))

borkdude20:10:39

that's a nice example

phronmophobic20:10:22

usage: it's meant to mimic a future. there's probably a better way to write it, but basically, I have some clj code I ported to cljc where I want a future that only gets deref'd once some async process is complete.

(let [obj (js/Object.)
      atm (atom obj)
      p (reify
          IPending
          (-realized? [_]
            (not (identical? @atm obj)))
          IDeref
          (-deref [_]
            (let [val @atm]
              (assert (not (identical? val obj)))
              val)))]
  (async/go
    (let [rendered (<! (-render-elems params elems))
          error? (= :error elems)]
      (when-not error?
        (builder-dispatch :set $current-render [elems params rendered]))
      (reset! atm elems)))
  p)
elsewhere:
(if (realized? p)
  @p
  (ui/label "loading..."))

borkdude20:10:56

Preferably links to public repos.