This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-18
Channels
- # aws (12)
- # beginners (489)
- # calva (32)
- # cider (117)
- # clj-kondo (4)
- # cljdoc (9)
- # cljs-dev (3)
- # clojure (56)
- # clojure-brasil (1)
- # clojure-europe (10)
- # clojure-italy (44)
- # clojure-nl (9)
- # clojure-russia (1)
- # clojure-sweden (6)
- # clojure-uk (64)
- # clojurescript (6)
- # cursive (6)
- # datascript (4)
- # datomic (6)
- # emacs (3)
- # fulcro (15)
- # graalvm (11)
- # jackdaw (7)
- # jobs (8)
- # jobs-discuss (29)
- # jvm (2)
- # leiningen (5)
- # luminus (10)
- # off-topic (23)
- # pathom (21)
- # planck (11)
- # quil (6)
- # re-frame (11)
- # reagent (17)
- # reitit (8)
- # rewrite-clj (6)
- # shadow-cljs (78)
- # slack-help (2)
- # spacemacs (7)
- # specter (4)
- # sql (60)
- # tools-deps (7)
- # xtdb (11)
I am hoping the clojure fam can help me out, there was an article (or maybe github project), that demoed running multiple versions of clojure side by side with classpath isolation, can anyone help me find it!?
@flyboarder it reminds me of immutant, but i'm guessing you mean something else http://immutant.org/documentation/1.1.4/initialization.html
(and i didn't actually use immutant)
Looking for side-by-side, ie. in the same JVM
Was that boot pods @flyboarder ?
What’s the correct pred
for something like this?
(condp pred thing
map? [:map thing]
vector? [:vector thing]
string? [:string thing]
…)
(Or a better solution that accomplishes the same thing)or
(require '[clojure.spec.alpha :as s])
(s/conform (s/or :map map? :vector vector? :string string?) thing)
Guys, how did you learn to solve problems the functional way? I’m currently in the middle of moving some of my JS codebase to Clojure. Started out by trying to directly rewrite the code, but that didn’t work and I sometimes still struggle to wrap my mind around how to design the flow of the programs. So I’m interested in hearing where you got this from
@henrik use a protocol if you want openness, if you have a constrained set of shapes you want to apply that on, go for cond
as suggested by @alexmiller
@kyselyradek I'd love to hear other's approaches. But For me I got to functional designs a bit "backwards" learning some heuristic rules of software design and being led by them to functional. The rules I use, that got me here, are... 1) minimize and isolate mutation 2) ditto for side effects 3) ditto for state 4) Name what you are doing, not what you're doing it on (what around here I've found out is called point free) 5) A small amount of dense code is slightly better than a large amount of light code 6) write code first for other developers to read, second to do it's job 7) TDD, lots And that's a quick look at how I got here. Also some vids.... https://www.youtube.com/watch?reload=9&v=US8QG9I1XW0 https://www.youtube.com/watch?v=srQt1NAHYC0
Suni, thank you a lot for the answer! I’m looking at the point-free programming now, looks like that was mainly what I was missing. However can you please explain what you meant by > 5) A small amount of dense code is slightly better than a large amount of light code I have a slight idea, but just to make sure
I find highly composed code (which is my fav!) "does more" per line. As a result I feel like 15 lines of "really good clojure" is effectively ~100 lines of "really good java". They're both good code, and most importantly it tends to take about the same amount of time to read or write them. in those situations I tend to prefer the option that produces more "dense" code.
^_^ No problem! Glad I could help.
@kyselyradek Neal Ford has a video on “Functional Thinking” that I found helpful. https://www.youtube.com/watch?v=JeK979aqqqc
Also some posts by Neal Ford: https://www.ibm.com/developerworks/library/j-ft1/index.html
hi, in ring or maybe even in general, what is the difference between :session and :cookies?
@tomaas cookies are literally the HTTP cookies, whereas session doesn't come from HTTP headers, but is something that can be derived (for instance, by looking up a session ID in a database)
And cookies are stored in browser.
session is created in server, but the browser must store something (id of session) so that with following requests the server can query up session data based on that id
Does anyone have any advice on moving defs between namespaces on an existing project? People keep telling me intellij/cursive have cool features and I'd love it if this were one of them. But yeah, do you just go through and check aaaaalllllll the requires? (context, I found a bloated utils file and wanna break it up a fair bit)
is there a neater way to do this (that doesn’t involve swaping an atom 😛)?
(defn find-all
"Recursively walks a tree structure and finds all elements
that match `pred`. Returns a set of results."
[pred tree]
(let [results (atom #{})]
(clojure.walk/postwalk
(fn walker [x]
(when (pred x)
(swap! results conj x))
x)
tree)
@results))
I'm going through tempura
's code and stumbled across this:
(let [;;; Local aliases to avoid var deref
merge-into-default-opts merge-into-default-opts
scoped scoped
search-resids* search-resids*
search-resids*-cached search-resids*-cached
search-resids search-resids]
...)
Can someone please help me understand what the comment means?My guess would be performance optimization. Any time you access a var, the compiler emits a call to <the-var>.deref(), which adds a layer of indirection plus a volatile read. A local binding is just an alias to a value, so it's easier for the JVM to optimize.
hey everyone, in a couple places in my code i’m trying to decouple services by passing functions as arguments as follows:
(defn get-and-do-a-thing [accessor args]
(do-the-thing (accessor args))
not in a way that's enforced at compile time
you can use specs and exercise the accessor, which works if you remember to do so and the spec is correct
I'd only use with-bindings if something else ensured I had the vars available
otherwise binding does all the stuff to get the vars behind the symbols for me
There are very good odds that anything that is a dynamic var is really a function argument hidden behind awkward calling convention
There are places were dynamic scope is useful, but like maybe less then one or two new instances of dynamic scope per code base. So maybe you introduce a single dynamic var, wrap it in some helpers, and use it while forgetting the mechanism that underpins it from the rest of your code that does nothing with dynamic scope
If you are using dynamic scope so often that you have to ask about preferring bindings or with-bindings, you might have a big ball of mud