This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-20
Channels
- # admin-announcements (2)
- # beginners (38)
- # boot (12)
- # business (2)
- # cbus (2)
- # cider (8)
- # cljs-dev (32)
- # clojure (154)
- # clojure-brasil (43)
- # clojure-czech (3)
- # clojure-dev (5)
- # clojure-germany (1)
- # clojure-japan (2)
- # clojure-nl (2)
- # clojure-poland (9)
- # clojure-russia (29)
- # clojure-sg (12)
- # clojurescript (147)
- # clojurex (22)
- # community-development (2)
- # cursive (8)
- # events (3)
- # ldnclj (30)
- # ldnproclodo (1)
- # leiningen (1)
- # luminus (34)
- # off-topic (6)
- # om (255)
- # re-frame (1)
- # reagent (22)
- # rum (2)
- # yada (1)
Could somebody give me any pointers to when / why classLoaders become a concern? I’m not familiar with them, but I’m trying to do something like this: https://github.com/uswitch/lambada
and I’m getting errors which seem to indicate that I need to do something like what he does in https://github.com/uswitch/lambada/blob/master/src-java/uswitch/lambada/ClojureLambdaBase.java but I don’t understand what’s going on there
@jeremyraines: What are the errors you’re getting?
What that code is doing is setting the thread context classloader to a specified loader. This is (generally) what Clojure will use to load its classes
java.lang.NoClassDefFoundError
thanks. When do you need to do that? Always with java packages? (I’ve mainly only worked with cljs so far)
But you’ll probably need to do that from some Java code, before Clojure itself is loaded.
actually I’m not sure how lambda starts it up either
So lambda, at some point, will call into your code, and at that point you’ll probably want to load some Clojure code and execute it.
You’ll need to find what that point is, I guess it instantiates an instance of a class, or calls an interface you provide?
as far as I can tell it is getting into the Clojure code
just parts of the java deps can’t find their own deps
that might be the issue. there’s this jar with the alexa-skills-kit library that I had to install via lein-localrepo because it’s not on maven
It might be a classloader issue, but it could also just be that the deps aren’t in the right place, or something similar
uberjar
how do you look in an uberjar?
Depends on your platform. It’s just a zip, so you can open it with a zip tool. If you have easy access to a unixy command like (like OSX), jar tvf your-uberjar.jar
should show you the contents.
so, I’m not totally sure which class I’m looking for, but the first part of the error message referenced org/apache/commons/io/IOUtils
which I do not see in the jar
and it is coming from a classLoader: java.net.URLClassLoader.findClass(URLClassLoader.java:381)
I don’t think that classloaders are your problem, I think your build isn’t adding all the deps to the uberjar
did something in the alexa-skills-kit jar not fully specify it’s deps? or how would that happen
so I haven’t done it, but that jar is in their java examples that they hand out for you to deploy to lambda
thanks for your help, though. I’m not really even sure of a good next question to ask.
@jeremyraines: It seems you need to add commons-io
to your lein dependencies list so it'll fetch it for you.
i’ll try that
now it can’t find com/fasterxml/jackson/databind/ObjectMapper
thanks
@kumarshantanu: Yep got it all working, thank you
@cfleming, doesn't it have to be marked with :dynamic?
(:dynamic (meta Compiler/LOADER))
@sarcilav: I’ll take a look.
Is http://clojars.org down?
@malch I cannot access http://clojars.org, too
@nowprovision: No, the issue is that you can’t use it with binding since that requires a symbol referring to a var. with-bindings works.
is there anything comparable in functionality to korma that doesn't internally use var resolution features everywhere? i.e. I dont want global singleton entity definitions
even though I can late bind the conn/pool to the entity during component start etc.. it still feels hacky, defining relations in a non global way leads one down a macro-expand rabbit hole eventually revealing code like this https://github.com/korma/Korma/blob/master/src/korma/core.clj#L589
sql honey looks interesting but it looks like it doesn't handle deserializing joins, only query building
I don't think there's anything like korma, at least in active development. But while I understand not wanting to have a global db connection, what's wrong about global entity definitions? (genuine question)
I don't think there's any yet - https://github.com/ptaoussanis/sente/issues/80
jaen, fair question, I guess Im just uncomfortable with them, since we're not binding the default-connection I can't see a reason for them to be global, also Im a little paranoia that im introducing state somehow, in my very simple domain model though I've decided Im just going forgo the relation, that way I can use create-entity it seems
I still tweaking it but I should able to model the join explicitly and woohoo (pointless win..) no defentity..
no defs, before I would assoc to the component a defentity bound to conn
(assoc :webhooks (database webhooks-entity conn))
true, hmmm.. i might need to rethink this
And connection is used only when executing the query - https://github.com/korma/Korma/blob/master/src/korma/db.clj#L307-L311
yeah agreed... I guess defentity aren't too bad.. you're right
unrolling
anybody uses prismatic/schema 1.0 here? I'm not sure how I'm supposed to replace s/both (which is deprecated) with s/conditional...
what is the perf of persistent vector random access?
I'm expecting it to be 2-3 times slower than first element access of a list
(get v 10000)
vs (first s)
I ran benchmarks on lighttable
both take the same time
how is it possible?
That doesn't sound like a very good benchmarking environment to me.
Tim Crayford has a useful talk on benchmarking pitfalls: https://www.youtube.com/watch?v=0tUrbf6Uzu8
The time complexity should be O log base 32 for a vector lookup and I agree with your expectation that it should be a bit slower than first on a list as it's going through 2-3 levels of tree
@asolovyov you'll get a instance that might
instatiant okay, but when used against s/check,validate throws a npe, in some scenarios you do have to make changes between s/both and s/conditional
in many cases if you can just use s/pred with a predicate that has an 'and' e.g. ▾ src-cljs/ | 6 (s/pred #(and (string? %) (> (count (strings/trim %)) 0)))
if you do as conditional iirc it's (s/conditional s/Str (s/pred #(> (count (strings/trim %)) 0)))
@nowprovision: but s/pred doesn't give nice errors...
true, i ended up doing something hack with that as still a step from lisp list to a human friendly (def not-blank (with-meta (s/pred #(and (string? %) (> (count (strings/trim %)) 0))) {:constraint-msg "must not be blank"}))
Im rolling back a lot of decisions frequently at the moment, so possible that I won't feel the same tomorrow, Im just experimenting atm and recognized the same s/both deprecated to s/conditional issue you came across
I think with custom predicates it will be quite difficult to go from a quoted list to a friendly meaning automagically, but if you come up with a way I'd love to see it
When I start an REPL an go into the namespace with (in-ns) I get the error „unable to resolve symbol“ What I’m doing wrong?
@nowprovision: haha, sure
@danielgroosee have you quoted the symbol e.g. (in-ns 'clojure.string)
think (could easily be wrong) you may need to require it too if not already loaded (require 'acme.whatever) (in-ns 'acme.whatever)
I have a namespace but when I go into it with (in-ns ’project.core) the defn functions are not available. As if it creates a new namespace
and you've required it first?
No just trying
Now I get a file not found Exception
what exactly are you type at the repl, and what is the physical file path of the component you are loading (can be important with dash to underscore rules etc..)
component -> namespace
I have to get more into the project. There is some error, I can’t understand now. I will contact the owner. Thanks for your help
@oli helps to see one record. would be best if you could post a complete record as clojure data as well as the schema definition
@christianromney: i think i figured it out
i'm using the schema as a template to populate data into and adding (s/maybe ...) changes how that's happening which in turn breaks things...
@oli cool glad you got it working
@christianromney: rubber ducking... 😛
not sure i'm not overcomplicating this - is there an approved way to insert values into a schema? i'm using a zipper to traverse the schema and inject values based on the schema keywords
Anyone that wants to chime in? https://www.quora.com/Programming-Languages/Clojure-style-domain-modelling-in-Java-or-other-mainstream-languages
Rich would obviously be the best person to chime in on whether that is an accurate representation of his views. Not sure if it’s worth @ ing him for this . The viewpoint attributed to Rich certainly makes a lot of sense to me… as does most of what Rich says. But I’m sure there are some things that seem to make sense to me that Rich would not agree with.
I guess it’s more interesting to chime in on the viewpoint described itself anyway, rather than meta-discussions of whose views it does or does not represent.
Clearly many Person classes have been written and a growing number of new ones are written every day.
Anyone know the rationale for transit-java (and thus clj) returning its own URI type (which datomic does not recognize as a URI in transactions) instead of java.net.URI?
@borkdude: thanks for sharing that link. a really good and concise explanation of one part of the clojure philosophy IMO. or of principles of simplicity that go way beyond clojure itself
Thing is, it could easily be confused with “pre-OO” or procedural thinking. But I think it’s really “post-OO” or functional thinking. The simplicity beyond complexity, in the words of some probably misattributed quote from someone. (of course FP is really only “post-OO” in the chronology of mainstream adoption)
one could argue 'procedural' means something different than a functional language with higher order functions
I'm not sure though why domain modelling is wrong, I see DDD being usable with a functional langauge as well. Unless that's not what is meant by domain modelling?
I don't think anyone said domain modelling is wrong. It's just done differently. I don't agree with the first answer on my question on Quora.
Anyone have experience with Yesql interacting with postgres? I’m having trouble trying to pass a nil parameter.
favila: transit-java and -clj just commit to a pretty minimal interface for uris (rather than Java's java.net.URI which is much heavier and has some pretty weird semantics for equals and hashcode)
favila: because uri is an extension type though, you can supply your own read handler for the uri type to construct java.net.URI instead
@alexmiller: I know, was just surprised and didn't understand the rationale. Had a datomic transaction blow up with a transit-supplied uri, was a head-scratcher until I realized it was not producing a java.net.URI type.