This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-24
Channels
- # adventofcode (11)
- # architecture (12)
- # beginners (132)
- # boot (19)
- # cider (26)
- # clojure (69)
- # clojure-dusseldorf (4)
- # clojure-gamedev (1)
- # clojure-italy (46)
- # clojure-nl (4)
- # clojure-serbia (1)
- # clojure-switzerland (2)
- # clojure-uk (91)
- # clojurescript (79)
- # css (4)
- # cursive (2)
- # datomic (16)
- # docs (9)
- # duct (20)
- # editors (94)
- # fulcro (15)
- # graphql (2)
- # hoplon (1)
- # instaparse (7)
- # jobs (3)
- # lein-figwheel (3)
- # leiningen (2)
- # lumo (40)
- # mount (35)
- # off-topic (19)
- # reagent (18)
- # reitit (1)
- # shadow-cljs (123)
- # specter (7)
- # sql (5)
- # test-check (4)
- # tools-deps (38)
- # vim (20)
- # yada (9)
@xiongtx often the best is not to AOT at all
avoids a whole class of issues
I like to just java -cp my-uberjar.jar clojure.main -e "(require 'my.core)" -e "(my.core/main)"
of course you may have some specific reasons for AOT'ing but if it's just about running an uberjar, this will work
What's the recommended way to do some asynchronous network io in a ring handler e.g. write to some log without slowing down the response?
I thought about just launching a future, but wondered if there is a more robust method
@danielstockton you could use a java.util.concurrent BlockingQueue
read-string in production : In general, how safe (stability/robustness-wise) is to run eval or read-string in production on regular basis in multithreaded environment? Say multiple threads are reading different strings... In terms of performance, what will be the main hit? Would that be the compilation? Is there any disk i/o? Is there any serialization happening? There is none, right? Also should I expect any significant memory growth over time or anything GC wouldn't handle?
re safe: depends on where the string is coming from (if a user, it’s not, but see clojure.edn/read-string for better)
re threading: no worries
re perf: reading and compilation. no disk i/o, it will be in memory. no serialization.
classes can generally get GC’ed if not in use. there are a couple of obscure bugs related to eval. prob unlikely you’ll hit those, but test to make sure.
@alexmiller thanks! yeah I meant safe in terms of robustness (security risks are clear here I guess). that all sounds good! in terms of compilation overhead - I ran some tests with small snippets of code and was surprised that the hit was quite unsubstantial, just couple of ms here and there... Are you aware of any conditions under which that would change significantly (i.e. orders of magnitude)? Just size of the code?
How long have you been waiting to say that?
Has anyone had luck using deps.edn to pull in private git repos with lein
is there away to access the local bindings of a closure? I posted my question here https://groups.google.com/forum/#!topic/clojure/iQVBiYcSvmk
there's hacks to access it but nothing officially supported or likely to work across clojure versions
so effectively no
@noisesmith thanks. disappointing.... do you have any ideas on how I can do it?
for debugging there's libraries that alter the clojure compiler to make that accessible while stepping code
what are some cool libs you guys use for tests beyond bog standard clojure.test
Clojure test probably gets the market share and has the most integrations with various editors. The only other i know of it Midje. Which i’m not sure is worth breaking convention for
YMMV but i tend to not write as many tests in clojure, so the testing framework seems a bit less important. This approach is also somewhat different then clojure test https://github.com/cognitect-labs/transcriptor
thanks, I'll look into it
@U66G3SGP5 I like (and maintain) Expectations for a more BDD style of test -- that is compatible with clojure.test
and all that tooling.
(defexpect test-name
(expect pos? (compute-something 42))
(expect IllegalArgumentException (blow-up 13)))
Where Expectations shines is that you can expect "more of" an expression with destructuring and predicates and so on. There's an #expectations channel here if you want to dig deeper.
@U04V70XH6 Just looked at Expectations. Thats awesome, this feels like what i should default to using.
I saw a presentation on it, some years back, and switched everything at work from clojure.test
to Expectations
shortly after, except for our WebDriver tests (which were very procedural and "assert-y".
I need to finish the 2.2.0 release but I'm still in the process of rewriting the docs, to make defexpect
the default approach.
And I still need to work on the reporting -- the clojure.test
integrated stuff doesn't have the great error reporting that standalone Expectations
has.
@noisesmith doyou think I can use dynamic binding to hack around this?
you could use a global dynamic var instead of a local, but that has its own drawbacks
or you could use a defrecord explicitly containing the value as a key, then you can access it like you could any value in a map
@sonnyto Dime https://github.com/kumarshantanu/dime has such an implementation called dime.core/definj
in case that helps to play with the idea.
by implementing IFn the record can be called like a function
and it already acts like a map where you can see the keys in it
of course that means instead of using a let binding it would use its own key, but that's simple enough
@sonnyto I have code for this. Have a look at https://github.com/TristeFigure/shuriken#storing-and-reusing-lexical-context
If you want to tell people, external tools, etc.. that a function is some combination of 1. not part of the public functionality 2. not the main goal of the library 3. wont be stable/ subject to change or go away So basically make it not really visible unless you go look at the raw code. Whats the best way to do that? I can make things private, but that seems to have more todo with namespaces, which isn’t really the same as the goals above
@drewverlee put it in a *.impl
namespace, ie https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/channels.clj
i did a quick search and didn’t find anything. is there something special about .impl?
I'm trying to do boolean logic on sets. For example,
(and #{7 3} (or #{2 3} #{3 5 7 99}))
I get #{3 2} as a result for that one. Not exactly what I was expecting. Feel like I'm missing something fundamental about how to evaluate and-or logic in clojure for things like sets.
is and
union and or
intersection?
and
and or
just check truthy / falsey
you might want clojure.set/union
and clojure.set/inersection
Oh I see. Well, how do I evaluate for overlap?
Ah, awesome.
I might have swapped and
and or
there
Hey, thanks, that's exactly what I was looking for
you are correct, union = OR, intersection = AND
Awesome. Map magic makes what I thought would be a quick algorithm even quicker. wazoo.
Does anyone have a link to that article that was about using with-open
and java.io.Closeable
as an alternative to the Component library? Or a list of terms to google for
no idea but it smells like the kind of thing hiredman or ghadi would blog about
Maybe you can check [fun-map](https://github.com/robertluo/fun-map/blob/master/README.md)
oh that does look like it - similar to plumatic's plumbing too
we’ve been using mount and very happy with it… https://github.com/tolitius/mount