Fork me on GitHub
#clojure
<
2018-05-24
>
pesterhazy10:05:43

@xiongtx often the best is not to AOT at all

pesterhazy10:05:03

avoids a whole class of issues

pesterhazy10:05:15

I like to just java -cp my-uberjar.jar clojure.main -e "(require 'my.core)" -e "(my.core/main)"

dominicm10:05:24

Or even java -cp my-uberjar.jar clojure.main -m my.core

pesterhazy10:05:35

of course you may have some specific reasons for AOT'ing but if it's just about running an uberjar, this will work

pesterhazy10:05:57

@dominicm, ah I didn't know about that

👍 4
danielstockton10:05:22

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?

danielstockton10:05:24

I thought about just launching a future, but wondered if there is a more robust method

pesterhazy10:05:18

@danielstockton you could use a java.util.concurrent BlockingQueue

pesterhazy10:05:31

one one of the other queues provided by that package

👍 4
miro13:05:17

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?

Alex Miller (Clojure team)14:05:37

re safe: depends on where the string is coming from (if a user, it’s not, but see clojure.edn/read-string for better)

Alex Miller (Clojure team)14:05:50

re threading: no worries

Alex Miller (Clojure team)14:05:11

re perf: reading and compilation. no disk i/o, it will be in memory. no serialization.

Alex Miller (Clojure team)14:05:28

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.

miro14:05:46

@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?

Alex Miller (Clojure team)14:05:20

mo’ code, mo’ time

👍 12
danielglauser15:05:03

How long have you been waiting to say that?

dpsutton16:05:30

can you partial a defmulti?

dpsutton16:05:32

the answer is yes. cool

alexisvincent17:05:32

Has anyone had luck using deps.edn to pull in private git repos with lein

sonnyto18:05:55

is there away to access the local bindings of a closure? I posted my question here https://groups.google.com/forum/#!topic/clojure/iQVBiYcSvmk

noisesmith18:05:50

there's hacks to access it but nothing officially supported or likely to work across clojure versions

noisesmith18:05:59

so effectively no

sonnyto18:05:05

@noisesmith thanks. disappointing.... do you have any ideas on how I can do it?

noisesmith18:05:08

for debugging there's libraries that alter the clojure compiler to make that accessible while stepping code

roklenarcic18:05:32

what are some cool libs you guys use for tests beyond bog standard clojure.test

Drew Verlee18:05:54

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

Drew Verlee18:05:40

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

roklenarcic19:05:51

thanks, I'll look into it

seancorfield19:05:44

@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)))

seancorfield19:05:38

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.

Drew Verlee20:05:49

@U04V70XH6 Just looked at Expectations. Thats awesome, this feels like what i should default to using.

seancorfield20:05:56

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".

seancorfield20:05:47

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.

seancorfield20:05:40

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.

sonnyto18:05:05

@noisesmith doyou think I can use dynamic binding to hack around this?

noisesmith18:05:18

you could use a global dynamic var instead of a local, but that has its own drawbacks

noisesmith18:05:04

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

Shantanu Kumar03:05:40

@sonnyto Dime https://github.com/kumarshantanu/dime has such an implementation called dime.core/definj in case that helps to play with the idea.

👍 4
noisesmith18:05:24

by implementing IFn the record can be called like a function

noisesmith18:05:39

and it already acts like a map where you can see the keys in it

sonnyto18:05:42

not a bad idea

noisesmith18:05:15

of course that means instead of using a let binding it would use its own key, but that's simple enough

sonnyto18:05:40

thanks. i'm going to experiment with that

Drew Verlee20:05:03

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

dominicm20:05:33

Under what conditions is a DynamicClassLoader created?

Drew Verlee20:05:53

i did a quick search and didn’t find anything. is there something special about .impl?

schmee20:05:47

nope, just a convention

sova-soars-the-sora21:05:46

I'm trying to do boolean logic on sets. For example,

(and #{7 3} (or #{2 3} #{3 5 7 99}))

sova-soars-the-sora21:05:52

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.

noisesmith21:05:01

is and union and or intersection?

noisesmith21:05:17

and and or just check truthy / falsey

noisesmith21:05:49

you might want clojure.set/union and clojure.set/inersection

sova-soars-the-sora21:05:51

Oh I see. Well, how do I evaluate for overlap?

noisesmith21:05:56

I might have swapped and and or there

sova-soars-the-sora21:05:06

Hey, thanks, that's exactly what I was looking for

sova-soars-the-sora21:05:22

you are correct, union = OR, intersection = AND

sova-soars-the-sora21:05:48

Awesome. Map magic makes what I thought would be a quick algorithm even quicker. wazoo.

arohner22:05:28

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

noisesmith22:05:48

no idea but it smells like the kind of thing hiredman or ghadi would blog about

noisesmith00:05:23

oh that does look like it - similar to plumatic's plumbing too

joaohgomes17:05:38

we’ve been using mount and very happy with it… https://github.com/tolitius/mount