Fork me on GitHub
#clojure
<
2015-06-23
>
lucasbradstreet02:06:18

Anyone have an idea how to include dependencies for lein javac? I’m trying to write a sample Onyx input plugin in java to test out our protocols and can’t figure out how to sensibly get the onyx dep on the classpath

lucasbradstreet02:06:09

Oh, maybe it’s just because I’m not gen-class'ing

bmay03:06:54

any recommendations for a real-time graph on a web application?

bmay03:06:29

i'm thinking clojure -> clojurescript (via aleph) -> javascript (d3.js)

niwinz06:06:26

@bmay Do you know about https://github.com/funcool/catacumba (a little bit of spam :P)

pesterhazy06:06:06

ghadi: I have, though not all the way to millions of rows

danielcompton06:06:29

@niwinz: you might want to change the tag line from "clojure build on" to "Clojure built on"

agile_geek06:06:33

@ghadi: not sure but I think @otfrom may have used Spark with Clojure (using Sparkling I think - https://github.com/gorillalabs/sparkling )

kachayev06:06:10

@podviaznikov: cool! will be really nice to hear any kind of feedback from early adopters!

escherize07:06:26

Whats a good way to make a function that takes some string and returns a pseudo-random, recognizable thumbnail? Basically like this: http://avatar.3sd.me/ but with deterministic results

escherize07:06:06

I found a java library maybe I'll wrap it

cfleming09:06:37

@niwinz: Catacumba looks really nice - great doc too.

sveri10:06:45

@escherize: again, very cool, I just created my one

calum13:06:20

is it bad practice to aot everything when building uberjars? Should I, in general, only AOT the app itself?

stuartsierra14:06:58

@calum Doesn't really matter. AOT-compilation is transitive, so anything your app depends on will be compiled along with it.

calum14:06:00

@stuartsierra: oh ok, it's just I ran into some namespace conflicts and not AOT'ing everything fixed it. I was told AOT 'can cause lots of problems', so I was wondering why it's on by default.

teslanick14:06:30

@escherize: I think I may have used that piece as a starting point.

stuartsierra14:06:41

AOT tends to cause problems with interactive development, e.g. reloading AOT-compiled sources at the REPL.

calum14:06:20

This issue was with building uberjars, normal compilation was fine

tcrayford14:06:14

a benefit of AOTing everything is that your app doesn't have to compile when it's booting in production (which makes restarting faster)

calum14:06:05

ah ok, I'm still very new to clojure and had never heard of AOT compilation so I'm just trying to get my head around the pros and cons simple_smile

stuartsierra14:06:20

AOT compilation definitely has issues. Some libraries don't work at all if you AOT compiled them. I believesome of these issues have been fixed in clojure 1.7

tcrayford14:06:09

CLJ-1604 made my app not compile (one of the deps broke). Fixed now though simple_smile

calum14:06:45

ok so I guess I just need to be vigilant about that

tcrayford14:06:53

a thing I'd recommend is trying to boot your uberjar during your CI process. It'll catch anything like that

Busy escaping the comfort zone14:06:27

I separate AOT using lein profiles, that way I can use clojure.tools.namespace.repl in dev env and compile while releasing the jars

niwinz14:06:08

I personally prefer AOT only the entry point namespace. This allows avoid all the AOT related problems. My two cents.

akiva14:06:31

I only AOT when using an uberjar.

Alex Miller (Clojure team)14:06:46

stuartsierra: there has been a change (CLJ-979) in classloading wrt checking the dynamicclassloader class cache - this "fixes" some scenarios with repl reloading and AOT by preferring the more recently redefined deftype. However these changes also negatively affect some other issues (CLJ-1741 is one example).

Alex Miller (Clojure team)14:06:21

However, I think the "solution" there is really to go back to address things like CLJ-322 (transitive compilation) and also reconsider whether \compile-path should be on the classpath (I now firmly believe it should not be, despite other instruction to do so)

Alex Miller (Clojure team)14:06:43

that is, calling "compile" should produce outputs somewhere, but you should not further consume those outputs while compiling. Rather, compile will have the same side effects as load on your runtime environment (causing classes to be loaded etc)

stuartsierra14:06:10

@alexmiller: interesting idea. Sounds like it would be worth trying at least.

Alex Miller (Clojure team)14:06:34

I have tried it, and it works pretty well. hard to be exhaustive about anything of course.

Alex Miller (Clojure team)14:06:38

I went back and read some of the irc logs from Rich, etc back when this stuff went in and I do not think the reasoning behind having compile-path on the classpath holds up in retrospect. We have better solutions to the dynamic classloading issues now than when that decision was made. The problem in CLJ-1741 is really hard to solve with that in play.

Alex Miller (Clojure team)14:06:18

(some day I will reclaim all the space in my brain reserved for memorizing these jira ticket numbers and will do something useful with it)

stig15:06:42

@alexmiller: thanks for Clojure Applied. I’m really enjoying it!

Alex Miller (Clojure team)15:06:53

you're welcome! hopefully the in-print version is not more than a couple months off.

stig15:06:47

that’d be nice, but the PDF /epub ones are very readable on a MB Retina simple_smile plus I can copy/paste from the PDF, which is a plus simple_smile

stig15:06:03

i tried following along on the “go shopping” example but got stuck — saying that I see you’ve fixed some issues I reported around that in B4, so I should try again...

kardan15:06:08

Anyone got experience custom tags in Selmer? I’m trying to feed a template variable into a new custom tag {% new-tag var %}. I made sure the var carry the value by {{ var}} in the template and also done (var :var {var} {{var}} ) inside the {% %}. Am I missing something obvious?

isaac16:06:36

common lisp and emacs lisp run above code correctly, but clojure throw stackoverflow exception

akiva16:06:03

Do you really need a macro for that in Clojure?

bhagany16:06:56

there's no tail recursion in clojure.

akiva16:06:18

Also that.

Busy escaping the comfort zone16:06:19

for small n it should work

Busy escaping the comfort zone16:06:43

but in this case its related to the macro

isaac16:06:10

it doesn’t matter with n

isaac16:06:27

it doesn’t matter with n

Busy escaping the comfort zone16:06:40

I think that somehow the fact there your trying to use the macro within its own definition causes it to blow up

Busy escaping the comfort zone16:06:53

not sure that clojure supports recursive macros

Busy escaping the comfort zone16:06:09

so its trying to expand indefinitely?

isaac16:06:23

I watched this code, so, write above test

akiva16:06:37

Macros can call themselves, clearly, but even in regular functions loop/recur is preferred over directly calling the function.

isaac16:06:01

(walk/macroexpand-all '(sum-1->n 10))

Busy escaping the comfort zone16:06:48

akiva correct but the JVM can support non tail recursion up to the JVM stack limit

isaac16:06:51

will throw stackoverflow exception

isaac16:06:52

will throw stackoverflow exception

akiva16:06:39

@narkisr: True but then you end up with situations like this. Heh.

Busy escaping the comfort zone16:06:33

akiva correct usually its not safe to do so

isaac16:06:49

How macro expand in common lisp

akiva16:06:53

I still say this should be a function rather than a macro and the loop should be handled with reduce where you can produce a range with n and dec.

isaac16:06:37

why common lisp(emacs lisp) do not throw exception?

Busy escaping the comfort zone16:06:21

I guess they have a smarter macro expansion code

Busy escaping the comfort zone16:06:54

is there a strong use case for such macros?

isaac16:06:37

I just written it for test

Busy escaping the comfort zone16:06:19

Nice finding, its cool what you can learn from just reading the source simple_smile

escherize16:06:51

isn't sum-1-to-n #(/ (* % (dec %)) 2)

gary17:06:14

@voxdolo: I'm also looking at Clojure Stripe libraries, I'm working on an example project (haven't pushed code up to github yet though) http://github.com/gdeer81/stripeapp using stripe-clj. sorry my example repo is bare because I got called on to do a real app using stripe so I'll copy,paste,munge the code as I go.

gary17:06:27

before I hook up all of the backend stuff that will actually make them money, the business users always want to make sure that the front end looks really good and is reactive and web 2.0 and buzzwords etc.

voxdolo17:06:54

@gary: cheers, I believe I stumbled across it yesterday whilst searching github. Didn't have a look then, will now simple_smile

cpmcdaniel17:06:53

is it generally better to use (make-hierarchy) or add parent-child relationships to the global hierarchy? How would I make this decision?

voxdolo18:06:57

@gary: oh, hah! just looked and caught what you meant by it being bare 😄

stuartsierra19:06:42

@cpmcdaniel: Doesn't matter much. Hierarchies are very rarely used at all. The global hierarchy implicitly includes the Java class inheritance relationships.

arohner19:06:41

@gary: I tend to avoid all libraries that are just wrappers on clj-http

arohner19:06:18

@gary rarely worth the trouble

gary19:06:05

@arohner but in this case it's worth it?

arohner19:06:37

@gary last time I used stripe, I ripped out whichever wrapper library it was, and just used clj-http directly

arohner19:06:43

that was a while ago though

arohner19:06:01

but I have a long history of removing http wrapper libraries 😉

arohner19:06:11

github, twitter, google. doesn’t matter

arohner19:06:29

the author always forgets to include some parameter you need, and then you have to use both, or rip them out

gary20:06:30

@arohner: or submit a patch lol

sveri21:06:15

this reminds me of a java client for the docker API that I was evaluating and then for fun, I implemented some of the stuff in clojure, thinking, uhm, there is no need for a wrapper fo any sort, just use clj-http for each call and you're done

mohan21:06:27

How do I run this code in lein without exiting from the jvm?

(ns hello-world.async-test
  (:gen-class))
(require '[clojure.core.async :as async :refer :all])
(require '[clojure.repl])

(defn -main [& args]
  (doseq [i (range 10)]
  (go (while true (let [random (rand-int 10)]
                  (println "Random ::" random))))
  ))

I want to use lein trampoline run command and watch JVM using jvisualvm

andrew21:06:41

(I submitted something and then incorporated 7 or so ideas from other submissions.)

arohner21:06:11

@mohan: go returns a chan containing the result of the loop, when it exits. take from that, something like

arohner21:06:25

(let [result (go …)] (a/<!! result))

malabarba22:06:07

Is there such a thing as a lazy map in Clojure? As in, a map where the value is only calculated when the key is accessed.

akiva22:06:24

I could be wrong but you can probably assign as a key’s value a lazy sequence.

akiva22:06:39

Now that I’ve typed that, my confidence has diminished greatly.

lboliveira22:06:12

Hi, The at-at library https://github.com/overtone/at-at seems abandoned. Which function scheduler do you recommend?

Busy escaping the comfort zone22:06:13

Your welcome, it rather small code wise and optionally uses channels, the joda times integration is nice also

malabarba22:06:22

@akiva worth a try, but I'm skeptical to be honest

akiva22:06:47

As am I. Try it and report back with your findings.

malabarba22:06:55

Maybe if manually extend a hashmap

arrdem22:06:13

@malabarba: you can totally have lazy seqs and other things in a hash map as values

arrdem22:06:32

@malabarba: there is no structure I know of in which the mapping itself is lazily computed.

arrdem22:06:42

although I suppose you could invent such a thing for some inputs...

malabarba22:06:09

@akiva alas, I'm actually in bed right now. Testing will be done tomorrow :-)

arrdem22:06:23

something something equivalence of maps and sets to functions grumble types

malabarba22:06:17

@arrdem i mean, the idea is that all the keys would be known ahead of time, like a regular map

malabarba22:06:35

But the values would be calculated the first time they are accessed

malabarba22:06:59

It's certainly possible in theory.

Busy escaping the comfort zone22:06:12

Why not have a map that hold partial applied functions?

malabarba22:06:11

Just For the syntax.

malabarba22:06:47

I'd like to be able to do (:some-key the-map) to get the value. Whereas, if the values are partially applied functions, I'll have to do ((:some-key the-map))

malabarba22:06:14

It's not a huge deal

Busy escaping the comfort zone22:06:56

You could implement the associative protocol (I don't recall its name) and extend so on get it will call the function

malabarba22:06:27

That sounds promising

Busy escaping the comfort zone22:06:11

Most of the implementation will just delegate, only the get stuff will call the function

malabarba22:06:42

Yeah, I think that's it. Reading into it now, and will try tomorrow.

Alex Miller (Clojure team)23:06:36

@arrdem and @malabarba Datomic entity maps are lazy like you're describing

Alex Miller (Clojure team)23:06:36

Not that that is useful in solving your own problem of course :)

malabarba23:06:21

Good to know anyway :)

Busy escaping the comfort zone23:06:14

I'm on the lookout for a secure over the WAN messaging protocol/implementation (for Clojure of course), iv already considered Zeromq (lacks security for the JVM) MQTT (requires a server which id rather to avoid) or SQS (tying me to Amazon)