#clojure logs

2012-11-14

00:00aduRaynes: where are you?
00:00antares_Raynes: we are in pretty different weight classes but yeah
00:00Raynesantares_: How much do you weigh, sir?
00:01antares_Raynes: ~ 145 lbs
00:01RaynesWere you assuming me to weigh less or more?
00:01RaynesOh wait, were you calling me fat?
00:02Raynes:p
00:02antares_Raynes: :)
00:02aduRaynes: should I repeat myself?
00:02Raynesadu: That's a decision you have to make yourself.
00:02aduwhat is conj?
00:03aduis it in NC?
00:03aduthis must be it
00:04RaynesI'm in Eldridge, Alabama.
00:04aduI'm in Maryland
00:04RaynesIn aproximately 13 hours I will be in Raleigh, North Carolina.
00:04Raynesapproximately*
00:05adubut I'll be in NC after the 18th
00:05adubut aparently that just won't do
00:05RaynesI will be leaving the morning of the 18th. :p
00:07aduI feel like I wouldn't fit in anyways, though, I've only written 2 webnoir sites
00:07xeqiTylerGillies: I notice its looking for "fuseresource", but the path has "fusesource"
00:07TylerGilliesxeqi: ack! thanks
00:08TylerGilliesmust have typoed it
00:08TylerGilliesgood catch
00:19zodiakI hope the conj videos will be up lickety split for all us poor people out there :)
00:20zodiakheck.. give it to the group for a conj-free ;)
00:21zodiakI still chuckle at the erlang conf out in SF, which is like $500 for a 'cheap' ticket
00:24TylerGilliesis there something analogous to 'import org.foo.bar.*' in clojure?
00:24aduTylerGillies: use
00:24TylerGilliesadu: thanks
00:25TylerGilliesuse org.foo.bar or use org.foo.bar.* ?
00:25zodiakisn't require :refer :all the proper way now ?
00:25adupossibly
00:25zodiakI believe as of 1.4 it is
00:26zodiak(:require [org.foo.bar :refer :all])
00:26aduI only ever do (:require [… :as …])
00:26zodiakopen to being wrong/stupid/moron
00:28zodiakTylerGillies, you got it ?
00:28TylerGilliesits not finding the jar, not sure if because it didn't download this dep as a dependency or im doing it wrong
00:28TylerGilliesFileNotFoundException Could not locate org/iq80/leveldb__init.class or org/iq80/leveldb.clj on classpath: clojure.lang.RT.load (RT.java:432)
00:29zodiakTylerGillies, you using lein/lein2 deps ?
00:29TylerGillieszodiak: yes
00:29TylerGilliesthe libs downloaded
00:29TylerGilliesnot sure if this dependency was implicit, im following instructions on the java page
00:30zodiakTylerGillies, fling up your project.clj someplace (pastiebin or some such)
00:31amalloylooks like a problem in your ns clause, not your project.clj
00:31TylerGillieszodiak:
00:31TylerGillieshttp://pastebin.com/Kr9u52pb
00:31TylerGilliesamalloy: http://pastebin.com/6Y5V0qzm
00:33amalloyleveldb is a java project, not clojure. require is for clojure namespaces, not java stuff
00:33TylerGilliesah
00:33TylerGilliesim a ruby guy, we started doing some stuff in clojure for performace, in the hopes of moving more towards that direction
00:33TylerGilliesso im somewhat of a novice
00:33aduiirc, import is for java
00:34zodiakimport is indeed the ticket
00:34TylerGilliesah
00:34TylerGilliesthanks guys
00:35zodiaknp
00:35TylerGillieslooks like the :refer :all syntax is off now though
00:35zodiakyeah.. you don't use :refer :all with import.. jst import and use as usual
00:36zodiaksorry, import and then program as usual (not use as in :use)
00:36TylerGillieszodiak: ah, thanks
00:36TylerGilliesi used .*, and it didn't complain
00:36TylerGillieshopefully that doesn't shoot me in the foot later
00:36zodiakit's java so, probably :P
00:38TylerGillieslol
00:43TylerGillieslooks like Rich Has Spoken on not being able to import * http://groups.google.com/group/clojure/msg/ddca7ec56ea8b51f?pli=1
00:47zodiakclojure is a pragmatic language, it's not like python with it's BDFL
00:47zodiakif you need to import .* go for it, jst know the risks ;)
00:48TylerGilliesso you _can_ import .* ?
00:48TylerGilliesthe above reference makes it seem its not possible
00:49zodiakI think you can, I read that message as 'not a great idea' .. but then .. it's way past my bedtime ;)
00:49TylerGilliesheh
00:50TylerGilliesi added .*sdfsdf to the (import ...) and it didn't complain, so im not gonna take failure of output to mean success
00:51TylerGilliesim just gonna jar tf the jar file and manually add the classes i need :)
00:54ynnivwhy would you import something that you aren't referencing?
01:02TylerGilliesynniv: ask the java documentation that ;)
01:03ynnivif you aren't referencing a class, what is the point of importing it?
01:03TylerGilliesreferto previous statement
01:03TylerGilliesfigured out what problem was
01:03TylerGilliesrepl was open before i did lein deps, doh
01:05ynnivthe previous statement being that the class couldn't be found?
01:08TylerGilliesprevious statement being "ynniv: ask the java documentation that ;)"
01:10ynnivThat isn't making any sense, but I'm glad that you found lein deps. You probably want to use lein 2.0, which no longer needs the deps command.
01:15TylerGilliesynniv: it was tongue in cheek, hence the ";)" im not a java guy but from a lot, if not most, of the java projects i've seen, import org.foo.* is quite common
01:15TylerGilliesynniv: so in a round about way i was asking "Ask the people who made that normal why they do it"
01:16ynnivimporting org.foo.* is a shortcut that is usually frowned upon even with Java folks because it reduces readability
01:17ynnivbecause the code you are reading imports *, you don't know which classes are in which packages, hence you want to import *
01:17TylerGillieswell it seems social pressure if not enough because through my power of observation i see that it is quite prevalent
01:18ynnivonly in sample code, or with people who don't use an IDE
01:18ynnivIDEs will use an import for every class to make it clear where classes come from
01:18TylerGilliesynniv: in sample code, i don't really know from the interwebs whether someone uses an IDE or not
01:19TylerGilliessince im not a java guy, as previously stated, i don't have much interaction with them face-to-face
02:07amalloytechnomancy: thanks for the pointer to parsatron. looks reasonably well designed, and small enough to learn to use easily
02:10amalloyalthough i don't think i've seen such a high letfn-per-LOC in any other clojure file ever
02:38jasonyehhi, has anyone experimented with Nate Young's the.parsatron?
02:47amalloyjasonyeh: i dunno how long you've been in the channel, but i was just saying that i recently took a look and it seems pretty good although i haven't tried it
02:52jasonyehamalloy: thanks, was confused by the line "(eof)" in bf parser in the readme. the "(eof)" seems to prevent repl printing the parsed result
02:54amalloywell, the parsed result isn't very interesting: it's just the input string split up into characters. he's using the bf parser to recognize/validate bf, but not to do anything interesting with it
02:55Raynesamalloy: Wow, what are the odds of that?
02:55RaynesThat he would ask about it like 10 seconds after you said you liked it.
02:57amalloyi think the simplest change to make (bf xs) return its parsed input would probably be (defparser bf [] (let->> [parsed (many (instruction)) _ (eof)] parsed))
02:58Raynesamalloy: What are you doing with parser combinators anyway?
02:59amalloynot much. marveling, mostly, and reflecting how gloss is kinda-sorta a parser combinator but missing many of the usual building blocks
02:59RaynesI don't think I share your interest in things like that.
02:59RaynesI get off on monads and applicative functors, but not parser combinators.
02:59RaynesDid you see me using arrows earlier? It was hot.
03:00amalloyi looked at your paste, but to say that i saw it would be an overstatement
03:00RaynesIt was one line, dude.
03:00RaynesFOCUS.
03:00Rayneshttps://github.com/Raynes/haskheap/blob/master/src/Network/Haskheap.hs#L32
03:01amalloyoh, are those arrows? i remember either *** or &&& just being juxt
03:02amalloyi guess it must be &&& that's juxt, and *** is the "knit" i added to useful?
03:02Raynesamalloy: `(f *** f) (a,b)` = `(f a, f b)`
03:02RaynesI don't know how it works at all (haven't learned about arrows), but cool.
03:03amalloy(f *** g) (a,b) = (f a, g b)?
03:03RaynesYes
03:04shachafover both :: (a -> b) -> (a, a) -> (b, b)
03:04shachafamalloy: Any lenses in your near past/future?
03:05amalloyshachaf: the extent of my knowledge about lenses is someone else's statement that they're a convoluted way to get clojure's update-in wedged into a static-typed language
03:06amalloyi skimmed an article once but didn't learn much
03:06shachafamalloy: That doesn't sound right.
03:06shachafA lens is a "functional reference" to some value which is "within" another value in some sense.
03:06jasonyehamalloy: sorry for the dumb question, what's the underscore in (defparser bf [] (let->> [parsed (many (instruction)) _ (eof)] parsed))?
03:07amalloya name for the result of (eof), _ conventionally meaning "i'll ignore this"
03:07shachafReading deeply-nested values is easy -- (foo . bar . vaz) -- but updating can be annoying in Haskell.
03:07shachafA lens is sort of like a composable (getter, setter) pair that you can use for both purposes.
03:08shachafBut the really nifty part is a generalization of lenses to traversals, which are references to N values instead of just one.
03:08shachafFor example, you can say "world.monsters.traverse.appendages.traverse.position.x += 1" to move all the appendages of all the monsters one unit to the right.
03:09shachaf(The above is actual Haskell code.)
03:17Sgeo__I feel like maybe I'm glad I never tried to implement lenses in Clojure. I wouldn't have known about the cool stuff
03:17Sgeo__Just more the idea that the logic is in the lenses rather than in the data structure or the function
03:21brainproxyRaynes: jimduey mentioned to me a couple of weeks ago that he's working on a protocol based arrows implementation for clojure
03:21brainproxysounded excited about it, but hasn't put anything on GitHub yet
03:21RaynesI can't get excited about Haskell things in Clojure.
03:24clgvRaynes: me neither.
03:24brainproxyRaynes: have you spent any time with frege?
03:24clgvI always wonder why there are some people eagerly describing monads in clojure, as well...
03:25shachafSgeo__: Hmm?
03:25jjidoclgv monads are supposed to be the answer to side-effects in a pure language :)
03:25brainproxyclgv: the abstractions can prove pretty useful, i think that's a fairly practical motivation
03:26Sgeo__shachaf, I have vaguely wanted to implement lenses in Clojure at one point, but haven't gotten around to it, and now I doubt that I'd know what the traversal stuff is, so probably wouldn't have done it, which would be sad, so maybe it's good that I didn't do it.
03:26shachafTraversals are the future.
03:27clgvbut until now I haven't seen an example where one of these monad implementations would improve clojure code. in the tutorials it was harder to read most of the time
03:28brainproxyclgv: because of having to setup the monad context, or what do you mean?
03:29clgvbrainproxy: I just read 3-4 tutorials briefly, yet. maybe it's the added indirection.
03:30brainproxyi think protocol-monads can possibly help w/ that a bit, but there is still a bit of a chicken-and-egg problem
03:30clgvadditionally, I have not seen a "Clojure success story with monads", yet ;)
03:31brainproxyi.o.w. to understand what it's doing for you, you need something of a mental model of what monads are all about in the first place
03:32jjidowhat are they all about?
03:32brainproxyjjido: encapsulating various plumbing patterns for moving data between functions
03:33clgvbrainproxy: where would *you* really see a need to use them in clojure in *your* projects?
03:33brainproxyclgv: sure.. so the project I'm working on has a really nasty control flow scenario
03:33brainproxyusing state-transformer and maybe monad and writer monad together seems to be helping
03:34clgvhumm, you cant sketch the scenario outline, can you?
03:34amalloyclgv: the `for` macro is a special-cased implementation of the list monad. -?> in contrib is a special-cased implementation of the maybe monad
03:35clgvamalloy: ah ok, in these cases they are manifesting implicitely
03:35brainproxyokay, so consider a uri pattern that looks like /api/[filter]/[item]/[collection]/[item]/[collection]/[item]...
03:35brainproxynow, assume that when trying to resolve the various hops between item,coll,item,coll...
03:36amalloythat's basically how it goes. monads are a useful tool for capturing and working with common patterns that come up even if you don't know about them
03:36brainproxyyou have diverse data sources that can spit back data which doesn't match up well between different kinds of collections and items
03:36amalloyi implemented a clojurey version of the io monad in jiraph, so that i could do computations that appear side-effecty on the database, but make them safe to re-do in case of partially-committed transactions
03:37clgvok
04:07thorwilwhere did -?> go for clojure 1.4?
04:09clgvthorwil: it's still in core.incubator lib
04:10clgvI'd wish that it was included in clojure.core by 1.5 - but there is no info on that
04:11thorwilok. it seems impossible to find it via google. even when calling it nilsafe
04:12clgvthorwil: lookup the core.incubator lib^^
04:12clgvthorwil: defnilsafe is the macro used to implement those threading macros
04:14_ulisesmorning folk
04:14_ulisesclgv: what TZ are you on? you seem to be here during my mornings :)
04:14clgv_ulises: GMT+1
04:14_ulisescool
04:16clgvthorwil: well, 1.5 will get when-> which tests for logical true during threading
04:18clgvthorwil: ah and (test-> (comp not nil?) ... ) would work it seems
04:20thorwilgood. whatever works that is less noisy then maybe-m
04:21clgvthorwil: currently I juest use -?> from core.incubator
04:21clgv*just
04:32otfrommorning
04:32otfromI'm guessing everyone here is *not* going to the conj.
04:37_ulisesotfrom: how so? is it happening like *right now*?
04:38clgv_ulises: tomorrow I think
04:39_ulisesah
04:39muhooit's EST time, so, tonight if you're in GMT-ish land
04:40muhooEDST, to be pedantic
04:41clgvmuhoo: huh. it says 15th and we have the same date :P
04:44otfrommuhoo: I thought the east coast US was back on EST
04:45clgvit's tomorrow for GMT+1 as well since it's a negative offset ;)
04:46otfromI figured anyone on here this time of the morning wasn't in NC
04:46muhooah, right, summer is DST, winter is not (reverse)
04:52thorwilwith the code in https://github.com/thorwil/tlog i can log in as admin and then the /admin will no longer redirect. but /admin then still does not use my handler, but delivers "Sorry, you do not have access to this resource."
04:56muhooare you sure the session is getting saved?
04:56muhooalso, note the :: in your realms
04:56thorwili'm not sure of anything. but if the session is not saved, wouldn't it still redirect?
04:57muhooauth realms must be fully qualified
04:57muhooso i wouldn't use ::, i'd explicitly call out where those realms are defined instead
04:58muhoonot ::admin, but :tlog.wherever/admin
04:59Raynesmuhoo: I've probably asked you this 400 times: are you going to the conj?
04:59muhooRaynes: sadly, no.
04:59muhooare you there already?
05:00RaynesWhy do people keep asking me that? It's a whole day before the conference even starts.
05:00RaynesRight? I haven't missed half the conference or anything, right?
05:00muhoobecause you can time travel too
05:00RaynesCause like 10 people have asked me if I was there already today.
05:00muhooas well as write haskell.
05:00RaynesThe Doctor isn't here right now.
05:04clgvbetter get going then ;)
05:05muhoospeaking of the Doctor, does rhickey still have that fourth doctor hair? i wanted to give him a scarf at clj/west.
05:06muhoohttp://en.wikipedia.org/wiki/File:Fourth_Doctor.jpg <-- conj keynote speaker
05:06thorwilmuhoo: :tlog.init/admin makes it work. thank you. all the examples are flat and no mention of this auth realm business
05:06maleghast*guffaw*
05:07maleghast"To the TARDIS!"
05:08muhoothorwil: if it's not explicit in the docs, maybe ask cemerick about it, or report it as a feature request to add it to the docs
05:08muhoothe examples assume everything is in one namespace. you've got what looks like an mvc-ish thing going there => trouble.
05:08clgvthorwil: it's more a namespaced keyword shortcut issue^^
05:10muhooalso, i don't know if he calls it a realm, but those keywords need to be namespaced
05:10clgvthorwil: you will have the exact same problem if you use that shortcut for namespaced keywords elsewhere. as a rule of thumb only use something like "::my-keyword" if they are only used in the same namespace - otherwise always fullqualify them
05:10thorwiljust the usual web pseudo mvc. though just today i wondered about going model -> database or persist and view -> respond
05:11muhootry it, see what fits the problem domain best, i guess.
05:15LicenserI wonder is there a good place to start with noir+pinot ?
05:18clgvLicenser: afair, you shouldnt use pinot anymore but the libs it was split to
05:18Licenserahhh sneaky
05:19Licenserclgv I read the article about that but thought it's still inside the smae library
05:19piranhaMaybe I'm wrong, but I had the impression that Datomic has some event/notification mechanism to notify you when certain data has changed... Am I wrong?
05:38Raynesantares_: Thanks for updating monger. I didn't even know you did it until I tried to push a commit just a second ago. :p
05:38RaynesIt's deployed.
05:38antares_Raynes: sweet
05:39antares_this reminds me, we need to update it again, although I guess 1.3.4 fixes are not relevant for refheap
05:40Raynesantares_: When are we going to write a rethinkdb driver together? :D
05:43antares_Raynes: it is hilarious that a company called RethinkDB is just a me-too mongodb clone :(
05:43antares_and by hilarious I mean sad
05:43Raynesantares_: From what I've seen, it appears to be better than mongodb in most of the areas where people complain about mongodb.
05:43RaynesAm I wrong?
05:44antares_possibly but they are still a me-too player now
05:44RaynesI don't know what that means. Is it anything like shitting rainbows?
05:45antares_yes but you shit them inside
05:45antares_so, it makes you über cool but nobody will notice
05:53nickikIs there a UseCase where I would prefer Mongo/rethink over Datomic? I do not know Mongo or rethink very well
05:54RaynesThe case where you want an open source database.
05:55nickikRaynes, I think Mongo has some more support for geodata
05:55nickiksome pre defined querys
05:56nickikor something
06:28Chironany clojure lib that allows for something like Scala match case ?
06:29Anderkenthow is scalas match case different from clojures match ?
06:30Anderkent,(doc match)
06:30clojurebotI don't understand.
06:30Anderkentgeh
06:30antares_Chiron: core.match
06:30antares_Anderkent: destructuring is very limited in scope compared to pattern matching in Erlang or Scala
06:31Chirondoes it worth to introduce it if i need match/case only two or three times in my code ?
06:31antares_Chiron: it's up to you, I don't think it is a huge dependency by any means
06:32Chironis it possible to use core.match were cases should match class Types ?
06:32Chironsomething like (instance?)
06:37orbidansmhello mate
06:38antares_Chiron: see core.match documentation, they supposed to have it
06:39Chironok . thanks :) amazing clojureworks btw
06:39orbidansmI'm using ERC Version 5.3 with GNU Emacs 24.1.50.1 (i486-pc-linux-gnu, GTK+ Version 2.20.1, multi-tty) of 2012-09-18.
06:52antares_Chiron: you mean, clojurewerkz? thanks!
06:52Chironoh, clojure.match couldn't be used with AOT :/
08:22ro_stwhat's the idiomatic way to respond 404 with noir?
08:23_ulisesro_st: there's a bunch of response helpers in noir I think
08:27ro_stjust searched the noir source. no helper
08:31jweissanyone got a link to how to destructure nested maps? i found {{:keys [bar]} :test} but that seems to only allow you to assign names to values at one level of the structure.
08:35jweissah here we go http://java.dzone.com/articles/clojure-destructuring
08:35jweiss{{bar :bar} :test}
08:35jweissweird, never saw that syntax before.
08:35Anderkentro_st: (noir.statuses/get-page 404) ?
08:36Anderkentro_st: or just set the response status code and not provide any content, it should do the statuses/get-page automatically then
08:37ro_stgoing to try that, Anderkent: {:status 404}
08:42KototamaI specified [org.clojure/clojure "[1.4.0,1.5.0)"] in project.clj but lein2 uses clojrue 1.5 beta1 nonetheless, any ideas?
08:46ro_stAnderkent: it just serves up an empty 404. so i guess i need to manually respond with 404 and the statuses/get 404
08:48ro_st(response/status 404 (statuses/get-page 404)) works
08:48ro_stthey couldn't just make (response/404) ? tsk.
08:49Mr_Bondyou could suggest a patch to them :)
08:50Mr_BondI'm sure they are not hostile against improvements
08:50ro_sti had to write 404, like, twice. like, DRY, y'know.
08:50Mr_Bonddo they also supply you with free finger-massages?
08:50Mr_Bondfrom the excessive keyboard typing?
08:51ro_stno, but they should, now that you mention it
08:51Mr_Bondyes :)
08:51ro_st(noir.perks/finger-massage!)
09:10ChironHi, any better ideas how to write this in idiomatic Clojure ?
09:10Chironhttp://pastie.org/5377160
09:15joegalloHard to say, without seeing cond-1, cond-2, and action-2.
09:15_ulisesChiron: what joegallo said
09:15danlarkinyeah what joegallo said
09:15joegalloyeah!
09:15joegallo:D
09:16Chironcond-1 and cond-2 are (instance?)
09:16Chironaction-1 returns a list
09:16joegalloit is not idiomatic to call instance with 1 argument... :)
09:16joegallos/1 argument/0 arguments/
09:17_ulisesChiron: perhaps better if you paste your actual code? (if you can)
09:17joegallounless this is the code for launching ze missiles, how about you just paste more?
09:19Chironhttp://pastie.org/5377198
09:19Chironcond-1 and cond-2 are calling to instance? functions
09:24orbidansmcan you use if instead of cond ?
09:30Chironproperly yes
09:30LicenserOkay I'm back to bug you all gain, I'm trying to get a little web applicaiton to run and am truely surprised how much walls I run into o.o. Is noir and the related clojure script libraries still maintained or is there a new thing to go with?
09:31winkLicenser: do you have a special problem? because I started a new noir app with 1.4 last week and it worked very well
09:32Licenserwink I try to get noir+noir-cljs to work and it all keeps failing stacktraces, something with a hiccup file not working
09:32winkLicenser: err, ok, I used no clojurescript, sorry, misread
09:32Licenser^^
09:33LicenserI was a bit surprised since people are soo happy with clojure
09:33zodiakLicenser, not to sound stupid here but, have you tried running through the clojurescript quickstart ?
09:34zodiakbecause it surely doesn't mention noir ;P
09:34zodiakas with all things comp sci, take it all back to first principles if you hit a roadblock
09:34Licenserzodiak I know the clojure basics and clojurescripts basics
09:34zodiakgood show, fling up a stracktrace on pastie then
09:35Licenserzodiak my question is not about the stacktrace, I figured the problem itself (it's just a version incompatibility), more about the state of the libraries or if there is something new around since I looked last :)
09:36zodiakoh .. spiffy :)
09:36zodiakwell, ~personally~ I use compojure+moustache so.. I maybe the wrong person to answer
09:36maleghastLicenser: I've had a lot more luck leaving Noir out of the equation and just using Comojure, fwiw
09:36zodiakmaleghast, +1 internets
09:37maleghastzodiak: I thank you… ;-)
09:37LicenserComojure = compojure?
09:38zodiakLicenser, yes
09:38maleghastLicenser: yes, my typing sucks, what can I tell ya?
09:38Licensermaleghast mine too ;) just wanted to be sure
09:38Licenserbut I guess I crawl back under my erlang rock for now
09:38maleghastLicenser: no worries
09:38Licenser^^
09:39maleghastLicenser: Erlang, eh? And I thought I had some esoteric language interests...
09:39maleghast;-)
09:39patrkrishi folks, i'm trying out reducers in Clojure 1.5 with the following code: https://www.refheap.com/paste/6668
09:39patrkriswhy do I get an OutOfMemoryException when running (reducerslib)?
09:39Licensermaleghast ^^ all the other parts of the applicaiton are written in erlang, I was pretty much interested in the clojure/clojurescript integration
09:40Licenserbut since I fail at making that simple I guess the energy to getting it all figured out is bigger then the energy saved for me in this case
09:40maleghastLicenser: Fair enough - if I had the time and / or a business need I think that I would enjoy ClojureScript too, but as it is I've not had the opportunity to use it yet.
09:40maleghastIf you want a nice, terse syntax for generating JS, why not look at Coffee?
09:41Licenser*nods* would have loved to, since I adore clojure but well :) I hardly can expect other contributors to fight with stuff when I have already trouble with it :P
09:42zodiakugh.. coffeescript is jst.. horrible :)
09:42zodiaktell me, honestly asked, how do you ~sanely~ debug coffeescript ?
09:42zodiak(assuming something slips past tdd etc ;)
09:42maleghastzodiak: *raised eyebrow* That's fair, I guess, but seeing as nodeJS can run it interactively I think there are a few ways
09:44zodiakmaleghast, that's what is stopping me adopting it. debugging. I mean, I can compile down into js, find the bug in the js and then reverse back into the cs
09:44zodiakbut.. it feels... nasty
09:45zodiakI am open to other ways :)
09:45niclHey all, I've just started my first serious Clojure application - a compojure app which exposes an API to create and store books (along with reviews, and some meta data - author, isbn etc.)
09:46niclI have a few questions: 1. what are the recommended libraries which abstract sql interaction - I've seen korma. Is there anything else I should be aware of?
09:47maleghastzodiak: Yeah, I can see that… As I thought, you can do it with Node, see the second answer, here -> http://stackoverflow.com/questions/11068023/debugging-coffeescript-line-by-line
09:47Licenserzodiak it's doable but not pleasent
09:47nicl2. SQL or Mongo ? - I've experienced with SQL but haven't used a noSQL db before. This is a purely personal/hobby project so it would be nice to learn something new in mongo, but is this widly inappropriate / what do people suggest?
09:47Licensernicl SQL
09:47nicl(this might be a hopeless/too broad question)
09:47Licenseror Riak
09:47zodiakmaleghast, *reading*
09:48Licensernicl and if you use SQL please go for postgresql
09:48patrkrisnicl: Datomic ;) http://datomic.com
09:48zodiaknicl, clj-record if you want activerecord instead of data-mapper ;)
09:49niclpatrkris: ha - I guess that would be appropriate although I am slightly scared by it!
09:50zodiakmaleghast, ta for the link.. time to play about with it and see how it shapes up :)
09:50patrkrisnicl: yeah, me too... but it's beautiful
09:50Mr_Bonddoesn't ACID transactions in datomic pretty much kill the performance it gains over regular rdbs?
09:51clgvMr_Bond: I thought ACID in an immutable db is easier thus cheaper, no?
09:51Mr_Bondno
09:51niclLicenser: not sure if you are suggesting I use SQL, or that there is an actual library called SQL for interacting with an SQL db?
09:52Licensernicl I suggest not using mongo actually, there are many scarry things to be read about that
09:52Mr_Bondto be ACID compliant, the write has to be commited to disk before the transaction is finnished
09:52Mr_Bondcommited as in fsync
09:53clgvMr_Bond: really, so in-memory dbs cannot be ACID compliant?
09:53Mr_Bondclgv: that is correct
09:53algernonI'd suggest using mongo, because for a hobby project, when one wants to learn something new, it's perfect. (and monger has great docs to boot, better than korma's imo)
09:54Mr_Bondit's the only way to guarantee consistancy from the databases perspective
09:54maleghastCertainly MongoDB is a powerful, stable product that no one should be frightened of, but like all tools it has its uses, and also there are things for which it is not fit.
09:54Mr_Bondit's like if you turn off fsync in mysql, it's dirt fast
09:55patrkrisMr_Bond: but why do you think it will perform worse than RDBMS? because of the extra layer added over the storage service (datomic on top of e.g. DynamoDB or PostgreSQL)?
09:55maleghastnicl: I suggest that if you are not in any danger of losing any money then have a go with Mongo - it's well suited to the domain that you describe, it's fast to get up and running and you'll learn something new.
09:56Mr_Bondpatrkris: I didn't say it would, I just thought it would kill most of the performance gains nosql typically has
09:56devn"if you're not in danger of losing money, use mongo!"
09:56devn^-new mongodb tagline
09:56Licensermaleghast how about riak? It's also a pretty awesome K/V store
09:56Mr_Bondcommon issues with mongodb, is sharding on wrong keys (having data moving about too much), and scaling out when it's too late
09:57Mr_Bondif you avoid those, and follow guidelines, you'll moste likely be fine
09:57Mr_Bondand what devn said
09:57Mr_Bond:)
09:57maleghastLicenser: I hear it is, though what I hear is that it's particularly well suited to very high traffic writes, due to its design choices
09:57patrkrisMr_Bond: I think Rich says that datomic is not good for massive amounts of writes
09:58patrkrisbut its fast for reads and provides ACID
09:58Licensermaleghast it scales very well and has a nice data integrety scheme
09:58patrkrisand that's by design
09:58zoldarI don't know if that still holds for current release, but mongodb has some insane default settings with regard to handling write operations
09:59Mr_Bondpatrkris: yes, but reads are typically not slow in rdbs either
09:59maleghastdevn: Hardly, there are large organisations using it in anger, the trick is to not use it for everything and to use it well, like any tool. My point to nicl was that he / she may as well learn something new (be it Mongo, Riak, Cassandra, RethinkDB) if there is no financial or business risk.
09:59niclwow - sounds like I will just have to decide what I want to learn.
09:59niclthere is no financial risk - it is purely a spare time/learning thing
09:59maleghastnicl: precisely
09:59Mr_Bondgo for it :)
09:59patrkrisMr_Bond: right... but I guess (I don't know much about this) scaling is harder
09:59niclthanks for all the advice
09:59maleghastWhy not hook it up to all of them one after the other and see which one you like best?
09:59Licenser:)
10:00Mr_Bondpatrkris: yeah
10:00niclmaleghast: if I get the time!!!
10:00maleghastDon't forget ArangoDB :-)
10:00algernonnicl: use whatever has the best docs, if you want to learn :)
10:02zoldarfor the record, here's an experiment that somebody did some time ago on mysql: bypassing the whole sql parsing layer and talking straight to ndb api: http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html
10:03mtdotfrom if it's on-topic, I have a random question about the upcoming London Clojurians hackathon's structure: do we come and work on our own projects, or one that's given to us on the day, or something in-between?
10:13niclmtd: when is the hackathon?
10:17orbidansmhackathon is like coding dojo, I guess. But longer
10:18orbidansmI havent been to any clojure hackathon
10:19mtdnicl: Dec 8, Tower 42 - http://www.meetup.com/london-scala/events/91346712/
10:19mtdorbidansm: so...like a dojo, there is an assigned project, right?
10:19marutksyes
10:19niclmtd: thanks
10:20mtdnicl: np
10:54otfrommtd: are you talking about Hack The Tower?
11:00otfrommtd: I don't know if there is a "set problem" as such, but it is focusing on building webistes
11:00otfrom*websites
11:42tgoossenshi. i'm just thinking. If i have "pieces" ([x y] coordinate) on a "board". One way to do this is to have define a board. {:pieces #{}} which has a set of pieces
11:42tgoossensi write all the functions to add pieces and do some useful stuff with this
11:43tgoossensbut then
11:43tgoossensi want it to happen in constant time
11:43tgoossensso
11:43Anderkentwhy do you want it to happen in constant time?
11:43tgoossens:pieces must now be a map of vector->piece
11:43Anderkentoh sorry i thought that was it, continue :P
11:44wingy_ibdknox: good LT update automation :)
11:44tgoossens:)
11:44tgoossensthen
11:45tgoossenswhen i compare it how i do it in java (this was part of an assignment in a course on OO but now i'm trying to do it in clojure (for myself))
11:45tgoossensthen
11:45tgoossensboard.hasPiece(Piece)
11:45tgoossensand all other stuff could still be used
11:45tgoossensbut I don't see how i can (in a clean way)
11:45tgoossenssuddenly adapt everything to the map
11:46tgoossensthat suddenly was introduced instead of the set
11:46tgoossens-- that ends the question
11:47tgoossens(note: i've only been exploring clojure for one month now. my only experience is OO so far)
11:47tgoossens(got interested into it by accident :D and so far i love it)
11:47Anderkent,(vals {[0 1] {:type :rook} [2 3] {:type :king}})
11:48clojurebot({:type :king} {:type :rook})
11:48Anderkentyou can look at a map as if you were looking at a set, if you just want to check whether something is in a map
11:49tgoossensWhat i'm trying to ask is. Do i have to "rewrite" all my functions, do i "write new ones", or something else?
11:49TimMcWell, you can for the keys.
11:49TimMctgoossens: If you change the backing store, you'll need to change the implementations of the functions, but probably not their contracts.
11:50tgoossensthe typical argument from an oO-fanatic would be now: "that it is a set or a map should be encapsulated". And having only experience with OO, i cannot deny this argument
11:50tgoossenswhat am i not seeing?
11:51Anderkenta set or a map have completely different meanings
11:51TimMcA user of your fns shouldn't know whether it's a set or a map, but your fns absolutely *should* know.
11:51Anderkentany function that directly interacts with the set/map will have to be updated
11:51Anderkentbut after it is it can behave in the same way as before
11:52Anderkentthus the fact it is a set and/or map is hidden from anyone who uses the function
11:52clojurebotAlles klar
11:52TimMc~botsmack
11:52clojurebotbotsmack is headdesk
11:52tgoossensmmm
11:52TimMcclojurebot: forget botsmack |is| headdesk
11:52clojurebotI forgot that botsmack is headdesk
11:52TimMc~botsmack
11:52clojurebotbotsmack is headdesk
11:52tgoossensnot quite getting it (yet)
11:52TimMcDamn inference engine.
11:52Anderkentlook back at your board.hasPiece, it used some kind of set, map or array as a backend, right?
11:52tgoossensyes
11:53Anderkentif you changed the backend data type, you would have to change board.hasPiece
11:53TimMctgoossens: Think of it algebraicly: (has-piece (make-board ...) ...) should return a certain answer independently of the implementation.
11:53tgoossenscorrect
11:53tgoossensoh
11:53Anderkentbut anything that uses hasPiece does not change
11:53Anderkentit's the same way here - your (has-piece) function has to be changed
11:53Anderkentbut anything that calls (has-piece) does not.
11:53clojurebotIt's greek to me.
11:53AnderkentDoes that make sense?
11:54tgoossensmmyes
11:55tgoossensit was just
11:56tgoossenshmm
11:56tgoossenscould multimethods help here?
11:56tgoossensdispatch on collection type
11:57tgoossensor is that just bullshit
11:57tgoossensif for some reason
11:57tgoossensmultiple forms of board are present
11:57tgoossensbut then.. why would that happen hmm
11:57tgoossensmaybe i'm seeing problems where there aren't any
11:59Anderkentif you want to support multiple types of boards
11:59Anderkentthen protocols are probably what you want to use
11:59tgoossensbecause of the speed?
11:59TimMcNah, protocols are restrictive.
11:59tgoossensor because of the "interface-like" behaviour
11:59TimMcMultimethods are far more flexible.
12:00tgoossensi like multimethods so far
12:00tgoossensseem quite powerful
12:00tgoossensbut read that they are slower (because of the dynamic dispatch)
12:00tgoossensbut that speed
12:00Anderkentthe speed doesn't really matter 99% of the time
12:00tgoossensis not relevant here
12:00tgoossensanderkent: as you say. that is only in critical systems :p
12:02firesofmayHi, I am looking to design LOGO programming environment in clojure. Can anyone give me pointers on how to get started on it? Like the libraries I should look at?
12:02firesofmayIts just to learn/fun.
12:03tgoossensps: it really nice i don't have to invent my own type everytime ovr again :p
12:04mtdotfrom: yes, I was wondering about "Hack the Tower". I've got a website idea I'd like to build, and would love to do it in clojure with some people working on similar problems sitting next to me to bounce ideas off of, and vice-versa, but I don't want to waste anyone's time and money if the purpose of that meetup is to hack on salesforce.com's API or similar...just wondering what the structure was planned to be, as I'm not a hackathon regular.
12:09tgoossensAnyone heard of java "Future"
12:09tgoossens?
12:10Anderkentyes, similar things in clojure are futures or promises
12:10tgoossensa friend told me a couple of minutes about it
12:10tgoossensnever heard of it
12:12tgoossenslooks ok to me
12:13mycelloandifiresofmay: take a look over here http://clojure-libraries.appspot.com should be a graphics section
12:14tgoossensDo i get this straight? Promises are the same as futures. but you can "deliver" later on a value? instead of defining what thread will do it?
12:14firesofmaymycelloandi, okay thanks. I was just checking out quil. I am wondering if there is something that will help me dynamically interact and generate. Will check it out. :)
12:15holohi
12:15mycelloandifiresofmay: you could also use html5 canvas or svg via clojurescript
12:16firesofmaymycelloandi, I see. any advantage of doing/using that?
12:16mycelloandieasy to say "hey check this out" and just send a url :-)
12:17Anderkentwith promises, you create it first and give it to someone other thread. Then at some point you deliver the promise, saying "You can now use this value"
12:17tgoossensok. then i got it right :)
12:17tgoossensthanks
12:17Anderkentwith futures, you ask some other thread to run computation for you, and wait for the result
12:17holowhen i run a script with `lein run -m script.spam`, i get a "java.lang.ClassNotFoundException: clojure.string" if i remove an unneeded library. if i put it there with a require (and i don't even use it) the script runs perfectly. do i need to clean something?
12:17tgoossensso futures are more for thread-pool like stuff / executors?
12:19firesofmaymycelloandi, Hmm. Point taken.
12:25pjstadigif anyone it at the Sheraton for the conj and wants a chocoroom, stop by the board room
12:25danlarkinstop giving away our chocorooms paul
12:27winkI'm not sure I want to ask for details.
12:27egghead:)
12:33alexnixonwhy doesn't LazySeq have a .toString method?
12:33tgoossensthink about what would happen
12:34tgoossensif it is an infinite sequence
12:34tgoossenslike (repeat 5)
12:34tgoossensnot sure that "is" the reason
12:34alexnixonthen "here be dragons" as always with lazy sequences
12:34tgoossensbut it makes sense to me
12:34alexnixon,(str (doall (lazy-seq [1 2 3])))
12:34clojurebot"clojure.lang.LazySeq@7861"
12:34alexnixon,(str (seq (doall (lazy-seq [1 2 3]))))
12:34clojurebot"(1 2 3)"
12:35alexnixonseems odd
12:35Anderkentwell, why the doall?
12:35Anderkentdoesnt seem odd without doall at all :)
12:35alexnixonoh, I was just playing (to see whether it returns a realized lazy seq, or a seq)
12:36alexnixonand to point out that the "your sequence could be infinite" doesn't really apply when your lazy seq has already been realized
12:36Anderkentbut you don't want the output of str to change depending on whether the seq was realized or not
12:37ebraminioHi, how I can use map here? (merge* @fy @fz) to (merge* (map #(@%) fy fz))
12:38alexnixonno, I agree you don't. I'm wondering why it doesn't just realize the seq, and just allow users to call .toString on an infinite sequence and shoot themselves in the foot
12:38ebraminiomerge* is a custom (user defined) function and fy fz are two futures here
12:39Anderkentalexnixon: because you don't know whether a lazy seq is infinite or not, and you might want to call str on infinite seqs as well (f.e. in a debugger)
12:39Anderkentebraminio: (merge * (apply deref fy fz))
12:39Anderkentshould be map
12:39Anderkentnot apply
12:40Anderkentbut basically @x => (deref x)
12:41alexnixonthe debugger argument is a good one, but I don't think the "you don't know if it's infinite or not" is. We let users (apply hash-map col) when col could be infinite.
12:44mefistoso, if I want to implement something that matches keywords to functions (as in, if we get this keyword, call this function, as defined in a map or something like that) do I need to make a macro for that?
12:44ebraminioAnderkent, thanks a lot! :) can you help me a bit about it? when i write code i get this error Don't know how to create ISeq from: clojure.core$future_call$reify__5684 I guess (apply ...) is lazy, am I must (into [] x) it?
12:44Anderkentalexnixon: the expectation is that (str x) should be safe to do on any x
12:45Anderkentebraminio: sorry, i said lower: it should be map. (merge* (map deref fx fy fz))
12:47Anderkentmefisto: you can have functions in maps, but if you're just dispatching on a keyword you might want multimethods instead
12:47Anderkent,((:my-str-keyword {:my-print-keyword prn :my-str-keyword str}) \A \B)
12:47clojurebot"AB"
12:48alexnixonAnderkent: then why not (str (range)) => "(0 1 2 3 4 ..."
12:49alexnixonperhaps I should just use prn and not worry about .toString
12:49mefistoAnderkent: ok, thanks!
12:49Anderkentalexnixon: what if each element is very costly? say you have a lazy seqs of files on remote server... How many do you fetch? What if they have side effects?
12:50ebraminioAnderkent, Sorry again, I am getting this "Wrong number of args (1) passed to" how I can fix it?
12:51Anderkentebraminio: (apply merge* (map deref fx fy fz)) . Sorry! I knew I wanted apply there.
12:51alexnixonAnderkent: then I'd argue that you shouldn't use str without understanding that you'll realize some portion of your sequence. If you don't want that, don't use str
12:53AnderkentThat means str is suddenly dangerous to use and I can't just print stuff in a repl. Bad cost just to have (str ...) instead of (str (seq ...))
12:54Anderkenthonestly I'm surprised prn does evaluate lazy seqs
12:55ebraminioAnderkent, oh great, but very sorry again, I am getting "Don't know how to create ISeq from: clojure.core$future_call$reify__5684"
12:56alexnixonAnderkent: so what about this: (let [x (range) y (seq x)])
12:56ebraminioAnderkent, (apply merge* (map deref [fy fz]))
12:56ebraminioAnderkent, thanks a lot :)
12:56alexnixonAnderkent: if you don't call .toString on y, things are fine. If you do call .toString on y, you go OOM
13:01tgoossensi must admit. The first time i wanted to print lazy sequences. I was quite confused why it didn't work
13:01alexnixonI'm actually confused by that example - how do you explain this? &| (let [x (range) y (seq x)] (realized? x)) |&
13:01lazybot⇒ true
13:02ebraminioAnderkent, http://imgs.xkcd.com/comics/logic_boat.png as a gift for you :)
13:02TimMc&(let [a (atom nil)] (reset! a a) a)
13:02lazybotjava.lang.StackOverflowError
13:04TimMc^ There are other things that can't be printed safely, by the way.
13:04tgoossenssense it makes none? :p
13:04TimMcIs that a bug? I don't know.
13:04Anderkentalexnixon: (seq x) realizes the first element of x if i recall correctly
13:05alexnixonAnderkent: that may be, but realized? should apply to the whole sequence
13:06alexnixonat least that's my understanding of it
13:06TimMcWait wait wait, since when does lazybot have this &| [1 2 3] |& inline eval syntax?
13:06lazybot⇒ [1 2 3]
13:06AnderkentI think there's a difference between 'lazy as a contract' and 'lazy as an implementation detail'
13:06Anderkentbut I might be wrong/confused
13:07Anderkentseq's are lazy of the 'implementation detail' kind, so they're presumed safe to print
13:07Anderkentlazy-seqs are lazy of the 'I told you I'm lazy' kind, so they aren't safe to print
13:07TimMcI wouldn't say that.
13:07AnderkentMight be wrong her e:)
13:07alexnixonAnderkent: even though assuming that a seq is safe to print is dangerous
13:07alexnixonsee my example above
13:07TimMcAn infinite seq is contractually lazy. It wouldn't make sense any other way.
13:07Anderkentsure you can make things that break the expectations
13:09raekit's interesting that (str some-seq) actually realizes it...
13:10AnderkentTimMc: can you make an infinite seq without using lazy-seq somewhere?
13:10raekI think it is realized because toString uses its hashcode
13:10seangroveHey all, I've been working in Clojurescript for awhile now, have some questions
13:10raekAnderkent: sure, you could define a new ISeq (that, for example, returns itself when you call rest on it)
13:10seangroveI would like to write a macro that will read from some template files locally and insert them as strings in the clojurescript code at compiletime
13:11alexnixontrying to keep this on track - my proposal is that it's more consistent, and more in line with the "principle of least surprise" for lazy sequences to have a .toString method
13:11seangroveJust want to make sure I'm thinking of this rigth with cljs - macros will run at compiletime, and therefore have access to the file system, right?
13:12TimMcalexnixon: I think a more appropriate track is to look at how prn handles lazy seqs.
13:12Negdayenseangrove: yep, should be so.
13:12TimMc(The whole print family of fns.)
13:12seangroveNegdayen: Thanks, cljs sometimes causes a bit of circular thought for me
13:12Negdayen(that's assuming cljs still uses clojure macros--should be so)
13:19alexnixonTimMc: (str (range 0 2)) => "clojure.lang.LazySeq@3c2". (pr-str (range 0 2)) => "(0 1)"
13:20AnderkentI think it's definitely surprising for .toString to realize lazy-seqs, but then again I find it surprising pr does it.
13:20alexnixonTimMc: (str (range)) => death. (pr-str (range)) => death.
13:20alexnixonso it seems that calling .toString on a lazy sequence *does* realize the whole thing, but also prints garbage
13:21Anderkentin which case it manages to combine the worst of both cases
13:21alexnixonAnderkent: yep :-(
13:21alexnixonAnderkent: and bolsters the argument for giving clojure.lang.LazySeq a .toString method
13:23alexnixonah, and of course Stuart Sierra has gotten there first: https://groups.google.com/forum/?fromgroups=#!topic/clojure-dev/F68GRPrbfWo
13:23Anderkent(defn prange ([] (prange 1)) ([n] (prn 'Realized' n) (cons n (lazy-seq (prange (inc n))))))
13:23Anderkentis useful for exploring that
13:24Anderkent(should be double quotes around realized, of course)
13:24Anderkentand indeed it realizes all of it - try (str (take 10 (prange))
13:25alexnixonyeah as the email above (and raek pointed out) it's because hashCode is called
13:26alexnixonso sensible behaviour is either 1. give lazy-seq a toString method which *doesn't* realize the seq, and prints garbage. 2. give lazy-seq a toString method which *does* realize the seq, and prints it
13:27Anderkentyep
13:30alexnixonwell at least that's the issue clarified, even though I'm not sure which of those is the better option
13:30alexnixonhave to go now - thanks for the help
13:30tgoossenseasy question: how to turn "nil" into "false"
13:31tgoossens(other than using if)
13:32alexnixon(defn truthy [x] (comp not not))
13:32Anderkenttgoossens: what should it do on not-nill values?
13:32tgoossenswel
13:32tgoossens*well:
13:32Anderkentfalse on nil true on everything else?
13:32tgoossensyes
13:32tgoossens(def haspiece? [{:keys [pieces] :as board} piece]
13:32tgoossens (pieces piece))
13:33Anderkent,(not (nil? nil))
13:33clojurebotfalse
13:33Anderkenthm
13:33pyrtsatgoossens: (doc boolean)
13:33tgoossensthats it!
13:33tgoossensthanks
13:33pyrtsaOften not needed, like you probably know.
13:34Anderkentyou dont want boolean since it will give you false on false.
13:34Anderkent,(not (nil? false))
13:34clojurebottrue
13:34Anderkent,(boolean false)
13:34clojurebotfalse
13:34pyrtsaThen (comp not nil?)
13:35tgoossens,(boolean nil)
13:35clojurebotfalse
13:40tgoossenswhen i rewrote my OO project from last year in clojure. I'm going to mindblow the professor (or so i hope :p )
13:41akhudektgoossens: is the rewrite shorter?
13:41tgoossensi just started today :p
13:41tgoossensbut for the functionality i rewrote atm
13:41tgoossensyes
13:42tgoossensits just. i find it a real pity that the coming years everything will be in the theme of "OOP": "OO is the best, and all you should do is OO"
13:42tgoossensand I would like an opinion on that
13:42tgoossensbut i'll first create an example
13:42tgoossensmany people in my study
13:43tgoossenshave heard ONLY of OO. Don't event know that there are other ways to program
13:43tgoossensthats just lame
13:43tgoossensand I want to try to change that awareness a bit
13:43tgoossens(not in the shortterm, but in the longterm)
13:44akhudektgoossens: it takes time for popularity to shift. The lack of popularity for functional languages has been a hotly debated topic for many many years
13:44akhudeksince the first lisp probably :)
13:45tgoossensany advice on what I should talk with my professor about?
13:45tgoossensakhudek: probably yes. All i want for now is the professors opinion
13:46tgoossens(ps: university of leuven, belgium)
13:47akhudeknot particularly. If you want his opinion just ask and listen. Don't discard what he says idly.
13:47scriptorjust ask him what his opinion is on functional programming
13:47scriptorbefore you show off your code to him
13:47tgoossensyou're right
13:47scriptorI'm sure he's had plenty of students trying to impress him before
13:47Iceland_jackDon't be surprised if he doesn't care that much
13:48tgoossenswhy would that be?
13:50madsytgoossens: If anyone tries to sell you OO as some ultimate method, show them http://c2.com/cgi/wiki?GoldenHammer
13:51akhudektgoossens: profs come in as many variations as people elsewhere. Some are just interested in their narrow domain and may not find the OO vs functional debate interesting. Ohter profs love questions like that and will happily spend time talking to you about it and perhaps trying to convince you of their point of view. You won't know until you talk to him/her.
13:52tgoossensmadsy: lol
13:52tgoossensakhudek: i'll just ask his opinion. and see how it goes :)
13:53Iceland_jackThat's a good plan
13:53scriptoralso, stay humble
13:54Iceland_jack^^
13:55tgoossensoh. don't worry about that. I've been interfering humbly in a professors teaching before succesfully ;)
13:56tgoossensand now he mentions what i told. in his classes :)
13:57tgoossensand now a confession:
13:58tgoossensit has only been a month since my first contact with functional programming and clojure in particular
13:58tgoossensbefore that i was "OO-fanatic" ("oo" is the best)
13:58tgoossensbut i prefer to become more pragmatic :)
13:59Iceland_jackIt sounds like you're still forming your opinions and preferences
13:59tgoossensyes
13:59tgoossensabsolutely
13:59Iceland_jackso I'd think carefully before becoming too dogmatic either way
13:59Iceland_jackNot saying you are, but it's not unheard of
13:59TimMc,{(range) 5}
14:00clojurebot{(0 1 2 3 4 ...) 5}
14:00TimMc,(hash-map (range) 5)
14:00tgoossensyes. thats why i'm learning about FP on myself
14:00clojurebotExecution Timed Out
14:00tgoossensand OO will be in class
14:00scriptorhmm...
14:00Iceland_jackGlad to hear that
14:00tgoossensbut that doesn't rule out
14:00TimMcIceland_jack: The zeal of the convert?
14:01tgoossensthat i want the opinion of my prof :)
14:01ChironHi, i don't really understand tree-seq (tree-seq vector? seq [[1 2 [3]] [4]]) would you please explain to me its output ?
14:01Chiron, (tree-seq vector? seq [[1 2 [3]] [4]])
14:01clojurebot([[1 2 [3]] [4]] [1 2 [3]] 1 2 [3] ...)
14:01tgoossensbut as you said
14:01tgoossenscurrently sstill forming
14:01tgoossensand a lot of "quoting" of the talks i saw about clojure & fp
14:02tgoossens(even overexcited perhaps)
14:04tgoossensg2g bye!
14:14bobo_doesnt it work to modify an atom if you do it in another thread? just calling my function seems to work. but submiting it to a executor doesnt seem to work?
14:15TimMcbobo_: It's not really clear what you're asking. Wht did you do, what did you expect, and what actually happened?
14:16bobo_I have an atom, i have a function that resets the value. When i call that function, the value of the atom resets.
14:16bobo_but when i submit the function to a scheduledexecutor, nothing happens
14:16bobo_ive been away from clojure for way to long
14:16TimMcSo you have any evidence the fn is actually being run?
14:16TimMc*Do
14:17bobo_hm, good point
14:24piranhaI've retrieved contrib.datalog from old monolithic contrib, which is fun - could be used as an in-memory db for cljs apps, but it seems to be quite slow :(
15:06`foguspiranha: There are many reasons why it's slow, the least of which is that it does a lot of set operations
16:03seangroveI can't seem to get the google closure hash library working in clojurescript properly: https://gist.github.com/4074776
16:03seangroveIt's saying the required namespace was never provided
16:04seangroveIf I just require [goog.crypt :as crypt] instead of [goog.crypt.Md5 :as md5] it works, but the md5 methods aren't there
16:07ChironHi, list comprehension is clear choice , but any other ways ? http://pastie.org/5379078
16:08znDuff"get the coll-3 of each coll-2 of each coll-1"?
16:09znDuffChiron: An example that's complete enough to be independently runnable would be helpful. Otherwise, it's not clear what the "coll-3" of a "coll-2" _is_.
16:09Chironcoll-1 has a seq 'call-2' . each element in coll-2 has a seq named 'coll-3'
16:10znDuffChiron: ...also, if you're doing this for side-effects, which the do-some-thing name implies, you should probably be using doseq rather than for.
16:10znDuff...
16:11znDuffChiron: It's still not clear. Let's go at it from a different direction: How does what you have already differ from what you want?
16:12Chironthe current for works (which it is something like Java's nested loops) . i'm only wondering how list comprehension could be done in Clojure in another way
16:13znDuffChiron: "list comprehension" is Python terminology -- it's not exactly common here.
16:13Chironhttp://clojuredocs.org/clojure_core/clojure.core/for
16:14znDuff*shrug*. Even so, I haven't seen it used in Clojure outside the documentation, and people coming from Python.
16:15znDuff...anyhow -- other approaches. *shrug*. You can look at what the for macro expands to, of course.
16:15Chironthank you
16:25seangroveOk, after digging around in the goog-closure jar, it looks like none of them actually include the md5 library
16:26seangroveanyone know if it's fundamentally incompatible, or just omitted for some reason?
16:27wei_is there a clj socket library? or do people just use java sockets?
16:29wei_^ I see there's a wrapper called pocket
16:29nightfly_I just use Java sockets but: https://clojars.org/search?q=socket
16:31zodiakhrm. stupid question, in vimclojure, how do I map \rt to run all tests for the project, not jst the tests in the current buffer ?
16:32lkjklkjjIf I have a java array #<long[] [J@75da931b> How do I stop class cast exception when calling (java.util.Arrays/asList )
16:32lkjklkjj[J cannot be cast to [Ljava.lang.Object
16:33raeklkjklkjj: does this work? (let [^:longs array (expression-yielding-array)] (java.util.Arrays/asList array))
16:34raeksorry, "^longs"
16:35raekperhaps this works too (let [^"[J" array ...] ...)
16:35lkjklkjj^no :(
16:39lkjklkjjThis works fine as its a list of Object
16:39lkjklkjj(java.util.Arrays/asList (.toArray (java.util.ArrayList. [4 3 2 1])))
16:41zackzackzackWhen I am writing tests with clojure.test, how can I test to see if a code throws an error?
16:42lkjklkjjbut this (java.util.Arrays/asList (.array (-> (java.nio.LongBuffer/allocate 4) (.put 4) (.put 3) (.put 2) (.put 1)))) fails with [J cannot be cast to [Ljava.lang.Object;
16:46TimMcTHat seems... unlikely.
16:55alexykhey -- clojurescriptone wants leon 1.7. How can I have 2 leins coexist?
16:55alexyklein, not león.
16:57znDuffalexyk: calling the old one "lein1" is the typical approach.
16:57alexykznDuff: is that enough? just get the old lein driver and call it?
16:57znDuffyup.
16:58wei_thanks nightfly_
16:59jamiihttp://dresdencodak.tumblr.com/post/35721129714/let-me-tell-you-about-fake-geek-guys
16:59jamiiOoops
16:59jamiiI need to just close non-hackerschool tabs :(
17:02andrewmcveighlkjklkjj: I think you want "doto" instead of "->"
17:10lkjklkjjstill just can't figure out how to call asList correctly (def mla (.array (doto (java.nio.LongBuffer/allocate 4) (.put 4) (.put 3) (.put 2) (.put 1)))) mla #<long[] [J@626287d3> (java.util.Arrays/asList mla) ClassCastException [J cannot be cast to [Ljava.lang.Object;
17:10amalloylkjklkjj: asList takes an Object[]. you don't have an Object[], you have a long[]
17:11amalloythere is no way to call asList with the result of (.array someLongBuffer)
17:11lkjklkjjShouldn't it take T whatever T is?
17:12amalloyprovided that T subclasses Object, which primitives do not
17:12lkjklkjjAh
17:13lkjklkjjThanks I that would explain it
17:13TimMcArgh, right.
17:14terom(Java compiler accepts Arrays.asList(somePrimitiveArray), but it will create a List with one Object in it what would be your primitive array. It's still probably something you don't want...)
17:28devnIs anyone else annoyed w/r/t finding the most recent version of any given modular contrib library?
17:29hiredmanwhat do you mean?
17:29znDuffdevn: Seems like the kind of thing Maven is good at.
17:29devnWhere do you look if you're about to require, for instance, logging?
17:29hiredmanby which I mean, no
17:29devnTo find the most recent version, I mean.
17:29hiredmanclojure.tools.logging
17:30devnWhat is your workflow to find the latest version you can require?
17:30hiredmanI don't look for the latest version
17:30devnSo in project.clj you type what?
17:30hiredmandevn: it's already in there, and it never changes
17:31devnhiredman: Suppose you're on a new project...
17:31devnWhat would you do?
17:31hiredmanI go to https://github.com/clojure/tools.logging and read the readme
17:31hiredmanhttps://github.com/clojure/tools.logging#installation
17:32devnWouldn't it be nice to just hit clojars and see the release there?
17:32hiredmandevn: why?
17:32hiredmanI never go to the clojars website
17:32hiredmanthe release is most likely not even in clojars
17:33hiredmancontrib stuff goes to maven central
17:33devnhiredman: Right, how do search maven central?
17:33hiredmandepends, I genenrally don't though
17:33devnWhy not?
17:33hiredmanbecause I don't search for things that are in maven
17:34brehautdevn: https://oss.sonatype.org/index.html
17:34devnbrehaut: loading... I'm on a plane
17:34hiredmanI search for a projact or library that does X, and when I find one I go to the installation / usage instructions
17:34hiredmanproject
17:34brehautdevn: oh well shit, thats an ext or whateveritscallednow app
17:34brehautdevn: but it will let you search central
17:35devnhiredman: brehaut: I guess all I'm getting at is that we have these disparate sources and methods for finding current versions for one ecosystem
17:35hiredmanthere is no single ecosystem
17:35brehauti <3 distributed ecosystem
17:35hiredmanthat is a myth
17:35devnDepends on how you define ecosystem
17:36franics_Hello all - I'm using clojure java.jdbc to run some sql queries against a AWS RDS mysql instance and I'm getting some extremely long query times. SQL reports that the query takes ~4 sec[0] - however the time for the entire process with JDBC is taking ~30 seconds. Has anyone else had issues with this/have thoughts on the matter?
17:36franics_
17:36franics_Please note that I am running the query from an amazon server in the exact same zone as the DB instance.
17:36franics_
17:36franics_http://paste.lisp.org/display/133749 - the code I'm using
17:36franics_
17:36franics_[0] As showing by profiling the query
17:37devn"gem install foo" vs "realize that contrib is now modular and each lib has its own github repo, navigate to said github repo and find the most recent version assuming the author updated the readme, but well, you may want to search maven central just in case"
17:37hiredmanthere is no single source of maven info
17:37devnthat's just weak sauce
17:37hiredmanthere are many maven repos with many different things
17:37hiredmanno, gems are weak sauce and dumb
17:38brehautdevn‽ leins defaults let you do just the same (unless you want to play on bleeding edge contrib snapshots)
17:38brehautits not rocket surgery to set up more repos either
17:38devnhiredman: care to qualify that?
17:38hiredmandevn: you qualify yours first
17:39devni asked first
17:39hiredmanno
17:40hiredmanI do not care to qualify that
17:40devnlook: I just think it's silly that we can't come up with one place to search for patently clojure dependencies.
17:40devni think it is a shitty user experience
17:40franics_devn: agreed - I'd love to know if you've any thoughts as to make it better.
17:42devnfranics_: a new clojars maybe?
17:42franics_devn: why would it have to be new - and what precicely would you do to improve on the current formula?
17:43devnfranics_: it doesn't have to be new -- it could just be building on the existing clojars
17:43francisjust realized my name was spelled wrong *smh*
17:43devnbut what i imagine is: you go to clojars, and you see releases for things that are in maven central that lots of clojure-folk use
17:43devnregardless of whether they *live* on clojars
17:44devntools.logging, for instance. i feel like you should be able to search for that.
17:44francisAh, that's cool - though I'm not sure how you would get data about jars that don't *live* there
17:44devnfrancis: scrape maven central
17:46devnfrancis: whether anyone likes gems or not, you can at leasr `gem search -r foo` and find meaningful libs. I still don't get how leiningen's search utility is supposed to work or be useful to new users. most tutorials in clojure start out with: get leiningen.
17:46devns/leasr/least
17:48devnhonestly a lot of this stuff is /done/ and works, it's just that it's usually given a really annoying interface
17:48devnFor instance: Here's the output of `lein search` with no args...
17:49devnWrong number of arguments to search task.
17:49devnExpected ((project query page))
17:49devnSuper informative, eh?
17:50francisdevn: Talk to Phil about it - I'm sure if you've got some improvement your willing to implement he'd be more than happy to discuss improving lein
17:50devnSo you type `lein help search` -- better, but it's still just kind of weird
17:50francis*you're
17:50francisdevn: personally I never use lein search and as such don't feel your pain in this particular situation
17:50devnFair enough -- I'll bring it up at the conj. Hopefully hiredman doesn't beat me up
17:51devnThey just told me to put away my 'puter. Wheels down RDU.
17:51devnCheers
17:51francisdevn: have fun at the conj yo
17:51hiredmanwhen have I ever beat anyone up?
17:52francisI'm sure everyone already heard this before - but...
17:52francisHello all - I'm using clojure java.jdbc to run some sql queries against a AWS RDS mysql instance and I'm getting some extremely long query times. SQL reports that the query takes ~4 sec[0] - however the time for the entire process with JDBC is taking ~30 seconds. Has anyone else had issues with this/have thoughts on the matter?
17:52francis
17:52francisPlease note that I am running the query from an amazon server in the exact same zone as the DB instance.
17:52francis
17:52francishttp://paste.lisp.org/display/133749 - the code I'm using
17:52francis
17:52francis[0] As showing by profiling the query
17:53TimMcfrancis: Please don't re-paste like that -- I can still see the first copy at the top of my screen.
17:53francisTimMc: noted.
17:55seangroveHey guys, wondering about the goog-closure.jar, and where it comes from
17:55seangroveIs it centrally maintained, or can I compile my own version? The few I've found so far are missing the md5 libs
17:56seangrove(speaking about clojurescript of course)
17:57ivanI just put closure-library\closure and closure-library\third_party\closure in my CLASSPATH
17:58ivanyou can make your own jar with those, I guess
18:02technomancydevn: looks like a bug that the project arg is shown in the error message there
18:03technomancythey screwed us up by removing the old index format, so there was a while where lein search just wouldn't work
18:05seangroveivan thanks, I'll give that a try, been a rough patch after a great start.
18:08eggheadhmm, with expectations and with-redefs, does the redef only happen once per file? I'm making some changes to atom in one redef that are showing up in another with-redef
18:11technomancydevn: fixed
18:13eggheadah, I was confusing redef-state with with-redefs
18:13eggheadnope, nvm
18:14alexykI have a name conflict in my namespace from imports, how do I rename the colliding symbol away?
18:16gfredericksalexyk: they both come from other namespaces?
18:17alexykyep
18:17gfredericksthe easy way is to not refer at least one of the namespaces -- i.e., give it a prefix
18:17alexykthat kind of answered my question :)
18:17gfredericksI know refer lets you rename things
18:17gfredericksbut I don't know the exact syntax
18:18gfredericksbut prefixing is the normal approach I think
18:18gfrederickse.g., (:require [clojure.string :as s])
18:19Apage43refer takes a :rename {from-symbol to-symbol ...}
18:19Apage43if you really do want to do that
18:22azkaneis there a function to check if a string is a substring of another? other than using a regex?
18:23gfredericksthe string class has that I think
18:23znDuffazkane: the java standard library's String class has methods for that, yes.
18:24kofno(.contains ...)
18:24kofnoI think
18:24azkaneoh, i thought there was a clojure function for that, will use the java one thanks!
18:32alexyksay I did (use 'bad) and regret it. How do I dissociate bad namespace from current?
18:33Apage43alexyk: if you didn't clobber any symbols you can use ns-unmap and ns-publics
18:37alexyk(ns-unmap ['user 'server])
18:37alexykArityException Wrong number of args (1) passed to: core$ns-unmap clojure.lang.AFn.throwArity (AFn.java:437)
18:37alexyk?
18:37alexykdoc ns-unmap says it takes [ns sym]
18:39alexykomg nm
18:39brehaut(ns-unmap 'user 'server)
18:40alexykyeah, a case of rusty idiocy/idiotic rustiness
18:40alexykin #Haskell 3 people would have said that already! you guys rock
18:41brehaut?
18:42alexykbrehaut: rustiness on my part :)
18:43brehautright
18:43alexykI'm glad folks here are helpful in all cases :)
18:43alexykbtw there's a remove-ns
18:53zodiakstupid question.. I have a defn inside a (-> ..), how do I 'promise' I will defn one of these methods later ?
18:53zodiakor rather; (-> f add-behaviors show!) .. and I defn add-behaviors later in the same file
18:54cgagdeclare?
18:54zodiakhow do I say 'promise it will come later' (ala prototype ?)
18:54cgag(declare add-behavior)
18:54zodiakaahhh
18:54zodiakyup. (doc declare) has it.. awesome ta
18:59mpanwhat's the simplest (not necessarily proper) way to use a jar I have locally?
18:59znDuffmpan: ...well, the _proper_ way is to install it in your local Maven repo (the ~/.m2/ cache)
18:59znDuffmpan: ...which Maven has a subcommand to do.
19:00mpanI wasn't aware I even had maven, except that lein brought it along at some point
19:01znDuffwell -- see if you have a mvn command
19:01znDuffif you don't, you might need to install it.
19:01mpanautocomplete for "mv" only has "mv" so I guess I don't
19:02mpanis there somewhere I can just drop the jar as a one-off for now?
19:02mpangoogle also suggests I do it "properly" but I've dug myself into a deadline hole
19:05znDuffWell -- yes, but you'll have to create a .pom file by hand
19:05mpanI was really hoping just to point lein at a path
19:05mpan(wouldn't mind hard-coding it for now)
19:05znDuffif you want to call it example.com/mylib 1.0, then create ~/.m2/repository/example/com/1.0/
19:07znDuff...and drop mylib-1.0.jar in there
19:07mpandoes that approach require writing more config also? or just make the path and drop the jar?
19:08znDuff...and create a mylib-1.0.pom file that looks like https://gist.github.com/4075744
19:08znDuffand that's it.
19:08znDuffso -- you drop the jar, and you create the tiny little XML file, and that's it.
19:10mpangreat! thank you!
19:12thmzltanyone having "Invalid memory access" issues with lein and OS X?
19:21wei_what's idiomatic clojure to continuously read from a socket?
19:22gfrederickswithout any context at all, I would think you could do that with a lazy seq
19:24amalloywei_: http://stackoverflow.com/questions/1054170/clojure-variables-and-looping may be relevant
19:24seangroveWhat's a better/more efficient way to write this function to detect if a string contains a double-byte char: https://gist.github.com/a38106fe15a521288708
19:24wei_gfredericks: how do you do that in another thread so the repl is still responsive?
19:25seangroveIt has to target clojurescript though, so can't use Java utils
19:27gfrederickswei_: you don't have to do it in another thread
19:27wei_ah, just read through amalloy's link. thanks
19:27Apage43seangrove: it's worth noting that any unicode codepoint > 127, not 255, will have a multi-byte encoding
19:28seangroveAh, good point
19:28seangroveAs far as writing an efficient function though?
19:28seangroveRecur keeps it from having to traverse the whole string, but it looks clunky
19:29dnolenseangrove: if efficiency is the main concern just right it just like you in JS w/ loop/recur.
19:29SomelauwCan't you use filter and check if the resulting lazy-seq has at least 1 element?
19:29dnolener s/right/write
19:29TimMcIn CLJS, what are the elements of a string seq?
19:30seangroveIt's not the biggest concern, it's used on short strings, and rarely, but was just curious
19:30TimMc(some #(...) string)
19:30seangroveTimMc: I believe strings of length-1
19:30TimMcBah, OK.
19:30Somelauwlike (seq (filter #(> (.charCodeAt % 0) 255))
19:30TimMcThat spawns a ton of tiny strings.
19:31dnolenseangrove: if efficiency doesn't matter then TimMc's suggestion works fine.
19:32Somelauwoh, some does that as well
19:33seangroveAh, yes, some, that looks like what I wanted
19:36seangroveThanks TimMc, appreciate it
19:50mpanI'm getting a strange error from "lein deps" using a local repo https://www.refheap.com/paste/6688
19:50mpanI followed some tutorials but I may have messed up the process midway
19:50mpancan someone help me understand what that error is?
19:51mpanthe jar file is in the same spot as the pom file but it doesn't seem to find it?
19:52znDuffmpan: Pasting the POM wouldn't be a bad place to start.
19:52mpanhere's the pom file https://www.refheap.com/paste/6689
19:53mpanthe jar and the pom file are both in the same spot in the local repo
19:56znDuffyour local repo isn't at ~/.m2/repository?
19:56znDuffanyhow -- what does your project.clj look like?
19:57mpan:repositories {"local" ~(str (.toURI (java.io.File. "mvn_repo")))}
19:57mpanunder :dependencies, there is [jgap/jgap "3.6.2"]
19:58mpanI was following a tutorial that recommended making a new directory for it
19:58mpanshould I use the one under .m2 instead?
19:58znDuffDoes it work properly if you don't do that, and use the default local repository?
20:01mpanshould I just copy the directory structure over?
20:02znDuffSure.
20:05mpanit seems to have worked
20:05mpanthank you!
20:06mpanin the future, should I use mvn's install directly to the default repo?
20:06znDuffIt's what I do, anyhow.
20:06znDuffWouldn't be surprised if whitespace in the path were an issue.
20:07znDuff(with respect to why the other approach wasn't working)
20:08mpanin general, should I worry about naming my directories with spaces?
20:10zodiakwhy in a repl does (source foo) not work after I have done; (defn foo "test" [] "x")
20:10zodiakit works for (source doc) jst dandy
20:10zodiakmpan, yeah.. spaces in dirs/filenames are jst a pain in the tucas
20:11ivanzodiak: Clojure doesn't preserve the source for functions it compiles
20:11ivan,serializable-fn
20:11clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: serializable-fn in this context, compiling:(NO_SOURCE_PATH:0)>
20:11ivanserializable-fn?
20:11clojurebotserializable-fn is a hack for preserving source of a compiled function: https://github.com/technomancy/serializable-fn
20:12ToxicFrogzodiak: (source) works by tracking down the original .clj file and reading it, AIUI
20:13zodiakspiffy .. ta
20:18ivanso (source) is probably a lot of fun if you've changed the .clj file
20:22amalloympan: definitely don't use spaces in directory/namespace names. they're equivalent to java package names, which are restricted exactly to java identifiers
20:24znDuffmpan: In an ideal world, you wouldn't have to worry about it.
20:24znDuffmpan: ...in the real world, it tends to expose bugs that would otherwise not trigger.
20:25znDuffmpan: ...so -- if I wanted to spend my time finding and fixing bugs in other peoples' software, I'd have my home directory have a space in its path.
20:25znDuffamalloy: the context here isn't namespace names, but Maven repo path names.
20:26zackzackzackIs there a way to get leiningen to be more verbose? I'm trying to debug a "error in opening zip file" and not having much luck.
20:27zackzackzackFound DEBUG=TRUE but it doesn't help much.
20:36DaReaper5Hi again! I have another clojure question. This time about hwo to return an input stream in the body of a message.
20:36DaReaper5I have the following: :body (io/input-stream (simple.FastReportTest/reTest)
20:37DaReaper5simple.FastReportTest/reTest returns a ByteArrayInputStream
20:38zodiakzackzackzack, I don't think so, but, without sounding like a troll, write a few tests around the fn that deals with the zip files.. no ?
20:39DaReaper5I get the following error: java.lang.IllegalArgumentException: No implementation of method: :make-input-stream of protocol: #'clojure.java.io/IOFactory found for class: nil
20:39zackzackzackzodiak: This is more of a dependency issue than anything else. I'm using leiningen as a tool right now and to write tests would mean I would have to set it up locally and test it here
20:42DaReaper5any help would be much appreciated. To sum up my question again: How to i return an input stream properly in the body of a message?
20:45DaReaper5The following also does not work: :body (java.io.ByteArrayInputStream. (simple.FastReportTest/reTest)
20:46DaReaper5I get a java.lang.NullPointerException
20:46DaReaper5However on a local test using the same java code i know null is not being returned.
20:47DaReaper5:(
20:48znDuffDaReaper5: Can you provide enough context that we can actually reproduce your result?
20:50DaReaper5it would take way too much for you to reproduce exporting a dynamically created jasper report. However ALL i want to know is what is the standard convention for returning an input stream that is NOT a file. (I can return files fine)
20:50znDuff(ideally, enough context and not the tiniest bit more)
20:51DaReaper5to return a ByteArrayInputStream in :body do i do: [:body (java.io.ByteArrayInputStream. (simple.FastReportTest/reTest)], [:body (io/input-stream (simple.FastReportTest/reTest)], or something else
20:52DaReaper5[:body (io/input-stream "file.xls") ] works
20:52DaReaper5hmm maybe more high level context:
20:52znDuff...so, if you're returning something lazy that isn't valid when it's evaluated later, that would be the more usual cause of that kind of issue.
20:53znDuffthat's not specific to input streams, though
20:53DaReaper5i have a clojure web server which responds to api calls. I am creating a test that returns a dynamically created file, but am having issue with ":body"
20:53DaReaper5"returning something lazy
20:54DaReaper5"?*
20:54znDuff"lazy" == "not existing until referenced" (or until read).
20:54znDuff...it's very, very easy to make things lazy in Clojure
20:55znDuffand if you have something that's lazy and gets evaluated after you're outside of a thread-local scope where valid bindings for it existed, you get problems like what you're describing here
20:55znDuffbut because you aren't giving us enough context to reproduce, that's guesswork.
20:55znDuffYou're fixating on the "but it's an input stream!" bit, but if that input stream runs code that depends on thread-local context before it can be read, that code matters. :)
20:56spearHey guys. I'm going to try to not sound like a noob here. A few months ago I was planning to learn clojure, but then I read an article that said it was significantly slower than Java.
20:56spearIt said that because Clojure generated docstrings (for production as well as development programs, when its only needed for dev), it was slower. Has anything been done about this?
20:56znDuffspear: docstrings have nothing to do with it.
20:56DaReaper5sorry, (clojure noob) but i thought it was all in one thread because the static java method is being called inside the clojure method
20:57znDuffDaReaper5: it's not about the threading, it's about the bindings, and their ability to go out of scope
20:57znDuffDaReaper5: ...again, typically. This is, again, guesswork, because you aren't showing code.
20:57DaReaper5so i should bind the return of the java method to a variable then provide that variable!!!
20:58mpanI have something created with proxy, extending a base class, and when I try to call a method on it, I get nil: https://www.refheap.com/paste/6691
20:58mpanI'm expecting an empty vector
20:58ivanspear: startup times are not really a problem if you keep your JVM running
20:58znDuffDaReaper5: ...waitamoment. If _all_ you're returning is that one value, why not just evaluate to that value?
20:59DaReaper5sorry i still am not lisp/clojure minded
21:00DaReaper5i was trying to provide the return of the method as a parameter to io/input-stream
21:00znDuffAhh.
21:00znDuffSorry -- I misunderstood your question as something more complex
21:01DaReaper5when (as i understand it). In order for the return value/instance to be used it has to be binded to a variable (let)? Right?
21:01DaReaper5one second checking
21:01znDuff(io/input-stream (simple.FastReportTest/reTest)) calls the static function, and passes its return value to io/input-stream
21:01mpanif I change the method I'm overriding to return a string, I still get nil: https://www.refheap.com/paste/6692
21:02mpanhave I got the syntax for 'proxy' wrong or something?
21:03DaReaper5Ugh trying all possible combinations for testing is going to be anoying. https://www.refheap.com/paste/6693
21:03znDuffDaReaper5: You don't need to do that -- I misunderstood your question.
21:03DaReaper5Could you tell me what i have to do? Should i specify foo2 as a ByteArrayInputStream? Should i replace io/input-stream with ByteArrayInputStream
21:04znDuffDaReaper5: ...no need for the let there -- it adds nothing.
21:04DaReaper5... xnDuff so i could posibly pass the method call assuming that its return will be used as a parameter?
21:04spearivan, znDuff "My summary is that it spends 95% of the startup-time loading the clojure.core namespace (the clojure.lang.RT class in particular) and filling out all the metadata/docstrings etc for the methods. This process stresses the GC quite a bit, some 130k objects are allocated and 90k free-d during multiple invokes of the GC (3-6 times), the building up of meta data is one big source of this massive object churn."
21:04spearFrom the article
21:04znDuffDaReaper5: {:body (io/input-stream (simple.FastReportTest/reTest))} is fine. Initially you were using square brackets rather than curly, which is a rather different thing.
21:05znDuffspear: Yes, but that's _startup_ time.
21:05znDuffspear: Who cares about startup time? It's runtime that's important for most applications.
21:05znDuffspear: ...if you're writing something that needs to start up quickly, Java is usually the wrong language too.
21:05DaReaper5oh sorry about that (was just separating things out in the irc)
21:06DaReaper5http://stackoverflow.com/questions/13140875/intermittent-error-serving-a-binary-file-with-clojure-ring does the following :body (ByteArrayInputStream. pixel-bytes)}))
21:06DaReaper5... however this did not work for me
21:06spearIs regular runtime comparable to Java?
21:07znDuffspear: Clojure isn't exceptionally fast at runtime either for a single thread, but it parallelizes astonishingly well -- I've seen major performance gains via a Clojure rewrite for code running on extremely parallel hardware.
21:07mpanI'm so confused. If I make an proxy for j.l.Object it works fine. If I make a proxy for some strange class with a type parameter T, it gives me nil instead of what my overriding method should be returning.
21:07znDuffspear: ...so -- if you're doing something where you can take advantage of having Clojure's STM available instead of locking, and will be running on lots of cores, Clojure is a good fit. Otherwise, if you're performance-bound, probably not.
21:07clojurebot'Sea, mhuise.
21:07mpanIs my issue the fact that the class uses generics?
21:08toofisheshi everyone. i'm trying to do something like this (reduced into a standalone one-liner), but the apply isn't working as i hoped. (map apply [#(Integer/parseInt % 16) #(Long/parseLong % 16) #(Short/parseShort % 16)] ["a0" "a0" "a0"])
21:08toofishesArityException Wrong number of args (2) passed to: core$eval419$fn clojure.lang.AFn.throwArity (AFn.java:437)
21:08DaReaper5znDuff, http://grokbase.com/t/gg/clj-noir/1234t3bx3g/noir-hooking-gzip-middleware-in-noir does :body (java.io.ByteArrayInputStream. (.toByteArray out))})
21:08DaReaper5but that did not work for me either (because it is practially the same)
21:08DaReaper5so i come here to see if i am being stupid with syntax
21:09spearAh I see
21:09spearthanks, znDuff
21:09znDuffDaReaper5: The tiny snippets you give us aren't obviously wrong, but they lack enough context to evaluate.
21:10znDuffDaReaper5: ...I mean, some web frameworks expect the return value to be a dict with a :body key, but you haven't even told us what you're using.
21:10DaReaper5znDuff ... but i just want to return an input stream :P. Not sure what else i should provide. Shouldn't this be basic for clojure web servers?
21:10mattmoss(doc juxt)
21:10clojurebot"([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
21:10mattmosstoofishes: Take a look at juxt.
21:11DaReaper5however, most of the example i fine are returning static files (gah!)
21:11DaReaper5examples*
21:11znDuffDaReaper5: Build a reproducer that doesn't require your huge dependency chain. You won't be able to get help that isn't guesswork until you can do that.
21:12znDuffDaReaper5: ...it shouldn't be that hard to find a non-file inputstream -- the standard library includes some memory-backed ones, after all.
21:13DaReaper5could you reference me a non-file inputsream :)
21:13znDuffI search through the Java standard library docs when I need such a thing
21:13znDuffdon't keep it all off the top of my head.
21:13mpanoh my gosh, I just did the same thing twice and it worked only the second time
21:13DaReaper5okie dokie
21:14DaReaper5true
21:14mpanI'm a bit scared now
21:14gfredericksthe javadocs list "Direct Know Subclasses" when you look at inputstream
21:14gfrederickss/Know/Known/
21:14toofishesmattmoss: i'm not looking at applying each function to each arg, it looks like that is what juxt does? more like [(functionA argA) (funcB argB) (funcC argC)]
21:14mpanmy best explanation is that I'm not properly loading my changes into the repl
21:16mattmosstoofishes: Then maybe just... (map (fn [f a] (f a)) [fs...] [as...])
21:16mattmosstoofishes: The function you map with can have multiple arguments... one arg per collection provided.
21:16DaReaper5hmm something different and interesting: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
21:16DaReaper5new error
21:16DaReaper5progres!?
21:17toofishesmattmoss: oh, geez. that sounds so easy now.
21:17toofishesthank you!
21:17mattmoss,(map (fn [f x y] (f x y)) [+ -] [1 2] [3 4])
21:17clojurebot(4 -2)
21:18toofishes,(map (fn [f a] (f a)) [#(Integer/parseInt % 16) #(Long/parseLong % 16) #(Short/parseShort % 16)] ["a0" "a0" "a0"])
21:18clojurebot(160 160 160)
21:18mattmosswootage
21:19mattmoss,(map (fn [f a] (let [x (f a)] [x (class x)]) [#(Integer/parseInt % 16) #(Long/parseLong % 16) #(Short/parseShort % 16)] ["a0" "a0" "a0"])
21:19clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
21:19mattmossoops
21:19mattmoss,(map (fn [f a] (let [x (f a)] [x (class x)])) [#(Integer/parseInt % 16) #(Long/parseLong % 16) #(Short/parseShort % 16)] ["a0" "a0" "a0"])
21:19clojurebot([160 java.lang.Integer] [160 java.lang.Long] [160 java.lang.Short])
21:20DaReaper5ITS ALIVE! IT WORKED
21:20DaReaper5wow
21:20mattmossBwhahaha?
21:20DaReaper5:body foo2
21:20DaReaper5thats it
21:20DaReaper5no bs needed before it
21:48mpanI introduced a new local dependency, ran lein deps and it succeeded, but I'm still getting a classnotfoundexception at runtime
21:48mpanHow should I debug this?
21:49mpanthe class is in the jar and the jar is in the place I expect under ~/.m2/repository/
21:50yedihttp://blog.wolfram.com/2012/11/14/code-length-measured-in-14-languages/
21:51yediclojure trashes everything except for mathematica
21:55mpangfredericks: supposedly that's what wolfram alpha is, approximately
21:55mpanthe thought of it confuses me as well
21:56mpanah! second time today! doing the same thing twice yields different results! first incorrect then correct
21:56gfredericksmy point is that I think mathematica is rather special-purpose
21:56mpanif only I knew where I was actually differing
21:58mpangfredericks: I suppose wolfram themselves have a vested interest in the business success of it
21:59mpanI certainly don't imagine myself waking up tomorrow and thinking to myself... hm, I'll write a web-app in mathematica/matlab/etc
22:44yedii swear the process for getting clojure/swank/lein working with emacs is a mechanism for filtering out idiots from the clojure community
22:45brehautyedi: nrepl+lein2 is much easier to get going than swank
22:46brehautsee also http://technomancy.us/163
22:46ivanEmacs itself is the great filter
22:46yedisweet, thanks
22:47brehautivan: hmm. it's a filter alright, but swank is/was an especially weird piece of the puzzle
22:51azkaneso is there an advantage in using swank over nrepl?
22:52brehautyou like pain?
22:52brehauttheres some features that swank supports that nrepl doesnt have yet
22:52brehautemphasis on yet
22:53brehautfrom memory i think swank has some better debugging / stepping stuff?
22:53brehauti never used it though, so i cant say
22:55Sgeo__Isn't there some ritz thing? I haven't tried it though. I should
23:00brehautSgeo__: thats a name i have seen but have no familiarity with
23:05amalloyritz does indeed have more features than stock swank/slime. IME it was a lot harder to set up, and the payoff wasn't really that big because the bytecode and line numbers the compiler generates confuse the heck out of the debugger
23:12Sgeo__Is it worth to set up over plain nREPL.el?
23:30yediwhats the best/simplest way to do line by line file processing?
23:37hyPiRionsimplest is probably line-seq
23:37hyPiRion,(doc line-seq)
23:37clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
23:38yedicool, ty
23:38hyPiRionjust be a bit careful with it though - as it is lazy, you cannot close the buffer before you've actually finished reading all the lines.
23:39hyPiRionyou could wrap it in a doall if you know you're going to process all the lines in the file.
23:42hiredmanhttps://gist.github.com/4075459