This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-05
Channels
- # adventofcode (8)
- # aleph (42)
- # announcements (4)
- # beginners (157)
- # boot (4)
- # calva (1)
- # cider (6)
- # cljdoc (8)
- # cljs-dev (1)
- # cljsrn (3)
- # clojure (50)
- # clojure-europe (9)
- # clojure-italy (16)
- # clojure-nl (2)
- # clojure-russia (6)
- # clojure-spec (59)
- # clojure-uk (25)
- # clojurescript (20)
- # core-async (41)
- # cursive (30)
- # data-science (9)
- # datomic (20)
- # fulcro (28)
- # kaocha (9)
- # nrepl (1)
- # off-topic (3)
- # om (3)
- # pathom (10)
- # re-frame (8)
- # reagent (2)
- # ring-swagger (38)
- # rum (9)
- # shadow-cljs (209)
- # spacemacs (7)
- # tools-deps (11)
- # vim (6)
- # yada (2)
What strategies, if any, do people use to decouple sub systems within an application. For example decoupling a database access layer. I've been using protocols to group common functions and passing the instances down into subsystems using stuartsierra/component
. I can also see people using weavejester/integrant
and mapping single functions. I can also see directly coupling/referencing subsystems and segregating them in separate namespaces.
Protocols are a must for (clean) testability IMO. Also nice being able to change libraries in a future (e.g. Bidi -> ataraxy) At work we use separate directories for protocols and impls. At first I agreed but I came to realise this creates an awkward indirection. 90% of times there's just 1 relevant implementation for a protocol. So one's IDE's jump-to-def will take you to the protocol ns, not the impl ns. That's the awkward point, and a good reason to place protocols close to impls bad:
protocols/
foo.clj
...
impls/
foo.clj
...
better:
components/
foo/
protocol.clj
impl.clj
bar/
baz/
...
This becomes evident as the app size scales
I wouln't create proto and impl in the same ns, it forces you to choose different fn names to avoid clashes. Better to have it uniformAs for Component vs Int, Int has "suspend" capabilities which I believe can make the restart process more graceful and/or performant. Haven't tried it though. https://github.com/weavejester/suspendable might work as well for Component I like Component. With https://github.com/stuartsierra/component/pull/62 now it's as lightweight and data-driven as Integrant (or even more so)
Answering to your question... at least 1 protocol (and 1 component) per sub-system. Each subsystem only talks to each other via protos
@U45T93RA6 Thanks for your input. It's great to see how other people solve these problems. We are definitely on the same page with this. When using protocols, I've also grouped up the implementation with the protocol in the same directory. I use cursive so when I jump-to-def to the protocol, I can do another jump-to-def on the protocol name which takes me directly to the implementation. So using that it wouldn't matter if they're in the same directory or not. However, I do prefer them in the same directory.
I have a project where starting a REPL with Java 1.8.0_192 takes 11 seconds and with Java 1.8.0_201 takes 44 seconds. I'm wondering if this is a known issue or something idiosyncratic to my project.
Looks like the Clojure portion ^ is easy to repro with a fresh React Native project; will check in #cljsrn
Hi all, I'm new to Clojure I'm new to Java. 🙂 Can anyone point me to the right direction? I'm trying to serialize an https://github.com/thi-ng/ndarray
How do I apply
a function (defn myfn [& {:keys [a b]}] ...)
to a map m
(`{:a 1 :b 2}`)?
$ clj
Clojure 1.10.0
user=> (def m {:a 1 :b 2})
#'user/m
user=> (defn myfn [{:keys [a b]}] [a b])
#'user/myfn
user=> (myfn m)
[1 2]
it’s a function that’s not in clojure, but in several helper libs:
(defn mapply
"Applies a function f to the argument list formed by concatenating
everything but the last element of args with the last element of
args. This is useful for applying a function that accepts keyword
arguments to a map."
[f & args]
(apply f (apply concat (butlast args) (last args))))
noticed functions like assoc
and contains?
operate on vectors (by position), but dissoc
throws an error. Seems like this should work as a complement to the aforementioned functions - no? Or is this an intentional omission for performance reasons?
removing something from the middle of a vector isn't a simple operation, so it isn't built in
also if you find yourself wanting to do that, you should probably use a different datatype (eg. finger tree)
you have keep-indexed tho (keep-indexed (fn [k v] (when (not= k 0) v)) [:a :b :c :d])
see also the inability to check something sequential for a specific value (what people often naively think contains? would do) - it's possible, but there's no simple built in because doing so often indicates you should be using a different datatype
for what it’s worth I was building a custom version of assoc
that wouldn’t add nil values in order to reduce gc overhead (relative to pruning). it works as I expected, but in doing so I stumbled upon the issue. edit: note that I’m not even using vectors, but I was attempting to achieve feature parity… so it was really just a question.
@noisesmith wouldn't something like some
count as a built in for that?
@lockdown- yes we have functions that do linear scans of collections, but nothing that specifically checks membership of a given value
Hi, does anyone have recommendations on how to get the length of a video in clojure... Sadly I must use windows.
i was using ffmpeg on a mac, and calling it with processBuilder, however I'm running into issues getting any output at all while using CMD instead of bash
I tried loading the file as a media object using ffmpeg, but ffmpeg doesn't support MOV files .
@jdkealy you should be able to pipe output between processes via InputStream and OutputStream, if all the executables are present
java does have multimedia libraries, that's the next thing I would look for
even if there was a clojure binding, using the lib via interop is likely a better choice
right! https://gist.github.com/jdkealy/65edec6c28a89f378c27803fb78be6d8 so this calls bash, would you know how to do this in windows ? I know you can call bash via CMD, eg. "CMD" "C/" "bash" but the stream just returns ""
could stuff be going to stderr that's not showing up? I remember from some old C#/.NET work there were some Process
options for redirecting stderr to stdout, not sure if that'd be exposed via Java classes though
this is what I was thinking of https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.redirectstandarderror?view=netframework-4.7.2
Process allows accessing stderr