#clojure logs

2015-08-21

03:02OlajydHi, TEttinger
03:02OlajydHi, all
03:03TEttingerhey Olajyd
03:03TEttingerhow did the data parsing stuff work out yesterday?
03:03TEttinger*date not data
03:05OlajydHi, TEttinger :)
03:06TEttingerconnection troubles?
03:06Olajydsorry I got disconnected
03:06Olajydyup
03:06TEttingeryeah, did the date parsing stuff work after the channel had the 3 people jumping in and out with suggestions? :D
03:07OlajydI tried solving the datetime problem but somehow I couldnt resolve it
03:07TEttingerhm
03:07TEttingerdid you encounter any errors that could be, say, posted on refheap?
03:08Olajydthe date parsing did work but had issues with number of days that is a non-integer
03:08Olajydfor example where the number of days is 0.5
03:10TEttingerright, so you needed also to parse decimal days?
03:10TEttingerthis is where things get interesting
03:11oddcullyOlajyd: have you tried the suggestions to work with hours or milliseconds?
03:12Olajydoddcully, no :)
03:13TEttinger,(let [date-str "2015-08-21"] (map #(Double/parseDouble %) (clojure.string/split date-str #"-")))
03:13clojurebot(2015.0 8.0 21.0)
03:14OlajydI tried converting the non-integer days to hours or minutes and adding it to the given date string, dont know if that was a good approach though :)
03:15TEttinger,(let [date-str "2015-08-21" part-of-day-str "0-0-0.4" parse-date (fn [s] (map #(Double/parseDouble %) (clojure.string/split s #"-")))] (map + (parse-date date-str) (parse-date part-of-day-str)))
03:15clojurebot(2015.0 8.0 21.4)
03:22OlajydTEttinger, I have a problem for today :)
03:23TEttinger,(def date-format (java.text.SimpleDateFormat. "yyyy-MM-dd-HH:mm:ss"))
03:23clojurebot#'sandbox/date-format
03:23TEttingersure, go right ahead
03:23OlajydTEttinger, problem is: Right-pads the associated string with the Pad Character until it contains Length total characters. If the column value is already longer than Length, then it is truncated to Length
03:24OlajydWhat is the way to go with this,
03:25TEttingerthis one is another thing that format is good for. and format is, if you recall, sorta a voodoo magic function... it has a description for this type of thing
03:25TEttingerbut there happens to be another way hang on
03:28Olajydreally, lol I’m going to hang on to that voodoo function :)
03:29TEttinger,(let [Length 20 Pad \- Name "TEttinger"] (apply str (map #(or (nth Name %1) %2) (range) (repeat Length Pad))))
03:29clojurebot#error {\n :cause "String index out of range: 9"\n :via\n [{:type java.lang.StringIndexOutOfBoundsException\n :message "String index out of range: 9"\n :at [java.lang.String charAt "String.java" 658]}]\n :trace\n [[java.lang.String charAt "String.java" 658]\n [clojure.lang.RT nthFrom "RT.java" 854]\n [clojure.lang.RT nth "RT.java" 847]\n [sandbox$eval27$fn__28 invoke "NO_SOURCE_FILE" 0]\n ...
03:29TEttingeroh right
03:29TEttinger,(let [Length 20 Pad \- Name (vec "TEttinger")] (apply str (map #(or (get Name %1) %2) (range) (repeat Length Pad))))
03:29clojurebot"TEttinger-----------"
03:29TEttingereasier way actually
03:29TEttinger,(let [Length 20 Pad \- Name (vec "TEttinger")] (apply str (map #(get Name %1 %2) (range) (repeat Length Pad))))
03:30clojurebot"TEttinger-----------"
03:30TEttinger,(let [Length 20 Pad \- Name (vec "TEttingerLivesInCaliforniaSoItIsGettingLate")] (apply str (map #(get Name %1 %2) (range) (repeat Length Pad))))
03:30clojurebot"TEttingerLivesInCali"
03:30TEttingerthere's some really neat clojure language stuff being used here
03:31TEttinger,(doc nth)
03:31clojurebot"([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."
03:31Olajydwow
03:31TEttingeroh it can be even simpler
03:31TEttinger,(let [Length 20 Pad \- Name "TEttingerLivesInCaliforniaSoItIsGettingLate"] (apply str (map #(nth Name %1 %2) (range) (repeat Length Pad))))
03:31clojurebot"TEttingerLivesInCali"
03:32Olajyduhhmm nice
03:32TEttingerok so quick going-over: Pad doesn't need to be a char but should be, probably.
03:32Olajydok
03:33TEttingerwhat it does is it maps over two collections, pair of elements by pair. one is an infinite range from 0, 1, 2... up to however many elements actually get used, which is limited by the other collection here.
03:34TEttinger(repeat Length Pad) will create a sequence of repeated pad chars here, exactly Length long
03:34Olajydoh ok
03:34TEttingerthe function we use on this uses the anonymous fn syntax, #() where %1 is an element from the first collection and %2 is an element from the second
03:35TEttingerit gets the nth char from Name at index given by an element from (range), so the first will be (nth Name 0 \-) when you resolve what the args are
03:35TEttingerthe next is (nth Name 1 \-)
03:36TEttingerit will stop if it hits the end of either collection, doing the truncate because the repeated padding chars are exactly Length long
03:37TEttingerif the index from (range) is past the end of Name, it uses the not-found argument to nth in that doc I pulled up for nth
03:37Olajydok
03:37TEttingerand that's really all there is to it, other than needing to (apply str ...) on it to go from a sequence of chars to a string
03:38Olajydso how about the voodoo function you suggested earlier
03:39OlajydTEttinger, in what areas can we apply the formatting
03:40TEttingerthat would be format. it I don't think can do the truncate part very easily
03:40TEttingerbut it has built-in support for padding with certain characters
03:41Olajydis it available in clojuredocs?
03:42TEttingeruh, sorta. clojuredocs refers to this: https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
03:42TEttingerwhich is rather large.
03:42Olajydoh nice
03:43TEttingergood things about format include:
03:43TEttinger,(format "%04x" (int \Z))
03:44clojurebot"005a"
03:44TEttingeran easy way to get zero-padded numbers in decimal or hex
03:44TEttingera lot of ways to format, though not parse, dates
03:45Empperiit is it's own mini language
03:45Empperia bit like destructuring in clojure
03:45TEttingerformat can't handle arbitrary padding chars or truncation even with all that
03:45TEttingeryeah, or regular expressions
03:45Empperiyeah
03:46TEttingerwe seem to be hitting a lot of those in these first few days with clojure :)
03:46Empperiand most of that stuff is not limited only to java/jvm
03:46TEttingeryep!
03:46Empperithe whole formatting syntax comes from C I think
03:47TEttingerI believe you're right unless C got it from somewhere else too
03:47Empperiand it's been adopted to whole plethora of languages
03:48Empperione of those strange looking mini languages which are actually worth learning since it'll carry on with you to the next language you're going to learn (most likely at least)
03:48TEttingercl-format in clojure.pprint is a pretty crazy reimplementation of one of the most complex mini-languages in Common Lisp
03:48TEttingerhttp://clojuredocs.org/clojure.pprint/cl-format
03:53OlajydTEttinger, thanks for making out time today, I hope to catch up with you tomorrow :)
03:53TEttingerno problem! glad to help
03:53OlajydThanks to y’all that contributed too
03:53luxbock(inc TEttinger)
03:54TEttingerlazybot is dead. long live lazybot
03:54OlajydTEttinger, quick advice on how I can be like you :D
03:54TEttingerkeep making little test projects and things in clojure
03:54TEttingerlots of little stuff in different areas
03:55amalloyTEttinger: i bet you never thought anyone would thank you for making out time
03:56TEttingerI'm happy my time is well-spent
03:56amalloyit's a joke, see. "taking time out" would be the usual idiom: "making-out time" sounds like a totally different thing
05:46lazyseqhi, I'm stuck with a java interop issue that I do not understand
05:46lazyseqI use gen-class to generate a class within a particular package to access its package private classes
05:47lazyseqhowever, I get the following exception java.lang.IllegalArgumentException: Can't call public method of non-public class
05:47lazyseqif I use an intermediate java class, that is not generated, this isn't an issue
05:48lazyseqthe java class, part of the particular package, can access the public method of the non-public class with any issue
05:49lazyseqthis drives me nuts, because I have a dependency between clj and java files that I cannot solve in leiningen because I do not know how to compile a single java file in the prep-tasks
05:51lazyseqthat is, I have clj that depend on a java implemented class, and a different java implemented class that depends on a class generated with gen-class
06:38Manaphy91Hi, I've an atom useful to put items inside and a pmap with a procedure that try to add element to the aforementioned atom... The strange thing is that this procedure isn't deterministic and it seems to suffer sometimes of race condition.... (info Clojure version 1.6)
06:45luxbocksay I have a processing pipeline that I'm implementing as a transducer, where I'm using an anonymous function as the reducing function
06:46luxbockif my non-transducing version looks like (->> data (map foo) (filter bar?) ... (reduce post-processing {}))
06:47luxbockwith transducers it just occured to me that I can do the post-processing in the single-arity body of my reducing function
06:48luxbockbut I'm wondering if this is bad for readability, or if there are any other issues involved
06:49luxbockbecause previously I had thought of the single-arity of the reducing function as a way to clean up state
07:24drwin@luxbock if post-processing is another transformation step which has nothing to do with transducing process (e.g. underlying data structure "data" in your case), you should do it as a transducer, this will allow your composed transducer (map filter post-process) to be composed with other transducers
07:26luxbockdrwin: it's basically the difference between doing the post-processing in the single arity body of my reducing function, or wrapping the result of calling transduce in another function-call
07:27luxbockI think I should just do the latter, it seems much clearer that way
07:28drwinluxbock: yes, the difference is subtle, just decide if post-processing is part of the process doing transduction (given transducers composite) or it is transducer on its own, which can be reused in other transduction processes
07:29drwinfor example, if you decided to use channels instead of 'data, would post-process still make sense in that context?
07:32luxbockjust to be clear, if the signature of transducer is (transduce xform f init coll), I'm talking about `f` and not `xform` here
07:34drwinwell, f is transducing function, xform is transducer, you can put your post-processing in single-arity version of f, or have composed it as last transducer in xform, so you have to be talking about both, if I understand it well
07:37drwinyour xform can look like this (comp map-xform filter-xform post-process-xform) or just (comp map-xform filter-xform) and do the post-processing in f
07:39luxbockpost-process-xform would see items from coll one at a time, whereas I need to do things with the end result of the whole xform
07:40luxbockso I think your example wouldn't work for my use case
07:42luxbocklike a silly example would be (transduce (filter pos?) (map (inc)) conj-and-calculate-avg)
07:42luxbockwhich I know looks a bit silly, so I think (calculate-avg (transduce (filter pos?) (map (inc)) conj)) is the way to go
07:43drwinwait, I'm going to read the docs, I think xforms can do reduction and return single value if they want, mapcat can be xform
07:43luxbockhmm, yeah it's entirely possible I'm wrong, I'm still trying to wrap my head around these things :)
07:50luxbockdid you mean `reduced` instead of `reductions`?
07:51drwinluxbock: where exactly? :)
07:51luxbockerr, the last thing you wrote, though I think you definitely didn't
07:51drwinluxbock: xforms can have also completion single-arity call, so post-process-xform could be implemented as stateful transducer, which collects all items and does reduction in its completion (flush), but I agree that would be a bit strange, because then the stream of values would have just one value
07:53luxbockhmm yeah that does sound right
07:54drwinluxbock: I wrote "I think xforms can do reduction and return single value if they want", that still makes sense to me, xform can decide to eat all items and do reduction to them and return single value to be further processed in transduction process
07:56luxbockI'm re-writing some old code to use transducers and re-factoring out some things at the same time, so doing both while trying to understand what the best way to use them is is taking its toll on me :)
07:57luxbockbut this is a pretty good way to get comfortable with them
07:58drwinluxbock: I'm also pretty new to transducers, I rewrote re-frame to use them
07:58drwinluxbock: think about partition-all https://clojuredocs.org/clojure.core/partition-all, it can give you stateful transducer
07:59drwinluxbock: your extreme post-processing-xform could work similar way, but collect all items in the stream
08:00drwinluxbock: but it is not usual, doing reduction in f is more natural
08:00drwinI think
08:01luxbockI hadn't even seen `unreduced` before
08:01luxbockyeah thanks for the pointers, I need some food in my stomach before I continue this task
08:02drwinok, enjoy your meal
08:09zxchello, I'm learning clojure and love every aspect of it, but I'm worrying about performance, since everyone says clojure is slow. do I have reasons to worry?
08:10oddcullywhy do you believe what others say, when you can benchmark your usecase for yourself?
08:11zxc_wasamasa: various blog posts and stuff
08:11wasamasaaha
08:11wasamasagot one to link to?
08:12justin_smithzxc_: slow to start up - yes. Slow at runtime - compared to what?
08:12zxc_wasamasa: first from google http://martinsprogrammingblog.blogspot.de/2012/02/why-is-clojure-so-slow.html
08:13zxc_justin_smith: hmm, go?
08:13wasamasaa core2duo macbook?
08:14zxc_wasamasa: so I need a multicore monster to really feel it?
08:14wasamasazxc_: keep in mind that python for example is 33x as slow as C
08:14wasamasazxc_: and java around 2x as slow
08:14zxc_wasamasa: I know, python is sluggish, so is ruby
08:15zxc_wasamasa: but I don't know about real-world clojure
08:15justin_smithzxc_: in the real world, most of us are not using clojure for things that have runtimes measured in seconds
08:15justin_smithzxc_: I wrote programs in clojure that run for months or years, 3 seconds startup time is nothing on that scale
08:15zxc_justin_smith: I mean - is speed problematic? or not at all?
08:16justin_smithzxc_: we have one graph algorithm that we wrote a 15 line java method for, because immutable data structures were slowing it down
08:16zxc_justin_smith: and what are these programs, if I can ask?
08:16justin_smithout of a ~3k line of code clojure codebase
08:17justin_smithzxc_: servers / backend processing for a webapp that does social analytics
08:17zxc_justin_smith: so most of the time it's good? that's what I came for
08:17justin_smithzxc_: in our experience, yeah
08:17zxc_justin_smith: okay, thanks
08:17wasamasamost of the time it doesn't matter
08:17wasamasaunless you're of course doing number crunching or who knows what
08:18justin_smithzxc_: but this is why I asked "compared to what" - if you were doing high frequency trading or video processing I would likely tell you to look for some other language (something faster than go as well :))
08:18zxc_bu-ut I'm not tied to web, right? since almost everything that was done with clojure was a web app or server stuff or something
08:18justin_smithzxc_: it's a niche that clojure is very good at
08:18zxc_justin_smith: nah, not really
08:19justin_smithzxc_: I would not personally (and do not in practice) use clojure for things that run for a few seconds at a time
08:19zxc_justin_smith: what about desktop apps?
08:19justin_smithzxc_: I don't have much experience with it, but we do have bindings to swing and javafx
08:19zxc_justin_smith: 'kay, thank you
08:19justin_smithI played with seesaw a little, but not enough to make anything substantial
08:20justin_smith(seesaw is a swing wrapper for clojure)
08:20justin_smithTEttinger2 did some stuff with seesaw I think? or was that gui stuff all with CLR?
08:21zxc_justin_smith: by the way, what language faster than go you were talking about? c?
08:21wasamasaseesaw is swing, so no clr there :P
08:21justin_smithzxc_: ocaml, haskell, java, c, c++, c#, f# there are a lot of options
08:21justin_smithwasamasa: what I remember is his screenshots, what I forget is how he made them
08:22justin_smithzxc_: but for me none of those are as nice to work with as clojure
08:22wasamasaif you're on clr, winforms works with mono or natively on windows
08:22wasamasaalternatively, gtk#
08:22justin_smithI wish more people were using clojure-clr
08:22zxc_justin_smith: hate every language from this list, kinda like haskell
08:22justin_smithit's the neglected cousin
08:22zxc_justin_smith: but I thought haskell was slower than go
08:23wasamasaonce I've got something substantial going, I'll turn it into clojure for clojure-clr
08:26justin_smithzxc_: regarding speed, there's some screenshots from the benchmarks game here https://lispmachine.wordpress.com/tag/haskell-vs-google-go/ showing that typically go is slower than c++, c, ats, ocaml, sbcl, and ghc (haskell)
08:26justin_smithit was almost a close match with sbcl, but not with the others really
08:26zxc_justin_smith: from 2012
08:27justin_smithfair enough
08:27zxc_justin_smith: look now http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=ghc
08:27zxc_justin_smith: still slower than c in those benchmarks, but a lot better
08:28justin_smithzxc_: interesting, looks like they massively improved their benchmark code (or go itself) in the meantime
08:29zxc_justin_smith: yeah, go is a new language, a lot of new improvenments are in 1.5 now
08:29zxc_justin_smith: those benchmarks are on 1.4 I believe
08:29zxc_justin_smith: *checks* nope, 1.5
08:31justin_smithzxc_: the really sad thing is when you go to "all langs" for one benchmark, and then sort by memory usage - clojure is always so close to the bottom
08:31justin_smithzxc_: the other clojure weakspot
08:31hyPiRionRemember that the benchmarks game is, well, a game. May or (usually) may not be relevant to what you're developing.
08:31justin_smithhyPiRion: absolutely - last I checked most of the code was nothing like idiomatic code
08:32justin_smithbut if we are trying to compare langs for performance I don't know of better comparisons
08:32zxc__justin_smith: so sad, since its syntax is so nice
08:33zxc__hyPiRion: and these are numerical, short benchmarks
08:33zxc__hyPiRion: that's why c shines
08:50zxc__justin_smith: aand I went on benchmarks game, and clojure is at most just 6 times slower than c, it's not slow at all
08:50zxc__justin_smith: it's comparable to haskell in performance
09:20lodin_Anyone knows a stringify function that can handle infinite (or very long) sequences, e.g. outputting something like "(0 1 2 3 4 5 6 ...)" for (range)?
09:26dxlr8rlodin_: (apply str (range 0 1000)) ?
09:27lodin_dxlr8r: (range 0 1000) is not infinite.
09:27hyPiRionlodin_: look up *print-length* and *print-level*
09:27hyPiRion,(doc *print-length*)
09:27clojurebot"; *print-length* controls how many items of each collection the printer will print. If it is bound to logical false, there is no limit. Otherwise, it must be bound to an integer indicating the maximum number of items of each collection to print. If a collection contains more items, the printer will print items up to the limit followed by '...' to represent the remaining items. The root binding is...
09:28lodin_hyPiRion: Excellent!
09:28lodin_(inc hyPiRion)
09:28lodin_Need comma?
09:28jeayeincf
09:29lodin_(incf hyPiRion)
09:29hyPiRionlodin_: I think lazybot is dead
09:29lodin_RIP :-/
09:29hyPiRionlong live lazybot!
09:29snowellAt least we have clojurebot
09:30lodin_hyPiRion: If lazybot comes back, will it be as zombiebot?
09:30oddcullyi heard he also went over to slack ;P
09:30snowellclojurebot: We love you
09:30clojurebotexcusez-moi
09:30snowellWell fine
10:13OlajydHi oddcully
10:14justin_smith$mail zxc__ note that the specific usages I mention (hft and video) are not just about being fast, but also about having low latency simultaneously with high throughput
10:14justin_smithlazybot has forsaken us
10:17OlajydI tried using the clj-time library to do date functions and I’m getting #<DateTime 2015-08-21T22:56:38.400Z>, Do i need to format it to give something like `2015-08-21T22:56:38.400Z` :|
10:18justin_smithOlajyd: yes, clj-time has formatting methods - like most Object types the default print method isn't going to work in output that is meant for humans
10:20OlajydOh so if i’m using it somewhere else its passing it as an actual date value?
10:20Olajydjustin_smith :|
10:20Manaphy91Hi, I've an atom useful to put items inside and a pmap with a procedure that try to add element to the aforementioned atom... The strange thing is that this procedure isn't deterministic and it seems to suffer sometimes of race condition.... (info Clojure version 1.6)
10:21akabander(defn tick->string
10:21akabander "Converts a Java time scalar into a string using the specified format."
10:21akabander [fmt tick]
10:21akabander (let [jt (java.util.Date. tick)]
10:21akabander (.format (java.text.SimpleDateFormat. fmt) jt)))
10:21justin_smithOlajyd: right - you could look for the javadoc for that specific DateTime class, I am sure it has nice formatters
10:21justin_smithakabander: please don't paste code here
10:21akabander(tick->string "kk:mm:ss 'on' yyy-MMM-dd" tick)
10:21akabanderOh sorry
10:21justin_smithManaphy91: atoms retry, don't do things to atoms that would cause errors if you retried (did them over, repeatedly)
10:22justin_smithManaphy91: especially if you are using pmap and accessing the same atom in each parallel branch, you can expect many retries
10:23Manaphy91but sometimes it works and sometimes not... it isn't deterministic... it seems to overwrite prrvious data...
10:24Manaphy91pmap is in a doall... if I try to substitute pmap with map it works....
10:24justin_smithare you using reset! at all? are you reading the atom contents and setting it in separate forms?
10:24justin_smithManaphy91: can you share the code on eg. refheap.com?
10:25Manaphy91I use only (swap! atom-name function-to-update)
10:25justin_smithand your function doesn't drop data?
10:25Manaphy91I would like but it is too long...
10:25justin_smithManaphy91: http://refheap.com
10:26bjaanyone using undertow here know how I'd go about knowing whether .stop() is safe (i.e. the instance is actually started, otherwise this throws a NPE)?
10:28justin_smithbja: are you using the ring adapter?
10:29lazy-seqIs there any reason why I can't access package private classes from Clojure, even if I make the namespace equal to package containing the class I want to access?
10:29justin_smithlazy-seq: it isn't even supposed to work that way
10:29bjajustin_smith: yes
10:30bjaI'm actually wondering if I should just move to org.immutant/web
10:30justin_smithbja: run-undertow should return the object that you would use to stop the server
10:30lazy-seqjustin_smith: why not though, because clojure just creates a class in the same package
10:30bjayeah, it returns an undertow instance, but if you .stop it and it's not started it throws
10:30bjawas just wondering if there was some way I was missing to tell if it's started without trying to do and catching NPE
10:31justin_smithlazy-seq: just because you are in a package with the same name, doesn't mean you can access a private value
10:31justin_smithbja: oh, that's weird that you would end up with an unstarted instance of something you get by calling run-undertow
10:31lazy-seqit is not a private value, the class is package private, so only classes in the same package should be able to access it
10:32justin_smithlazy-seq: that's called protected, not private, and just having a package by the same name isn't the same as being the same package, this isn't java
10:32lazy-seqjustin_smith: it works if I create a java class in the same package that accesses the methods I want and call the wrapper class from clojure
10:32bjajustin_smith, it's started when you call (run-undertow), but I want to make sure my component's stop method is idempotent
10:32bjaso if someone accidentally calls (stop (stop http-component)) the world shouldn't blow up
10:34justin_smithManaphy91: just a style not, (swap! pe update-in [conf-len] #(conj % ext-vec)) is equivalent to (swap! pe update-in [conf-len] conj ext-vec) but I think the latter is nicer to read
10:34bjaor maybe I'm being silly and the world should blow up, idk. undertow just didn't seem to have any docs on knowing whether their instance was actually bound to ports right now or not.
10:34Manaphy91ok
10:35justin_smithbja: I typically have my system component dissoc the stateful thing after punching it in the state, so that next time it isn't there to punch again
10:35lazy-seqjustin_smith: Given the decompiled class it is in the same package
10:35bjaI guess that's a reasonable thing to do. Maybe more reasonable than trying to figure out how to avoid double stopping.
10:35bjathanks
10:45justin_smithbja: I bet the undertow object has a method like .isRunning somewhere in the api, but I find the general practice of removing things from a component if they are no longer relevant to be quite re-usable :)
10:50lazy-seqjustin_smith: I guess the only forward is to create a java wrapper then, still curious as to why that works, but clojure with the ns equal to the package or gen-class fails
10:53justin_smithlazy-seq: sadly I don't really get how package-scope works on a bytecode level - but I think this is one of the various ways that clojure's emitting of byte code and javac's are different
10:57justin_smithlazy-seq: I am following up to try to find more about this question. One clue I just found is that "protected" doesn't actually directly correspond to any protection in the jvm bytecode
10:58arkhI've been using clojure for a number of years now but I've never had to include java in a clojure project (leiningen). In broad strokes what are the steps a person needs to take to use this (1) from their clojure code: 1) https://github.com/ronniedong/Expect-for-Java
10:58lazy-seqjustin_smith: I suspect it has to do with reflection, because the wrapper cannot have the package private class as a parameter. Rather I need to specify each parameter that has the type of the package private class as an Object and cast in the function to the package private class
10:58justin_smithlazy-seq: unless it really is private (which is not the same as package protected)
10:58justin_smithlazy-seq: there is no such thing as "package private"
10:58arkhExpect-for-Java is not in any public repository
10:59lazy-seqjusting_smith: package private is synonymous to default access / protected
10:59lazy-seqjustin_smith: at least that is how I encountered it on several websites
11:00wes_ellisI've got a csv file that I want to parse and plot lat/lng on google maps. Can I do this with just clojurescript, or would I need compojure/ring?
11:01justin_smithlazy-seq: "protected" is a compiler restriction. "private" is a bytecode restriction. Clojure shouldn't be preventing access to package level protection at all, and reflection can easily get around the private stuff.
11:01lazy-seqjustin_smith: that is what I expected, but somehow it throws IllegalAccess errors :/
11:02lazy-seqarkh: You can include the java file in src/java, add the java-source-path to the project.clj and just import it into your clojure ns
11:03oddcullywes_ellis: there is a file api in javascript - i can not say, how well it's wrapped in goog libs (or if there is a nice cljs lib)
11:03justin_smithlazy-seq: this could have to do with the "final" flag too... hopefully someone else knows more, I'm rapidly out of my own depth here
11:03m0wfofinal flag should have no effect
11:04lazy-seqjustin_smith: the class is final btw
11:04arkhlazy-seq: thank you
11:04justin_smithit's not just classes that can be final
11:04justin_smiththere's also fields and methods that are final (on a vm level)
11:05justin_smithand sometimes with reflection hacks you have to toggle final status to get at things
11:06wes_ellisoddcully Thanks. I'll look into a pure clojurescript application.
11:06lazy-seqjusting_smith: I think I will spends some time to create a minimal example that invokes this behavior and see what is causing this
11:06lazy-seqjusting_smith: an other non-final protected class doesn't give an issue
11:07lazy-seqjustin_smith: so perhaps the final flag is influencing things
11:07justin_smithlazy-seq: I don't have it here (it is on my notes on my home computer) but there is a hack amalloy showed me where you can actually change the value of the number 5 to be 2... and ensuing hilarity of course. But it's a good demo of popping the hood and tweaking things you really shouldn't be touching.
11:09justin_smitharkh: depending on how ambitious you are feeling, it looks like clojure.data.csv is not huge, and porting it to cljs would be interesting if it hasn't been done yet (or even making a cljc version...)
11:10lazy-seqjustin_smith: I try to dive more into the internals to figure this out, thanks for helping!
11:58dxlr8rhello, I know there is a project to compile clojure code to C. but is there a project where I can write clojure without compiling and running from shell?
12:05justin_smithdxlr8r: "a project to compile clojure code to C" this actually exists?
12:05justin_smiththere are hooks to use llvm from clojure, but that's not the same thing at all
12:06justin_smithclojure relies really heavily on gc for starters...
12:06jeayeNot to mention java interop
12:07justin_smithjeaye: I could see system interop working for a cclojure - but yeah it provides a completely different level of abstraction
12:14lvhcljc would be cool
12:14justin_smithname's already taken
12:14lvhthe reader logic is fairly different; ISTR clojure.data.csv uses a lot of Java APIs directly
12:15justin_smithahh, that's what you mean, neverm ind :)
12:15justin_smithlvh: they are just io apis, you could swap them out
12:15justin_smithI have done more rediculous things in cljc
12:33wes_ellisjs interop: I'm trying to get the .-result prop of a FileReader, but I think cljs is returning the result too quickly. How can I wait for .-readyState to be 2 ("finished")
12:40lvhjustin_smith: Sure
12:40lvhjustin_smith: My experience with cljc so far has been "rename file; magically be able to use it from both clj and cljs"
12:53bourbonwhat's the most proper way to differentiate behavior between lein profiles?
12:53bourbonI want to use a local in-memory store for dev and a config file for everything else
13:00wes_ellishttps://gist.github.com/hiredman/5167534
13:01wes_ellisNice example on reading files. Now if I can find a clojurescript equiv of clojure.data.csv
13:08iwohey, quick concurrency question: I want to create N workers to do something in my clojure app, which I can do like: (dotimes [_ n] (future ...))
13:09iwothis kind of thing: http://stackoverflow.com/a/2622410/125825
13:09iwohowever my first thought is: this isn't actually creating n threads of course, I'm still limited to the size of the thread pool used for futures (I'm just creating N tasks)
13:10justin_smithiwo: the future thread pool is not limited in size
13:10iwoIt seems like what I want to do is send-off, but I have no need for agents
13:10justin_smithagents use the same thread pool futures do
13:10iwoso futures use the 'send-off' pool, not the 'send' pool?
13:10justin_smithin fact, canonically, the futures are using the agent thread pool
13:10justin_smithoh, wait
13:10justin_smithforgot those were two different pools
13:11{blake}Is one supposed to be able to "lein jar" a project newly created with "lein new app project-name"?
13:11justin_smithiwo: yeah, I think it's the expandable send-off pool futures use, but we should double check that
13:13iwoit's clojure.lang.Agent/soloExecutor
13:13iwoso it's the good one :D
13:14iwothanks for pointing me in the right direction!
13:14justin_smithnp, glad I could help
13:16justin_smithiwo: the point where it happens, for those following along at home https://github.com/clojure/clojure/blob/4bb1dbd596f032621c00a670b1609a94acfcfcab/src/clj/clojure/core.clj#L6670
13:21dxlr8ryes it is: https://github.com/schani/clojurec , but that was not important :)
13:26dxlr8rI guess it could be done, but it would need to be compiled for every run. have a script start a repl with code from a file
13:27dxlr8rmight be better to have one repl up at all times and refresh it somehow, and then load new code
13:27justin_smithdxlr8r: what are you trying to do again?
13:28dxlr8rtrying to replace clojure for small shell scripts
13:28dxlr8rmake it more like perl, python, etc.
13:28justin_smiththat's what pixie aims to be
13:29dxlr8rnice :)
13:29justin_smithbut you can totally run java -jar clojure-1.7.jar -e '(load "blah.clj")'
13:30justin_smithand the load time is actually decent with lein and nrepl out of the picture
13:30justin_smithor at least usable
13:30{blake}Huh. Pixie's VM is "small" at 10MB.
13:30justin_smithfor a full system of a clj-like that's puny
13:30dxlr8ris it possible to have the jvm open, instead of opening and closing at everytime
13:30dxlr8rwould make it faster
13:31dxlr8rand instead flush it between "scripts"
13:31justin_smithdxlr8r: there is grenchman for that kind of thing
13:31justin_smithbut then all users need to share a vm and trust each other not to mess up the vm state of course
13:32dxlr8rtrue, might not be to smart :P
13:32{blake}Why is it all so big?
13:32dxlr8ris it possible to slim the jvm? :)
13:33justin_smithdxlr8r: it's not the jvm that needs slimming here, it's clojure itself
13:33{blake}Yeah, Pixie doesn't use the JVM.
13:33justin_smith{blake}: immutable data structures are relatively fast, but are not cheap
13:33justin_smiththey trade size for speed
13:33{blake}And my understanding is it's not the JVM that's the startup time problem, either.
13:33justin_smithexactly
13:34dxlr8rok
13:34dxlr8rlearning a lot today :)
13:34dxlr8rwill bookmark the projects
13:34{blake}Oh, I get that they're not cheap, but I guess I don't get how that translates to VM size. Unless the built-in stuff uses =and stores= a lot of IDSes.
13:34justin_smith{blake}: ever notice how much of clojure is written in clojure?
13:34justin_smiththe immutable data goes pretty deep
13:35{blake}Huh. I thought we weren't supposed to bother with state. =P
13:37dxlr8rcan I take code from pixie straight into clojure?
13:38dxlr8rif it doesn't do any outside calls :)
13:38fantazowhats pixie?
13:38dxlr8rhttps://github.com/pixie-lang/pixie
13:38justin_smithdxlr8r: it's highly similar but not compatible, even things like require have different syntax
13:39dxlr8rwell, that's not good :/
13:39justin_smithI'm sure in the brave future of arbitrary read-conditionals we will eventually see code that can be clojure or pixie code depending on which compiler you are using
13:39{blake}You can use hiccup from Pixie, apparently.
13:40justin_smithbut pixie doesn't have clojure compatibility as a goal
13:41{blake}Right. Sort of a mindspace compatibility.
13:42Bronsa{blake}: in my system starting the jvm takes 1/5 of the time it takes for the repl to start
13:42{blake}Bronsa: Yikes.
13:42{blake}How did you figure that out?
13:42Bronsatime java HelloWorld.java vs time java -jar clojure.jar < /dev/null :)
13:43{blake}Bronsa: Ha!
13:47dxlr8rtime java -jar clojure-1.7.0.jar -e '(+ 1 2)', take 1 second here
13:47dxlr8rso not that slow :)
13:47Bronsa0.6s here
13:48dxlr8r1.17 to be precise
13:48justin_smithyeah, when you take out the lein/nrepl overheads it's not super bad
13:48Bronsai'm optimizing for startup time though, a bare java -jar take 0.8/0.9
13:49dxlr8rguess clojure can be used for scripting then :)
13:49dxlr8rwithout having to make jars etc.
13:50hiredmanI use clojure for scripting
13:50BronsaI try to use bash when possible, when I fail I fallback to clojure
13:50justin_smithdxlr8r: especially considering you can do "lein cp > deps" and just slurp that deps file up from your script to get your runtime classpath (assuming that making sure maven has all those deps is part of your install for the script)
13:50hiredmanhttps://gist.github.com/hiredman/a8fb63ec64704ecb967f is a script for deleting old backups of clojurebot's db from s3
13:51rhg135If you need many deps though, then it gets hairy, but for scripts it's unlikely
13:51justin_smithrhg135: lein cp generates a deps string, not too hairy
13:52rhg135That requires a project.clj and lein installed
13:52justin_smithduring install, sure
13:52justin_smithbut not during runtime
13:52hiredmanhttps://gist.github.com/hiredman/05befd5b39eef89b86ca is a script
13:53BronsaI'm guilty of doing java -cp `lein cp` clojure.main
13:53hiredmanhttps://gist.github.com/hiredman/7670532
13:54rhg135Heh, as am I
13:54dxlr8rnice hiredman
13:54Bronsahiredman: wasn't there a function to add a jar to the classpath at runtime in clojure.core?
13:54hiredmanyep
13:54Bronsa,(doc clojure.core/add-classpath)
13:55clojurebot"([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
13:55akabanderThere's lein-bin which makes a binary from the uberjar
13:55hiredmanthe java method it called is still there on DynamicClassloader too
13:55akabanderOr did I misunderstand the question? Load times are... not great... but okay on a fast system.
13:55Bronsaprobably a better way to do that than using a using c.l.C/LOADER
13:56dxlr8rmy scripts are going to use each other a lot, I'll take a look to see if I can make it work. or this might be a good time to refresh my python or perl
13:57akabanderI wrote an API to Ambari REST in Python and a utility to use it, then re-wrote the API and tool in Clojure. Using lein-bin, the Clojure version takes 3x as long as the Python in user time.
13:59dxlr8rspeed is really not to important for what I trying to do. but I want to share with a community, so a hackish approach would maybe not be the prefered way
14:00akabanderHm, I take it back. It's 0.12s user for the Python and 2.23s user for the Clojure. :(
14:01akabanderIt's all about the jvm overhead.
14:01akabanderSkummet crashed on me, but I hear that can help.
14:01dxlr8rwould be great with a clojure for scripting. easy refer to other scripts that are within your SHELL path etc
14:01dxlr8rjust as in perl/python/bash/sh etc. :)
14:02akabanderYeah I may have to dig into pixie and cljs.
14:02dxlr8rwhere the code is compatible with clojure. except for maybe the require etc. since it's based on shell path
14:03akabanderThis is one of those areas where I'm pretty sure smarter people than I am working.
14:03dxlr8rtrue dat :P
14:04akabanderSo I just saw a library anounced that works with both clj and cljs, not sure how difficult the technique is to use, but it could be something to consider.
14:07dxlr8rhttp://hugoduncan.org/post/shell_scripting_in_clojure_with_pallet/
14:08dxlr8rnot entirely what I wanted, but wanted to share while one the subject
14:09akabanderYeah, that's interesting, but it's sort of an inversion of what I want. :)
14:09dxlr8rhttps://koodo.wordpress.com/2013/11/09/shell-scripting-with-clojure/
14:10fantazoI wonder how someone could tune the jvm for a quick startup, like in shellscripts.
14:11akabanderfantazo: There's a project called Skummet, which Switftkey is using to get decent startup times on Android
14:11justin_smithfantazo: considering that the jvm is 1/5 of the startup time, why would you optimize that first?
14:11akabanderBut I couldn't get Skummet to work
14:11fantazois it?
14:11justin_smithfantazo: that or less
14:12fantazoI always wondered why jvm apps generally take longer to print something on the console than say C apps
14:13justin_smithfantazo: the jvm starts up slower than a program that isn't running on a vm. Clojure starts up much slower than the vm itself. We have a lot of optimizing we would have to do before the vm became the bottleneck.
14:13dxlr8rlein-exec looked interesting, but looks like you can include scripts from the shell path in an easy way.
14:13akabanderhttp://blog.ndk.io/2014/02/11/jvm-slow-startup.html
14:13dxlr8rsince it's still depended on lein to load deps
14:14fantazojustin_smith, that's bullshit a vm isn't the limiting factor for startup time. there are enough vm languages which start "instantly"
14:14akabanderThe part 2 of the article I linked above goes into detail
14:15justin_smithfantazo: OK looking at that link I was clearly wrong, more like 1/30th of the startup time is the vm
14:15justin_smithfantazo: did you read what I said? a vm is a factor, clojure is the bigger factor by far
14:15fantazoI did.
14:16justin_smithI don't know how you got "the vm is the slow part" out of my statement, which was the opposite
14:17fantazo" the jvm starts up slower than a program that isn't running on a vm."
14:17fantazofirst sentence.
14:17justin_smithwhich is a fact
14:17justin_smithfollowed by the more relevant concern: the app in question starts up much slower than the vm
14:18fantazosure. but it highly depends on the language. not every vm language out there has a slower startup time
14:18Bronsafantazo: he said jvm
14:18Bronsathe jvm startup time is the same regardless of language
14:18fantazoBronsa, no vm.
14:18justin_smithfantazo: a program that isn't using a vm can be compiled such that literally the bytes that will be put into memory are in the same order and same position in the binary. This starts a lot faster than a vm that loads up bytecode. But this fact is not really relevant in the case of clojure.
14:19Bronsafantazo: justin_smith said `jvm`
14:19justin_smithfantazo: there is no vm out there that will start up as fast as a program which literally has an mmap call as its startup sequence
14:19akabanderCould we generate a binary that has already loaded core.clj into bytecode?
14:19fantazoBronsa, I'm not arguing about a sentence which I quoted. sorry.
14:20akabanderSo instead of running on a JVM, the program would run on a CLJ-VM?
14:20Bronsafantazo: you were replying to a comment he made about the jvm
14:20akabanderThat should let us trade seconds for bytes, which I'll happily do.
14:21Bronsaakabander: clojure.java is already distributed AOT compiled if that's what you're suggesting
14:21fantazoit really isn't important if a vm language has the same startup time. only a startup time for say -help or console like programs like java, cat, etc.
14:21fantazothat's not a very big deal.
14:21akabanderI guess so... I'm actually kind of naive when it comes to the JVM, so please feel free to kick me in the assumptions.
14:22Bronsafantazo: i'm not sure you're reading or understanding what we're saying. the JVM startup time is a factor in the slow startup time of clojure but it's marginal. the real factor is clojure itself
14:23Bronsaakabander: clojure is loaded from class files, core.clj doesn't get recompiled each time you start clojure
14:23fantazoBronsa, I'm understanding what you are writing.
14:24akabanderGot it, but it does spend a lot of time creating vars and metadata and loading external functions. Can that be done once and "frozen" into a binary?
14:25Bronsaakabander: I don't think creating vars and metadata is the bottleneck, what's slow is loading the thousand of classes required to do that
14:26hiredmanrunning the verifier
14:26Bronsahiredman: I disable the verifier for my clj repl, startup time goes from 0.9 to 0.7
14:26akabanderBronsa: I'm just looking at the article about bootstrapping: http://blog.ndk.io/2014/02/25/clojure-bootstrapping.html
14:27Bronsaakabander: there is a branch in the clojure repo to delay var initialization until necessary, IIRC it resulted in some startup speedup at the cost of halved runtime performance
14:27dxlr8rguess btw I could use eval and read-string to load other clojure scripts from my path
14:27justin_smithdxlr8r: or even just load or load-file
14:28dxlr8rnice
14:28hiredman,(doc load-file)
14:28clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
14:28akabanderBronsa: Yeah I'm looking deeper now; "functions like eval cannot know what classes are needed"
14:31hiredmanthere are a vast multitude of different techniques, and people have explored a number, and they all have different and in some cases complex trade-offs, and some of the techniques are proposed by people who barely use clojure so the interactions with other features of the language are not well understood
14:33hiredmanclojure could do very well for many different uses cases, and people of many ideas how to do it, but ideas are cheap
14:35akabanderI have several use-cases just in this one project. I'm building an API first, then a set of utilities that will need the API, and then a modular long-running application that will also use the API.
14:35hiredmanlike, if someone *really* *really* wanted a highly optimized clojure they would take stalin (the optimized scheme compiler every cites) and port it/translate it for clojure and the jvm, but that is a lot harder and appeals less to thinking about things that might work and writing a blog post
14:35hiredmaneveryone
14:36hiredmanakabander: you just need a socket and your utilities written in shell communicating with the socket via netcat
14:38akabanderThat approach actually has some interesting second-order benefits. Should be worth the experiment, at least.
14:38hiredmanif someone actually finished an optimizing compiler for clojure, and people felt it was worth it to use, that would likely push clojure towards being "self hosted"
14:39hiredmanakabander: it is how every project that I know of that does something like that does it
14:39hiredman(a whole program optimizing clojure compiler would do better when the datastructures are written in clojure too)
14:40akabanderhiredman: And this is how we get the "fix the airplane in flight" behavior that all the "we're using Clojure" articles boast about. I see.
14:42Bronsaa whole program optimizing clojure compiler is impossible w/o sacrificing some features
14:42hiredmanlikely it would take someone like ambrose with core.typed (or Bronsa, who if I recall is also in academia, with all the tools analyzer work), because it is a huge chunk of work, hard to sustain as a fee time project, and most startups don't care that much
14:42hiredmanBronsa: same for scheme
14:48dxlr8rI might make a small library to integrate the shell's path into load-file. so that you can simply just load the name of file and not know it's path
14:48justin_smithin my experience the biggest sacrifice with stalin is the hours of compilation time to generate toy level code - I lost patience before getting to anything close to usable
14:48dxlr8rand use pomegranate if the scripts need external jars
14:48justin_smithdxlr8r: maybe something like CLJ_TOOL_SCRIPT_PATH but using the name of your app or whatever
14:49justin_smithas an environment var that a user could add to or replace
14:50dxlr8ryeah, could seperate it from PATH ofcourse, have it contain the paths in PATH and the option to include clj only paths
14:50dxlr8rif that makes sense, not the best to talk about coding in english
14:51akabanderI would make it it's own variable, and if people want to put clj files in their actual PATH, then they can do CLJTOOL_PATH=$PATH:$HOME/lib/clj-stuff
14:51dxlr8ryeah
14:51dxlr8rprobably better
14:52akabanders/it's/its/
14:53dxlr8rwill look at it. atm I am splitting up a lot of my clojure work to make them generic as libraries
14:53dxlr8rand to put on github
14:54dxlr8ra couple might end up ion clojars too. I have a small library that is actually quite handy and I haven't seen it for clojure before
14:54dxlr8rso someone might want to use it too :)
14:54dxlr8rs/ion/on
15:06sdegutispuredanger: i dunno man, getting word out to 642 people could mobilize quite a few people to protest cca/jira
15:07sdegutisI for one am rooting for these guys to win. Cognitect should make Clojure pure Github.
15:08puredangerThis is not up for debate
15:08puredangerIt's not going to change
15:09sdegutisthat's what they all say
15:09sdegutisjust today gcc moved to git
15:10sdegutischange is possible
15:10sdegutissrsly tho if it doesnt change then rich and the team lose all my respect
15:11sdegutisand if that doesnt matter to them, then they deserve to lose all my respect even more
15:13puredangerI'm going to go put my energy into making Clojure things rather than into a conversation this dumb
15:14hiredman/ignore is really nice
15:22snowellI'd done that, but then I only get to see half of a conversation
15:25sdegutispuredanger: that may have been a bit harsh
15:26sdegutisi havent fully figured that out. but if it was, then you ahve my apologies.
15:26hiredmanbut the upside is you (sometimes) avoid saying harsh things to people on the internet, regardless of if they deserve it or not
15:28sdegutisI see what snowell said in an irc log but not in here, even though he isn't on /ignore -- wht givs
15:28hiredmanbut I also have my browser setup to replace certain words similar to https://xkcd.com/1288/, so I am used to my internet experience being heavily modified
15:28sdegutishiredman: how?
15:28sdegutischrome plugin?
15:28hiredmanfor me all the clojure documentation talks about namespaaaaaaaaaaaces
15:28sdegutishiredman: how? clojure plugin?
15:29sdegutisi mean chrome
15:30sdegutisoh, i see. people are actually using /ignore.
15:30sdegutisso i guess justin_smith is the only one who doesnt have me on ignore
15:31sdegutiswhich works out well, because he's the only one here who knows what he's talking about.
15:31prrthello beautiful clojuristas, is clojure suitable for indie games?
15:31akabandersdegutis: I don't have you on /ignore... yet.
15:31sdegutis:)
15:32xemdetiaprrt, I think a better question is 'is java a viable platform for the sort of indie game you want to make?'
15:32xemdetiaor rather the jvm/javascript
15:32akabanderSomeone should make clunity
15:32hiredmanprrt: https://www.youtube.com/watch?v=0GzzFeS5cMc is a great presentation about games written in clojure
15:32sdegutisakabander: just you wait until I've said some reasonable and logical things that happen to upset the crowd who hold rich on a pedastal!
15:32xemdetiasure
15:32prrtxemedtia: java = clojure? or is something there I don't know
15:32sdegutisprrt: java is 3 things
15:32akabanderClojure = hosted on the JVM, but not Java
15:33sdegutisprrt: 1. a virtual machine that runs platform-independent bytecode
15:33oddcullyakabander: there is arcadia
15:33sdegutisprrt: 2. a language (Java) that runs on that virtual machine (JVM)
15:33sdegutisprrt: 3. a set of libraries that the JVM inherently uses
15:33sdegutisprrt: Clojure is an alternative to #2
15:34sdegutisprrt: Clojure uses #1 and #3 tho
15:34akabanderoddcully: I should have guessed. :)
15:34prrtsdegutils: but isn't it slower than java-language?
15:34prrtsdegutils: (which gamers still blame for slugishness)
15:35sdegutisprrt: yes clojure is slower than java
15:35sdegutisprrt: the trade-off is that clojure is more dynamic, which some people prefer over speed
15:36sdegutilsprrt: there are optimizations that help clojure get close to java's speed in some circumstances, but they aren't common in the real world use cases
15:36prrtsdegutils: I just don't want to struggle with 15fps, like with python
15:36sdegutilsprrt: generally speaking though clojure isn't used where speed of the program is a huge factor; usually bandwidth or io are the real bottlenecks
15:36sdegutilsprrt: clojure is probably faster than python for games, yea
15:37prrtsdegutils: the real question is, is it fast *enough*
15:37akabanderThe GIL really hurts Python for games though; you can't multithread your renderer without causing hiccups everywhere.
15:38prrtumm, I'm sure I won't have advanced graphics
15:39prrtso roguelikes and platformers are a good spot?
15:39zerokarmaleftprrt: prrt: check out what the arcadia guys have done: http://arcadia-unity.tumblr.com/post/109708255688/building-flappy-bird-from-scratch-at-our-november
15:40prrtzerokarmaleft: thanks, I will watch it later
15:41prrtfinal question - is this speed issue improving with each release? like in go?
15:44zerokarmaleftprrt: there seems to always be something that improves performance with each major release
15:44prrtzerokarmaleft: significant changes, or cosmetic?
15:44zerokarmaleftI'll say that go has a lot more low-hanging fruit in that regard, e.g. GC
15:44alexshendiIs "The Joy of Clojure" still a recommended resource for learning Clojure?
15:45akabanderprrt: There are no cosmetic changes, Clojure is beautiful as it is.
15:45zerokarmalefthow is performance improvemtn cosmetic?
15:45prrtakabander: cosmetic changes in performance, like 0.001 secs
15:45akabanderalexshendi: I'm halfway through the second edition now, I think it's excellent, but maybe the longtimers have more critical opinions?
15:45prrtsmall changes*, maybe it's a better word
15:46zerokarmaleftalexshendi: Joy of Clojure is awesome
15:46akabanderOh, maybe "incremental" is what you meant?
15:46oddcullyprrt: have you done some gaming stuff on jvm. like with libgdx?
15:46alexshendiakabander: There is a *second* edition?
15:46prrtoddcully: nothing done with jvm before clojure
15:46akabanderalexshendi: It's two feet from my left elbow, yeah.
15:47prrtakabander: I just wanted to know if there are big improvenments in performance
15:47oddcullyprrt: there is play-clj, which wraps it for clojure
15:48prrtoddcully: bookmarked
15:50alexshendiakabander: I still have the 2011 edition, which I believe is the first edition.
15:50oddcullyprrt: i mention libgdx because its quite popular and it has several android and steam releases (the galleray sadly shows "everything" so pointing something out, you might know is a bit hard)
15:50zerokarmaleftprrt: transducers in the last major release was a pretty big improvement, for some definition of big
15:51zerokarmaleftprrt: the tuple stuff going into 1.8 looks interesting also
15:51hiredmantuples were reverted last I heard
15:52zerokarmalefthiredman: haven't checked JIRA in several weeks on that point, so I may be mistaken about it being included in 1.8
15:52hiredmanoh, maybe they are back? or maybe I imagined them being reverted
15:52prrtoddcully: o-kay, thank you
15:52hiredmanlooks like they are in master
15:53Bronsathey are reverted
15:53zerokarmalefthiredman: wasn't that rich's own version of the patch?
15:53hiredmanit is
15:53hiredmanah
15:54hiredmanthey are disabled, not reverted, so the code is there, just not used by default
15:54zerokarmaleftah
16:01weathered-treeHi, I"m new to Clojure and the JVM. I have a problem I could use some help with, though it involves jsvc . Anybody familiar with it and use it with Clojure?
16:02akabanderalexshendi: This one is (c) 2014, so I suspect you are correct.
16:09{blake}weathered-tree: Well, maybe we can help even if we havne't used it. What's the nature of the problem?
16:11weathered-treeI have a program that writes using agents to a share (/mnt/cifs). When I run this program through -main it works fine. However, when I run it as a daemon using jsvc, I the agents fail to write to the share with permission denied.
16:12weathered-treeI'm running with jsvc USER set to "root"
16:12weathered-treeand root has permissions to read/write
16:13justin_smithweathered-tree: are you using map or for to do this?
16:13weathered-treeyes, map in this case.
16:13justin_smithweathered-tree: because these things are lazy, the repl has the side effect of realizing lazy seqs because it prints the result, -main has no such mechanism unless you add it by hand
16:13weathered-treeI use dorun
16:13weathered-treeto evaluate the side effects, does that work?
16:14justin_smithweathered-tree: depends - dorun is not recursive for example
16:14justin_smithso a map inside a map or whatever would still be an issue
16:14weathered-treeI just noticed, but a call to -main works fine, even outside the repl.
16:15justin_smith,(do (dorun (map #(map println (range %)) (range 10))))
16:15clojurebotnil
16:15justin_smithoops!
16:15justin_smithoh it worked anyway
16:16justin_smith,(dorun (map #(map println (range %)) (range 10))) ; simpler
16:16clojurebotnil
16:17justin_smith,(dorun (map #(dorun (map println (range %))) (range 10))) ; now with more doruns
16:17clojurebot0\n0\n1\n0\n1\n2\n0\n1\n2\n3\n0\n1\n2\n3\n4\n0\n1\n2\n3\n4\n5\n0\n1\n2\n3\n4\n5\n6\n0\n1\n2\n3\n4\n5\n6\n7\n0\n1\n2\n3\n4\n5\n6\n7\n8\n
16:18justin_smithweathered-tree: of course I can't know whether anything like that is actually happening in your code
16:19weathered-treeI'm taking a look just to be sure :-) That said, when I run using "lein run -m" it works fine. Would that be the case if I had the problem you mentioned?
16:20justin_smithoh wait permission denied I clearly need a break here
16:21justin_smithI totally missed the part where you said "permission denied"
16:22rhg135Is jsvc doing any setuid type stuff?
16:22stuartsierrarhg135: I think it can drop privileges after startup.
16:23weathered-treeI think that is what is happening. I have -user option set to "root"
16:23rhg135Sounds like your code is not running as root
16:23weathered-treeyeah, though jsvc is, since I don't get any other permissions errors.
16:27weathered-treestuartsierra: I'm using component in this project, it's been very useful, thanks!
16:30stuartsierraweathered-tree: you're welcome!
16:33oddcullyweathered-tree: it runs manually as root, but fails if you start it as root via jsvc? maybe your setuid config is wrong and it uses some default (like nobody)?
16:34weathered-treeoddcully: That could be the case, I didn't set up this machine, I'll take a look, thanks.
16:38hante_monstaHow Clojure's release schedule works?
16:39hante_monstaHow long until the next major version?
16:39weathered-treeoddcully: no setuid on the /mnt or /mnt/cifs
16:41Bronsahante_monsta: they aren't usually scheduled, a release happens when it's ready -- however 1.8 will be an exception, it's scheduled for release this november IIRC
16:42oddcullyweathered-tree: no i meant you passing "root" there explicitly for suid? since you are already root and you want to run it as root, why pass that param - maybe it degrades to some unrelated used, which is not allowed to do things there
16:42oddcullyweathered-tree: disclaimer: i have not used jsvc, this is just asking "unix" stuff
16:44justin_smithhmm, on ubuntu you cannot su to root - could this effect jsvc? (probably not actually)
16:44weathered-treeoddcully: I think you may be right. I switched the -user option to a regular user instead of root, but still has write permissions and it works. I verified using htop that the user when using -user root was blank whereas now it shows the user specified.
16:44justin_smithahh!
16:44justin_smithcould be related to that anyway then
16:44justin_smith(inc oddcully)
16:44weathered-tree(inc oddcully)
16:45oddcullyjustin_smith: could you please inc me, when the darn bot is here again ;P
16:45justin_smithfor sure
16:45rhg135He's not coming back man
16:46oddcullyweathered-tree: if you are already root, it makes no sense to tell it to "drop" to root; this is "giving up power" makes most sense where you want to start a process for e.g. privileged ports and then drop root
16:47oddcullyyet jsvc could complain about it
16:47amalloyit's part of my plan to never let justin_smith surpass me
16:48rhg135Now it makes sense lol
16:48weathered-treeoddcully: good points. Thanks for the help, you and everyone.
16:49justin_smith(inc oddcully)
16:49lazybot⇒ 16
16:49weathered-tree(inc oddcully)
16:49lazybot⇒ 17
16:49{blake}(inc oddcully)
16:49lazybot⇒ 18
16:49oddcullyhooray!
16:49rhg135Yay!
16:50justin_smithweathered-tree: oh, I almost forgot to mention, just so our little garden-path detour wasn't a total waste of time, with 1.7 you can replace (dorun (map f ...)) with (run! f ...)
16:53weathered-treeI like that, I can replace a whole bunch of those. Can I inc two people in one day?
16:53justin_smithindeed
16:53weathered-tree(inc justin_smith)
16:53lazybot⇒ 285
17:03seakoanyone have experience with korma, honeysql or other clojure sql libraries and have preferences/recommendations?
17:07justin_smithseako: I don't think any of them are quite good enough that you don't end up needing to figure out how to use clojure.java.jdbc
17:10seakojustin_smith: thanks, since the queries I need to write at the moment are pretty simple maybe I'll just start there before exploring other tools
17:12justin_smithseako: of the various tools I kind of like yesql (which generates a jdbc query function from what basically looks like a regular sql file)
17:13futuroseako: I've been using honeysql, which I've liked so far. I'm doing some pretty straightforward queries, and it's been easy so far
17:14stuartsierraJava JDBC isn't bad either.
17:15seakojustin_smith: I saw that library. there is something that's appealing about just writing sql. but I often find myself needing to compose queries which is where I find sql rather cumbersome. I've enjoyed Sequel for Ruby in the past and both korma and honeysql seem like they would be just as pleasant if not more so.
17:16seakofuturo: thanks!
17:17seakostuartsierra: thanks, I think I'll start there since it sounds like I should learn it no matter what since it's ultimately what's under the hood
17:44skeuomorfHmm, what's a good static site generator to use?
17:47skeuomorfFound Cryogen http://cryogenweb.org/index.html will give it a go
17:50mfikesskeuomorf: Cryogen is awesome IMHO. :)
17:52skeuomorfmfikes: Great. It doesn't appear to have il8n support though, right?
17:52mfikesskeuomorf: Let me test. (Or do you perhaps mean l14n?)
17:53mfikesskeuomorf: (Do you want to localize to different languages, or just have UTF-8 properly rendered?)
17:53skeuomorfmfikes: I want niceties around having posts in different languages
17:53skeuomorfmfikes: so that probably entails utf-8 properly rendered
17:53mfikesskeuomorf: Ahh... right. I have not clue with respect to that aspect.
17:53skeuomorfmfikes: And some kind of system to manage different versions of the same post
17:54skeuomorfmfikes: No worries :)
17:56justin_smithskeuomorf: if nothing else, text output from clojure will be utf-8 if no other option is forced (though the internal representation is java native, basically utf-16)
17:57justin_smith,(def ☃
17:57justin_smitherr
17:57clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
17:57justin_smith,(def ☃ 42)
17:57clojurebot#'sandbox/☃
17:57justin_smith,☃
17:57clojurebot42
18:02sdegutisIs there a way to set an environment variable from a Leiningen alias?
18:03skeuomorfjustin_smith: oh, I see
18:06sdegutisHow can you tell what Leiningen profile was used at runtime in your proram?
18:23weathered-treeseako: I've used korma and yesql in addition to jdbc.
18:26weathered-treesdegutis: I normally use environ and just add a {:dev true} or some such to each profile map.
18:27seakoweathered-tree: that runs the gamut from low-level to dsl, do you have a personal preference based on those experiences?
18:31weathered-treeMy first projects used korma, but I found it too heavy, plus it has some global state I wanted to not deal with. It's pretty useable though. I prefer yesql and jdbc though. Although it's more work, it is a lot easier to reuse what I write and easier to test.
18:34weathered-treeseako: if you don't like writing SQL though, then korma is really your best option. I find with yesql I can keep the SQL out of my code which is good enough for me.
18:35weathered-treeClojure code*
18:42sobelcan someone figure out how to pass a list or vector as the parameter to an IN clause in sql? (oracle)
18:51dxlr8rsobel: apply list
18:51dxlr8r(apply sql [1 2 3])
18:54sobelno, i have a query with "...WHERE attr IN (?)" and i want to pass a list for the ?
18:56sobelreally hoping i don't have to generate a piece of the query just because of this
19:00AWizzArdToday I updated my Emacs to use “Cider 0.9.1”. Now in the repl when I press <Enter> on some previous (“historic”) expression it no longer get’s copied down to the current prompt.
19:01amalloysobel: you can't. there's no support in parameterized queries to parameterize the number of things in the IN clause
19:01AWizzArdIs this just me or is that a bug (or a new customizable setting)?
19:01sobelamalloy: thanks
19:01amalloyyou just need to generate a string like "(?, ?, ?)" yourself
19:01sobelthat was the best answer i could find on the web but it went back to 2013 so i thought i'd ask here
19:02sobeli guess i'll just fill a temporary table and join it. this query could get stupidly large anyway.
19:13seakoweathered-tree: thanks so much!
19:37domokatoI have a function that recursively traverses a tree, and I want to reuse the code to do one of two things: 1, perform some side effects for each leaf (easy), or 2, return a flat map containing leaf name to leaf data mappings. What's the best way to design the function to allow for both?
19:39domokatoMy initial thought is to pass a function in, but not sure how to get a map out of it (#2) without also passing the map through as a parameter
19:39domokatoor something like that
19:42domokatoi could use a map atom and populate that with each call to the passed in function, but there seems like there should be a better way
19:46domokatoi could return a map from the traversal function, but that means i would also have to insert code to merge maps at the recursive calls, which seems like bad coupling
20:09domokatoi'm thinking this may be a job for transducers...
20:12TEttingeror a job for zippers
20:13TEttingerhttp://www.exampler.com/blog/2010/09/01/editing-trees-in-clojure-with-clojurezip
20:28justin_smithdomokato: you could use tree-seq, and filter for data that is leaves
20:28justin_smith,(doc tree-seq)
20:28clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
20:29justin_smith(tree-seq map? vals {:a {:b {:c 0} {:d 1}}})
20:29justin_smith,(tree-seq map? vals {:a {:b {:c 0} {:d 1}}})
20:29clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
20:29justin_smith,(tree-seq map? vals {:a {:b {:c 0} :d 1}})
20:29clojurebot({:a {:b {:c 0}, :d 1}} {:b {:c 0}, :d 1} {:c 0} 0 1)
20:29justin_smithof course you would want to adjust the tree-seq arg for your trees, and ignore higher branches
20:30aaelonysobel: this is a reason why I prefer to write functions that emit SQL portions rather than use a library for this. If you write a function that contains a string of your sql query, it is simple to alter that string any way you please, including editing the IN clause. Then you can execute the new query string against a jdbc connection yourself. Just a thought.
20:31aaelonyfor sql analytics, the level of granularity for sql composability is much higher than for normal apps that want crud functionality.
20:33aaelonyi.e. most often, not at the syntax level of sql, but the "what am I trying to do" level in sql...
20:43domokatojustin_smith: hm, tree-seq might work with a little finagling, but the problem is it's not a simple tree - it's actually an acyclic digraph of objects of various types
20:43domokatojustin_smith: thanks for the tip, i'll compare it to transducers and see which one works better
21:08domokatoi think i'm gonna end up reducing the recursive call and passing a result value through, which will just continue to be nil in the case where I just want side effects. i think this seems reasonable
21:14domokatoin this way i can do the map merging inside the passed in function
21:20edtoast_46please try joining #edtoast .I would greatly appreciate it
21:21rhg135tsk tsk
21:22omarkjHey. Can I do multi arity in a defproto ?
22:41weebz_I'm currently making a website using compojure+http-kit, and I was wondering if anyone knew how to make debugging exceptions/errors easier?
22:41weebz_when I get a message like: String index out of range: -42
22:41weebz_it's a bit hard to figure out where it's coming from sometimes :\
23:37weebz_Is it possible to call Clojurescript from JavaScript?
23:42gfredericksshouldbe, especially if you add ^:export metadata to the functions you want to call
23:42weebz_I haven't used clojurescript before, was curious because when I tried to search I didn't see any examples of how to do it
23:42weebz_I want to use it in the context of a firefox extension
23:44gfredericksCLJS functions compile to JS functions, and the namespaces are all a bunch of nested objects
23:44gfredericksso you can figure it out pretty easily from a js console
23:51weebz_okay, thanks
23:52weebz_do you know if it's possible to do require calls in this format? var fooBar = require("sdk/foo-bar")
23:53weebz_because if that's the case I don't think I would even need to use javascript