#clojure logs

2015-02-27

01:05devllHi, how to get current profile name in clojure?
01:06devllI can get around by evaluating profile specific value,but is there an elegant way to do this?
01:14devllls
01:14lazybotbin dev etc home lib media opt sbin sys var
01:24tcrayford____the ring-jetty9 adapter has a new CVE/security fix: https://github.com/sunng87/ring-jetty9-adapter/pull/20
01:24tcrayford____y'all should upgrade to 0.8.2 as fast as you can
01:47Kneivayay, my first own macro: https://www.refheap.com/97841 Do you have any pointers for improvement?
01:56sm0keso is there a hack to add a folder to lein's classpath?
01:56justin_smithKneiva: why is it a macro?
01:57sm0kethe folder contains jar files
01:57sm0kei tried adding to resource-paths , but no lucj
01:57justin_smithsm0ke: each individual jar in the folder needs to be added
01:58sm0kei did a ["resources" "lib_managed/*"] justin_smith
01:58justin_smithoh, it accepts globs?
01:58sm0kejava does
01:58sm0kejava -cp "lib/*:..." works
01:59Kneivajustin_smith: can I repeat stuff for for's binding vector some other way?
02:02justin_smithKneiva: ahh, right. The function can be written without using a macro, but this approach (generating a binding vector) requires one
02:03dysfuntcrayford____: hrm, i wonder if such a thing affects aleph
02:05justin_smithsm0ke: I don't doubt that java supports that, I am just not sure that lein implements it. I've never seen it done, and there is no instance of doing it that way in the project.clj.
02:05justin_smith*the example project.clj
02:06Kneivahmm, I could probably bind the aseq to a constant so the data does not get repeated in binding vector
02:14sm0kejustin_smith: thanks i will verify by adding individually
02:14sm0ke`inc` is promised if it works :P
02:16sm0kejustin_smith: holy shit!
02:16sm0kejustin_smith: wildcard works!
02:16sm0keadding "lib_managed/*" to resource-paths works
02:17sm0kei was adding it to java-source-paths before
02:17slipsetjustin_smith: really enjoyed your conversation with csd_ earlier
02:17slipsetabout functions having different responabilities
02:18justin_smithslipset: thanks
02:18slipsetI've been searching for a name to put on this "pattern", but never came up with anything
02:18slipsetthe closest I've come is to mention one of the functions as an orchrestator(sp?)
02:19justin_smithinteresting
02:20justin_smithI'm turning in for the night, but I am sure there is a name for this (other than just "functional programming") that is escaping me today
02:20justin_smithone keyword would probably be "referential transperency"
02:21slipsetmy thought being that the one organizing the coupling between the logic and the side-effecter is the orchestrator, and it (the orchestrator), as you mention, needs very little testing, since it's logically very simple
02:21slipsetbtw, how can you be turning in? my day is just starting?
02:21justin_smith~ugt
02:21clojurebotugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html
02:21slipsetI know :)
02:22slipsetInterestingly, I was explaining this pattern to a co-worker just yesterday.
02:22slipsetAlso, the thing of sending the side-effecting function as a param to the logic-function
02:23jballancanyone know of a library of Clojure form transformations? e.g. I want to refactor a list of calls into a threaded form
02:23slipsetjballanc: please elaborate?
02:24jballancI often find myself writing something like `(map join (partition 2 (interleave ['a 'b 'c] (some-call))))`
02:24slipsetso you want the threading macro?
02:24jballancand I'd like to refactor that to `(->> (some-call) (interleave ['a 'b 'c]) (partition 2) (map join))`
02:25slipsetlike -> or ->>
02:25jballancright
02:25jballancbut automatically
02:25slipsetclj-refactor might have this?
02:25jballanci.e. I built up the first form either in the REPL or in my editor, but once I get 3-4 forms deep I'd like to re-order
02:25jballanchmm...I'll have a look
02:26slipsetyepp, it does
02:26slipsettf :) https://github.com/clojure-emacs/clj-refactor.el
02:26julianlevistonI have some data. I'd like to look up each entry by one of THREE keys! (and have each entry to have 3 values) Oh, the craziness! Is there a way to do that? I can't think of a way, really...
02:26slipsetor tl
02:26jballancslipset: ah, indeed...and as I feared its in elisp :-/
02:27slipsetjballanc: yak-shave for the weekend elisp2clj
02:28julianlevistonI should say, I want all 3 values out when I look up a key. Should I build a new type of data? I often seem to need n-way maps, actually… not really sure how to go about implementing that.
02:29slipsetjulianleviston: care to share a gist?
02:29julianlevistonslipset: I don’t have a gist.
02:30tcrayford____dysfun: it might have the same vuln, I guess, but that patch is jetty specific. writing http servers is hard :/
02:30julianlevistonslipset: because I haven’t started to build it yet… I’m currently re-implementing it based on these new requirements… and I’m presently using a map, which is a 1-1 version of this data structure.
02:30jballancslipset: probably just quicker to hand-convert to clj...then I just have to hook it into vim-fireplace somehow
02:33julianlevistonslipset: I’ll make up a syntax here because there’s no such syntax… (get <:a 1 :b 2 :c 3, :a 5 :b 10 :c 15> {:a 1}) should yield {:a 1 :b 2 :c 3}
02:34julianlevistonslipset: I *could* just use a set of n maps, but that’s ugly and takes a LOT of overhead to manage, and I don’t like it.
02:35julianlevistonslipset: the use case is I’d like to be able to say “look in the store for the one where :a is 1, and give me the value of :b”… where :a and :b are arbitrarily any of the keys.
02:37slipsetjulianleviston: but what's the relation between :a and :b?
02:37raspasovjulianleviston: so you want a value to be "discoverable" by n different keys, and not just one?
02:37julianlevistonslipset: if you want to know my use case, it’s :dom-id, :database-record-id and :parent-dom-id
02:38julianlevistonraspasov: yeah :)
02:38raspasovis this for Clojure or ClojureScript?
02:38julianlevistonraspasov: kind of like a map with 2 way lookup instead of 1-way lookup, but actually 3-way.
02:38julianlevistonraspasov: CLJS
02:38raspasovjulianleviston: hm ok, does CLJS have STM?
02:38julianlevistonraspasov: yes
02:38raspasovI can't recall
02:38slipsetso something like (get-by m keys) ...)
02:39raspasovI mean the refs
02:39ro_stcljs does not have STM
02:39julianlevistonraspasov: no
02:39raspasovit doesn't have the refs, does it?
02:39julianlevistonraspasov: just atoms
02:39ro_stcljs has atom and var. clj has those and ref, agent
02:39raspasovyea, with the STM you would be able to have three different maps
02:39raspasovand synchronize them
02:39julianlevistonraspasov: wow that sounds delicious!
02:39raspasovjulianleviston: is this irony or you're serious? :)
02:40julianlevistonraspasov: I’m serious. Sounds neat.
02:40raspasovjulianleviston: ok :) well you can do it with atoms as well I believe
02:40julianlevistonraspasov: I’m not sure how tho…?
02:40raspasovnot sure in CLJS though, since there's no threads...
02:41julianlevistonraspasov: isn’t the problem to do with structuring the data, not the synchronisation? Or am I missing stuff?
02:41raspasovwell, I was thinking about a kinda hacky solutions with refs
02:41slipsetjulianleviston: so, do you want all the matches or just the first?
02:41raspasovwhere you copy the data over three (or n times)
02:41raspasovin different maps
02:42julianlevistonslipset: how do you mean? sorry?
02:42raspasovalso how big is the data structure you're going to be accessing? I can think of many ways to do this with linear time lookup
02:42julianlevistonraspasov: well I can build a hacky solution myself. I was asking here because I wanted to know if there’s an actually efficient way to do map-like data structures with n-way lookup
02:43raspasovdoing it the proper way will prob require some more thought and potentially a new kind of data structure
02:43julianlevistonraspasov: yeah I can think of those too…
02:43slipsetsay you have a map {:a 1 :b 2 :c 3} and you ask for the keys [:a :b], should the return value be 1, 2 or [1 2]?
02:43raspasovyea :)
02:43julianlevistonraspasov: ah ok… that’s what I was interested in
02:44raspasovslipset: from my understanding he wants :a to be discoverable not just by :a but also by n other different keys
02:44julianlevistonslipset: um… no think of it more like a vector of records all of the same type… which you can look up by any of the values in the records, but that enforces the uniqueness of ONE of the key values
02:44julianlevistonraspasov: yep.
02:44slipsetAh, I see
02:45julianlevistonslipset: it’s actually a bit annoying, because there can be dupes of the dom-ids and the parent-dom-ids, but not the database-ids
02:46julianlevistonI guess I should use a relational algebra… probably.
02:46julianlevistonyeah.
02:47julianlevistonok thanks guys!
02:47raspasovhow about something like (def map-1 {:a atom-1 :b atom-2 :c atom-3})
02:47raspasovand then (def map-2 {:a-1 atom-1 :b-2 atom-2 :c-2 atom-3})
02:47raspasovI mean, it's still hacky
02:47julianlevistonraspasov: erm… I’m not sure how the associations work there… at all...
02:48julianlevistonraspasov: also these things will be stored in an atom already, so that’d be like… atoms stored in atoms… seems… bad?
02:48raspasovwell atom-1 is discoverable by either :a or :a-1
02:48raspasovyes it's not 100% pretty and idiomatic :)
02:48raspasovit's like a ... 50% hack lol
02:48julianlevistonerm… I think you’ve missed my point really… but it’s cool… nevermind
02:48julianlevistonI’ll go brush up on my relational algebra like stuffs.
02:49raspasovjulianleviston: alright :)
02:49julianlevistonDidn’t occur to me until just now… plus I just can’t remember the functions at the moment.
02:53julianlevistonbe so much easier if there was some kind of pattern matching facility
02:55dysfuntcrayford____: once something involves the network, it's time to give up and let someone else do it
03:06slipsetcore.logic?
03:12dysfunslipset: what about core.logic?
03:24julianlevistondysfun: it was meant for me
03:24dysfunoh right
03:24dysfunin that vein, also core.match
03:25julianlevistonI just meant this: pseudo-relational algebra support for 'relations', which are simply sets of maps - select/index/rename/join
03:25julianlevistonparticularly join...
03:26julianlevistondysfun: thanks
03:26dysfuni think R can do that, incidentally
03:26dysfunwhich means incanter probably can
03:26julianlevistondysfun: is it effecient over 2000+ item sets I wonder...
03:27dysfunthey're in memory. if you weren't doing it in your app you'd be doing it in the database which would probably have to read off disk
03:27dysfunso i'd expect it's "fast enough"
03:28julianlevistondysfun: maybe. I’m expecting this to be comparable to a map lookup...
03:28julianlevistondysfun: because I’m doing like… thousands of these and I’d like it to be very fast.
03:29dysfuni expect you probably want some sort of index data structure
03:29dysfunor, y'know, a database
03:29julianlevistondysfun: guh. This is a simple data structure.
03:30dysfunthen you don't have to worry about performance until you've demonstrated a problem
03:30dysfuni can assure you that thousands of operations are not a problem for the combined might of the jvm and a decent machine to run it on
03:31julianlevistondysfun: CLJS
03:31dysfunclient side or server side?
03:31julianlevistondysfun: client
03:31dysfunwhy are you doing all of these operations on the client?
03:31julianlevistondysfun: it matters. I’ve demonstrated that it slows things down
03:32julianlevistondysfun: it’s not a huge amount of operations.
03:32julianlevistondysfun: my point… it should be as fast/efficient as map lookup.
03:32julianlevistondysfun: because this is a master mapping index of in-memory records. Suggesting I put it in a db is kinda… self-defeating.
03:33pepijndevosWhat are my options for a websocket server? It seems Aleph and http-kit. How do they compare? Both seem to use their own channel-ish things.
03:33julianlevistondysfun: I just need it to be able to be looked up by 3 keys, is all.
03:34zotjust curious: is there another idiom for (mapcat identity coll)?
03:34dysfunjulianleviston: i think you probably want javascript workers then
03:34julianlevistonzoldar_: concat ?
03:35julianlevistondysfun: errrr… it’s not THAT much work… is it? Not knowing anything about what JS workers are
03:35dysfunpepijndevos: aleph is fantastic if you're running websocket-y stuff. http-kit is fantastic if you're doing client-y stuff. i'd probably use aleph for both these days
03:35pepijndevosdysfun isn't websockety stuff also clienty stuff?
03:36julianlevistondysfun: I *had* a 2 key version which I just used a map-invert when I needed the other direction… but the requirement just changed to having a 3 way lookup, and I’m investigating good ways to implement that…
03:36julianlevistondysfun: all good I’m going to try with this join thing first and see what happens after that
03:37julianlevistonzot: sorry… I mistyped - concat ?
03:37julianlevistonzot: seeing as mapcat maps a function across a coll, then concats the result… no need to do the map part.
03:38dysfunpepijndevos: sorry, i meant "http client" here, so if you're wanting to *initiate* connections
03:38pepijndevosah
03:40zotjulianleviston: apply concat would be the same i suppose
03:40zoti was curious if there's a completely standardized idiom for it
03:40zotand identity is *such* a long word :)
03:42hyPiRionWish it was named `id`
03:43julianleviston(def id identity)
03:43julianlevistonpretty easy
03:43dysfuni'd use 'apply concat'
03:43julianlevistonzot: given the source of mapcat USES apply concat, I think what you want is silly… just write your own function if you don’t want to repeat yourself
03:44zotlol. point taken :)
03:44julianleviston(defn catty [& args] (apply concat args))
03:44julianlevistonI have loads of these shortcuts of my own… and a lot are in contrib...
03:47julianlevistonzot: sorry I didn’t mean to be rude. Shouldn’t have used the word silly… “trivial” might have been a better word. :)
03:48zotjulianleviston: no worries dude, i'm a big boy, and didn't take any offense in the first place. but it's great to see you speak up; not enough adults act like it, these days :)
04:42Glenjamin~mapply
04:42clojurebotYou have to do something like (defn mapply [f & args] (apply f (apply concat (butlast args) (last args)))), which just goes to show why unrolled keyword args are a bad idea
04:43Glenjaminzot: ^ is that the scenario?
04:45zotGlenjamin: not really. but your suggestion has a bonus: seeing 'butlast' for the first time :)
05:03dysfunwhat's the library that has a reloader for lein repl called?
05:07pepijndevoswut... my Aleph websocket is closed instantly.
05:08zotdysfun: https://github.com/stuartsierra/reloaded ?
05:09noncom|2Raynes ping
05:09Raynessup brotha
05:09dysfunzot: no, there's another module i'm thinking of. that does a quick scan of changed files. although i'm using reloaded workflow so i should probably figure out reloaded repl
05:10noncom|2i've just got a cery strange error within conch
05:10RaynesThat's a shame
05:10zotdysfun: if you figure it out, please share :) i've had mixed luck w/ reloaded
05:11noncom|2i use lein 2.x and when i don't say :aot [main.namespace], it works ok (except that lein complains that i should be explicit). when i do say than, an exception comes up: https://www.refheap.com/97846
05:11noncom|2the line that causes the exception is marked in the source sample
05:12noncom|2i think this is not conch error, but it is so strange one..
05:12noncom|2why would that happen?
05:12noncom|2(sorry for typos)
05:13RaynesThat's something wrong with your environment.
05:13RaynesI see ci related stuff in there
05:13RaynesDoes this happen in a repl?
05:13noncom|2no, a teamcity ci agent runs the jar
05:14noncom|2it works ok, if i remove the explicit :aot clause in project.clj.. but afaik lein does just that automatically if i don't say it.. the main ns also has the (:gen-class) ns parameter..
05:15noncom|2and how drop-last is different from any other clojure.core function... ?
05:17dysfunzot: hrm, i've just gotten reloaded repl working, but working is a strong thing to say because the moment i get an error, my repl module drops out of usability and i can't call the refresh function
05:18zotdysfun: sounds like exactly the fun i've experienced :)
05:20dysfunwell i can figure out how to get around that. I just need to hook it into cider and bind a keycombo to eval (require '[clojure.tools.namespace.repl :refer [refresh]]) (refresh)
05:21dysfuni wonder what other horrors it has lurking
05:21zoti copy gladly. i had other issues with it (namely files w/ protocols always breaking, and sometimes having it run alllllll unit tests, despite my best efforts).
05:21zoti haven't spent enough time to understand it better
05:21pepijndevosHmmmm it seems closing a manifold closes the whole chain. How do I stop this?
05:22pepijndevosI'm trying to do something like this: https://www.refheap.com/97849
05:24dysfunpepijndevos: pass downstream? false to connect
05:25pepijndevosdysfun thanks
05:25dysfunyw
05:25pepijndevosas a keyword, or just like that?
05:26dysfunyou pass a map as the last arg if you want to provide some
05:26dysfunand keyword
05:26dysfun(s/connect foo bar {:downstream? false})
05:27pepijndevoscool
05:27dysfunwhat are you building, out of interest?
05:28pepijndevosdysfun, connecting a Game Boy to the internet.
05:28dysfuncool!
05:28dysfunhow does that work then?
05:32pepijndevosdysfun, with a teensy and a WebRTC connection. Quite tricky. https://www.youtube.com/watch?v=0X6RxmUK6jA
05:33dysfunoh wow
05:34dysfun'TCPokemon' heh
05:34pepijndevosI'm now making the Chrome app that talks to the Teensy a little more robust.
05:34pepijndevosYea, that's what it's called for now, kinda cheesy, but hey.
05:35pepijndevosSo I'm using Aleph to do chat and initiate the peer connection
05:35dysfunnice
05:35dysfunwhy are you doing it in browser though?
05:36dysfuni suppose you could build a gameboy social trading network
05:36pepijndevosbecause that is the only platform that has easy access to USB hardware AND peer to peer connections.
05:36dysfun'easy access to usb hardware' wouldn't be my first guess :)
05:37pepijndevosthink again https://developer.chrome.com/apps/hid
05:37dysfuncool
05:37daniel`anyone can point me to the easiest way of getting a headless cljs setup with repl?
05:38daniel`lein template of some kind
05:38pepijndevosIf there was a good HID lib and WebRTC lib for clojure.... I'm not that big of a fan of chrome and webdev.
05:39dysfunpepijndevos: well actually, i might be able to help you there
05:39dysfunpepijndevos: i've been using
05:39dysfunlibwebkitgtk+ to embed webkit. so you can have the same apis through gobject introspection
05:40dysfuni haven't tried the clojure bindings myself because JNI is horrible
05:40dysfunwell, the java bindings
05:40dysfunalso i'm building something that wouldn't benefit terribly from the jvm
05:52pepijndevosdysfun, I don't know. I think a chrome app makes sense and is not terrible. I'm not sure if some webkit hack is worth the effort
06:00dysfunit is for me because i find javascript enormously tedious and clojurescript leaves a little to be desired on the 'instant feedback' front
06:00dysfunand i won't ever need to provide it over the web
06:39pepijndevosstaartuuuupp tiiiiimeeeee! (I can type this whole mesage between lein run and something happening)
06:40noncom|2probably we could rewrite lein in python to make it faster..
06:40noncom|2(joke :) )
06:43dysfunwow, tetrisql looks cool :)
06:43dysfunhttps://github.com/zilti/tetrisql
07:05noncom|2when creating an app with luminus template, what advantage is of http kit over the default ring-server do i get if i specify +http-kit ?
07:10noncom|2in other words, what is the difference between using ring and httpkit?
07:17dysfunhttpkit is asynchronous so you can handle more connections concurrently
07:18dysfunin theory, anyway
07:19samfloresnoncom|2: I think you wanna know the diff between *jetty* and httpkit, right?
07:20noncom|3samflores: oh, i know that: jetty is java io server, which makes a thread for every connection, and httpkit (i looked at the sources) uses java nio, correct?
07:21noncom|3so that's the only difference, looks like using httpkit is the better option anyway
07:26dysfunor you can use aleph, which uses jetty's asynchronous features
07:26samfloreswell, I wouldn't say it *is* the better option, but as dysfun said, it theoretically can handle more concurrent connections
07:26samfloresI tend to use http-kit due to its WebSocket support
07:27dysfunaleph also supports websockets :)
07:28dysfunpick the one you like the sound of better, tbh. they're both written by smart people
07:29samflorestrue that
07:29dysfuni quite like ztellman's other libraries which integrate quite nicely with aleph
07:30dysfuni also use a lot of ptaoussanis' modules, but they're fairly silo'd
07:33samfloresit was ptaoussanis' sente that led me to http-kit :p
07:33samfloresnow it works with immutant too. I need to try that
07:35dysfunsente is cool, been meaning to play with it
08:35EremoxIs a function which references a global but immutable variable considered referentially transparent? And not if mutable?
08:36justin_smithEremox: that sounds about right. Also, if it captures the variable at time of definition it can be pure even if the variable was mutable.
08:37justin_smithEremox: sometimes you can change a clojure function from pure to impure by changing fn-name to #'fn-name because the later is always delayed to be looked up at runtime. This can be useful when redefining things during development.
08:38EremoxU mean a closure? But what if is a ref then I would have to capture the value not the ref
08:38justin_smithEremox: all clojure vars are mutable
08:38justin_smiththat's what I mean
08:39EremoxDo you OK sorry I misunderstood but I get it
08:40EremoxAnd do you mean I define the fn with #'name or that I call (#'name)?
08:40justin_smiththe latter
08:41justin_smithin normal code, vars will be looked up at runtime, but if you bind something as a function arg or in a let block you need the #'foo form for runtime lookup, otherwise you capture and close over a value
08:42EremoxThanks for the info ;)
08:43justin_smithof course code which changes vars during a normal run isn't idiomatic. During dev you want to change vars though.
08:44EremoxDo you know a good article i can read to understand the reader. And what happens behind the scenes?
08:45justin_smithEremox: have you looked at the clojure.org docs for the reader? http://clojure.org/reader
08:46mavbozoEremox, there's a video How Clojure Works https://www.youtube.com/watch?v=8NUI07y1SlQ
08:46EremoxYeah was reading now. Great I will watch that video. Thanks.
09:23ila1222221In cls I'd like to make objects implement ISeqable...
09:23ila1222221How do I find out what the methods are to override?
09:23ila1222221clojuredocs has no entry for it
09:23ila1222221(ISeqable)
09:24puredangerthe only method is (seq [this])
09:25julianlevistonila1222221: http://swannodette.github.io/2015/01/12/lazy-contracts/
09:25julianlevistonhas an example of implementing it
09:26dnolenila1222221: it's not documented anywhere, another good idea for a community maintained wiki page though!
09:27ila1222221ok... so what is the path to discover the methods of any arbitrary protocol. is it something that can be done at runtime, or do you go through cljs or clj source code?
09:33ila122221blech crash.
09:37justin_smithila122221: protocols are implemented in clojure code, which means you can use clojure.repl/source to see their code
09:37puredangerSeqable is a Java interface. you will probably inevitably have to look through the Clojure source itself for the details of everything.
09:37justin_smithalso you can use clojure.repl/doc to see just the doc string
09:37puredangerthere is also a great scaffold generator …. looking
09:37justin_smithpuredanger: ahh yeah, fair point.
09:37puredangerhttps://gist.github.com/semperos/3835392
09:38puredangerthat's a pretty useful tool for this
09:38justin_smithso, pedantically you can see "the source for an arbitrary protocol" but ISeqable isn't a protocol :)
09:38justin_smith(inc puredanger)
09:38lazybot⇒ 32
09:38justin_smiththat's cool
09:39puredangeryou also may find this tool to be good for exploring the internal class structure of the Clojure impl https://github.com/stuartsierra/class-diagram
09:41ila122221oh wow that tool is awesome. i tried source and doc in a lein repl and it gives me nil, maybe a lein setting? i'll probably prefer stuarts lib though.
09:41justin_smithila122221: source and doc work for protocols
09:41justin_smithila122221: but ISeqable is not a protocol, it is an interface
09:41ila122221ah duh the I ok.
10:30trideondoes anyone know what is wrong with this code? http://pastebin.com/KpcMVZyD
10:34justin_smithtrideon: get does not work on lazy-seqs
10:34justin_smith,(get (range 10) 2)
10:34clojurebotnil
10:34justin_smithyou would need nth
10:34justin_smith,(nth (range 10) 2)
10:34clojurebot2
10:35trideonthanks
10:36justin_smiththe NPE happens in the > call (getting a value that is nil thanks to get)
10:36justin_smith,(> nil Math/PI)
10:36clojurebot#<NullPointerException java.lang.NullPointerException>
10:37justin_smithalso, as a style thing, you might like (pos? (mod % p)) better than (not= (mod % p) 0)
10:37justin_smithbut that's six / half-dozen
11:37mmitchellIs there a default timeout value for deref?
11:38stuartsierrammitchell: no, it will block forever
11:38mmitchellok thanks stuartsierra
11:42justin_smithmmitchell: but deref does take a timeout arg optionally of course
11:43justin_smith(I frequently forget this)
11:43mmitchellyeah nice feature
11:43Glenjamin(doc deref)
11:43clojurebot"([ref] [ref timeout-ms timeout-val]); Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction, returns the in-transaction-value of ref, else returns the most-recently-committed value of ref. When applied to a var, agent or atom, returns its current state. When applied to a delay, forces it if not already forced. When applied to a future, will block if computation not complete. When applied to a promise
11:43Glenjamin(inc justin_smith)
11:43lazybot⇒ 198
11:44Glenjamini'd never noticed that before
12:02mmitchellanyone here familiar with http-kit's :timeout option?
12:02mmitchellclient
12:14pepijndevosWhat is the key for in add-watch?
12:16Glenjaminpepijndevos: it's just a name
12:16Glenjaminyou can use it to replace a watch
12:16Glenjaminor remove-watch
12:18pepijndevosthanks
12:22justin_smithmmitchell: it cancels the request if the server takes too long to respond. Do you have a more specific question about it?
12:25mmitchelljustin_smith: yeah, just that it doesn't seem to behave consistently. I have a test server setup that blocks for 5 seconds. I set the :timeout option to 3000, and wrap that with the time macro.
12:25mmitchellMy test server blocks for 5 seconds, and I get the response successfully
12:25justin_smithoh, weird
12:25mmitchellthe time macro reports just a little over 5 seconds
12:25mmitchellyeah it is
12:26justin_smithmmitchell: oh, are you using conn-timeout or socket-timeout?
12:27justin_smithbecause socket-timeout is a socket pool option (for pooling client connections for reuse)
12:27mmitchellgood question. I'm not sure. it's just the :timeout option.
12:28justin_smithand the timeout logic may be more about timing out on initial handshake, rather than timing out on getting the result
12:28mmitchellyeah that would make sense
12:28justin_smithmmitchell: I don't even see a unqualified "timeout" key being used https://github.com/dakrone/clj-http/blob/master/src/clj_http/core.clj#L207
12:30justin_smithmmitchell: and as you can see here, all the client methods are just calls to that request function https://github.com/dakrone/clj-http/blob/master/src/clj_http/client.clj#L838
12:30mmitchelljustin_smith: oh this is http-kit - http://www.http-kit.org/
12:30mmitchellsorry
12:30justin_smithargh, I'm sorry
12:30mmitchellno worries!
12:34xemdetiaMORE SORRY
12:37justin_smithmmitchell: and this is an async request? because the docs for clj-http.client/request suggest that for synchronous requests you should instead use deref with the optional timeout args
12:38mmitchellyeah, this is using http-kit's "request" function. It has a :timeout option here - https://github.com/http-kit/http-kit/blob/master/src/org/httpkit/client.clj#L135
12:38justin_smithmmitchell: right, that's the doc I am reading
12:38justin_smithit suggests using deref for sync
12:38justin_smithand :timeout for async
12:39mmitchellahh I see. The deref w/timeout works as expected (sync)
14:02fellipebrito[noob/starting here] Reading The Joy of Clojure yesterday. On a single example the guy moved things inside the main defn as much as he could.
14:02fellipebritoIt is completely the opposite of OO, when you try to use few lines inside your method, and organize it better with the principle of a method executes only one action.
14:03agarman@fellipebrito functions should do one thing only
14:03agarman@fellipebrito just like methods in OO
14:03fellipebritoI've studied and pushed my team to write a great code, following best practices and tons of other things that are out there on the ruby community.
14:03agarman@fellipebrito beginner books don't always demonstrate the best examples up front
14:04fellipebrito@agarman sure thing
14:04fellipebrito@agarman maybe I'm too raw, I will keep reading the book, but would ike to hear from you guys
14:04agarmanbtw, what page are you referencing?
14:06fellipebrito@agarman I will look for it later and get back to you
14:07fellipebrito@agarman thank you!
14:08fellipebritoBy the way. I have the book Clean Code here. How you guys see it being applied to Clojure?
14:10agarman@fellipebrito I like Agile PPP in C# by same author. SOLID & YAGNI apply to well written programs.
14:13justin_smithfellipebrito: some things that are slightly different with Clojure - for immutable data (which is what most things should be), there is less benefit for making it private or encapsulating. So well written idiomatic Clojure code will often pull things out of a private or closed over scope to be an immutable global.
14:14fellipebrito@justin_smith Thank you! For me it is still a "huge mess". I love the code as data idea, but everytime I open a file It takes some minutes until I feel comfortable reading the code. I'm used to read any well-written ruby code in seconds.... I will keep studying and pushing hard to get the 'clojure-way'
14:15justin_smithfellipebrito: also, because the clojure compiler demands that definitions be declared or bound before being accessed, the quickest way to read a normal namespace is usually from the bottom of the file to the top
14:16agarman,(declare maybe)
14:16clojurebot#'sandbox/maybe
14:16justin_smithevery once in a while you will see code that is organized top to bottom with declare
14:16justin_smithbut that's rare in practice
14:16justin_smithso you should not expect it as a reader of code
14:17fellipebrito@justin_smith I will buy some mangas alongside my new clojure books :)
14:17justin_smithhaha
14:17TimMc"declare" usually means "lots of mutually recursive code ahead"
14:17justin_smithit's just a rule of thumb that works well for me when I decide to read clojure code - I take a peek at the top, and most of the time the next step is to jump to the bottom of the file and scroll up
14:17agarmanyep, declare is a spaghetti crossing sign
14:17fellipebritoI do not want to write "ruby code" in clojure. I am trying to "get the groove"... the community helps a lot. Thank you guys
14:17justin_smithif I see a nice big comment block at the top of the file, and / or usage of declare, then I read top down
14:18TimMcfellipebrito: IRC convention doesn't use the @ sign, by the way.
14:18fellipebritothanks TimMc
14:18agarman@TimMc I started that above...my bad :-p
14:18TimMcIf you leave it off, people are more likely to be notified by their IRC clients that you're talking to them.
14:18TimMchah
14:19fellipebritoTimMc you see... you started above, but if I read bottom - top, I will not see the error and I will start the right way.
14:19pepijndevosCan I somehow auto--reload an Aleph app? the startup time is killing me. I could have written another app in Java it the time spent waiting.
14:19fellipebritoThank you justin_smith agarman and TimMc
14:19TimMcjustin_smith: I usually read from the top when I'm reviewing code, although I don't know that that's really the most efficient approach.
14:20agarmanpepijndevos: can't you just recompile files into running app?
14:20pepijndevosagarman, maybe? How?
14:20justin_smithTimMc: often there are one or two functions that are kind of "the reason this namespace exists", and it helps me to see those defs before looking at the details, and they are very likely to be at the bottom of the file
14:21agarmanpepijndevos: I just reload file through emacs
14:21Glenjaminthats my biggest bugbear in clojure, that i have to read from the bottom of the file
14:21pepijndevosuh... emacs?
14:21justin_smithpepijndevos: if you have a repl open, (require 'some.ns :reload)
14:21Glenjaminnot that it's a big issue really
14:21agarmanpepijndevos: if your in Intellij, using Cursive, you can do the same thing
14:21pepijndevosI see...
14:21agarmanpepijndevos: or exactly what justin_smith said
14:22justin_smithpepijndevos: most editors have some "reload project" function, but it's just going to call that one liner I posted anyway
14:22pepijndevos:)
14:22agarmanpepijndevos: or :reload-all if there's a whole lot of changes
14:22justin_smithyes, that's a good point too
14:23agarmanin my own web app, I (stop) (require 'core.stuff :reload-all) (start)
14:23justin_smithI should have said "reload namespace" rather than "reload project" above
14:23TimMcwhich is great until there are defrecords or protocols or multimethods :-P
14:23justin_smithhello, component
14:23agarmanyeah TimMc got some of those and it super not fun
14:23TimMcjustin_smith: ssshhhhh
14:23agarmanyep
14:23TimMcssshhhh
14:24TimMc(One of these days I will get around to using that.)
14:24agarmansame
14:24agarmanstill less time wasted than would probably take to migrate everything into component or similar
14:46fellipebritoAny of you guys trying to use clojurescript + Phonegap (or something like that) = nativeapps?
14:58dysfunlighttable is a native app using node-webkit. but i'm guessing you meant for phones. the phonegap desktop stuff is... a little sketchy
14:58nkozafellipebrito: if you google "clojurescript phonegap" you can see some examples
14:59nkozafellipebrito: there is also ongoing work to integrate Clojurescript with React Native, so you can use iOS/Android from CLJS
14:59fellipebritodysfun nkoza my main goal are iphone and android native apps, but not using only a webview... you know apple hates it.
15:00dysfunthere's a clojure->ios thingy
15:00nkozafellipebrito: check this: https://code.facebook.com/videos/786462671439502/react-js-conf-2015-keynote-introducing-react-native-/
15:00nkozafellipebrito: and this: https://github.com/omcljs/ambly
15:00fellipebritonkoza Praise the lord
15:01dysfunooh, nice
15:10ToxicFrogDoes pprint have the same guarantee as prn in that it emits something the reader can consume?
15:13gfrederickseehch
15:17chouserToxicFrog: prn doesn't have that guarantee either, as far as I know.
15:17chouser,(pr-str (Object.))
15:17clojurebot"#<Object java.lang.Object@7799cdd5>"
15:17amalloyprn produces something the reader can consume when it can
15:17chouser,(read-string (pr-str (Object.)))
15:17clojurebot#<RuntimeException java.lang.RuntimeException: Unreadable form>
15:17ToxicFrogchouser: (doc pr) says it does
15:17justin_smith,(doc pr)
15:17clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
15:18ToxicFrogI mean, obviously this isn't universally possible, but it guarantees that it will if it can
15:18ToxicFrogSo I know I can throw a map full of keywords and strings at it and get something that I can read back in later.
15:19chouserYeah. I think that should work approximately as well with pprint as with prn
15:20mikerodDoes it matter if type-hints are Symbols representing classes or actual Class objects themselves?
15:20amalloymikerod: they should be symbols
15:21hexaHi, I have this weird problem if I do like (do (map println '(1,2,3))) with lein-exec plugin , nothing prints out.... , without map all is fine,,, ideas??
15:21lazybothexa: Definitely not.
15:21amalloy~lazy
15:21clojurebotlazy is hard
15:21amalloyer
15:21amalloy~map
15:21clojurebotmap is hard
15:21amalloysure
15:21justin_smithhahaha
15:21justin_smithhexa: map is lazy
15:21hexahaaaa domap...? or similar
15:21justin_smithdoall
15:21hexarigh thx!!
15:21mikerod_,(-> #'str meta :tag type)
15:21clojurebotjava.lang.Class
15:21hexaI was getting crazy since it worked ok on the repl hehe
15:22justin_smithhexa: or dorun since you likely aren't using the return value
15:22mikerod_amalloy: this seems inconsistent
15:22justin_smithhexa: right, printing forces laziness
15:22mikerod_I thought it should be symbols too
15:22mikerod_but I see a mix
15:22hexa:)
15:22justin_smith(and Print is the P in rePl)
15:23mikerod_,(-> #'realized? meta :arglists first first meta :tag type)
15:23clojurebotclojure.lang.Symbol
15:23mikerod_I'm guessing the compiler is dealing with symbols and classes interchangably
15:24mikerod_it is always awkward in situations where you have to chose which one is right for a type hint, if you are doing something like writing a macro.
15:24amalloymikerod: the hints on arglists are not the same as hints on vars. the compiler does not treat them the same; i wouldn't try comparing them
15:24amalloymikerod_: it is very easy. always choose a var
15:24amalloyer, a symbol
15:24mikerod_amalloy: I see... :)
15:25mikerod_I see some places in the compiler explicitly referring to `tag` fields with type Symbol, so that does seem to be the wise choice
15:25amalloythe :tag metadata on vars may be symbols, it may be classes, who cares - the important thing is that in the *source code* the compiler reads, it should be symbols
15:26hiredmanstrings
15:26mikerod_oh
15:26amalloywell. sure. that's fine too i guess
15:26amalloybut a human being can type a string or a symbol into source code, and they can't type a Class object out and save it in their .clj file
15:26amalloythe compiler is supposed to consume stuff you could have typed
15:28hiredman,((fn [^foo/String x] (.toString x)) "Foo")
15:28clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: foo/String, compiling:(NO_SOURCE_PATH:0:0)>
15:29hiredman,((fn [^foo/java.lang.String x] (.toString x)) "Foo")
15:29clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: foo/java.lang.String, compiling:(NO_SOURCE_PATH:0:0)>
15:29mikerodamalloy: I'm able to not fail though with classes
15:29mikerodlike (eval (let [sym (with-meta 'a {:tag String})] `(let [~sym "a"] (-> '~sym meta :tag type))))
15:29mikerodI'd think that would break
15:29mikerodits fine, I'll stick to symbols
15:29mikerodI'm just curious how it keeps working out for me to use embedded classes instead
15:29amalloymikerod: sure, some things work. you can add #_#_#_#_#_3 anywhere in your source code and it works fine
15:30amalloylikewise (eval (fn [])) works, but you're not supposed to do it
15:31gfredericks(defn set-foo [x] (def foo x)) also works fine and you're also not supposed to do it
15:32gfredericksFSVO "supposed"
15:32hiredmanfsvo of works fine
15:32mikerod:D
15:32justin_smithgfredericks: also, (System/exit 42) can replace any program
15:33justin_smithit's a proven fact
15:33chouser(swap! x prn) ; fsvo works fine
15:33mikerodall good points
15:33hiredmane.g. if people do that expecting scheme's local defines, that doesn't work
15:33gfredericksyeah true
15:34hiredmanif you do that, and expect clojure to still throw an error compiling forms that reference foo because you haven't run the function yet, that doesn't work
16:02oskarthUsing secretary, is there something I have to do server-side in order to get dispatch to work when changing the URL? Adding `(defroute foo "/bar" [] ...)` and clicking a link `href="#/bar` doesn't do anything, but running `dispatch!` manually in browser-repl works.
16:18oskarthproblem was with listening to 'navigate' event
16:25augustlis there a canonical setup for using clojurescript to develop code for running in node.js?
16:44nuwanda_oskarth: yeah, I've only used secretary on a small project and i didn't have time to figure out what I was doing wrong so I simply had those links directly dispatch
16:45nuwanda_I'm sure there's another (proper) way to do it though
16:55augustlemacs indents clojure like in "actual.clj". How do I make it indent the way it is in "want.clj"? :) https://gist.github.com/augustl/7b028e1cadc498809e56
16:55augustlI don't want nested data structures to align to the opening symbol, I want it to indent like normal code
17:00justin_smithaugustl: hanging open symbols aren't very popular in this language family
17:00justin_smith*open delimiters
17:00amalloyyour "want" is weird as heck. it doesn't look like "normal code"; normal code in clojure looks like actual
17:01augustlis it really that weird? The code is from David Nolen's leiningen templates
17:02augustlI found the extra spaces that emacs added when I indented the generated project.clj pretty unhelpful
17:03augustlthe rule seems pretty simple to me, indent nested data structures the way builtins like "do", "if", etc are indented
17:03justin_smithaugustl: that's not what it is though. It's indenting based on trailing open delimiters C style
17:04hiredmangross
17:04TimMcHere's a thing I think I'd like to be able to do: https://www.refheap.com/97878
17:04amalloyaugustl: do you have a link to whatever code from dnolen you copied?
17:04TimMcBasically, "footnotes" in functions so that I can attach logging statements and the like unobtrusively.
17:05augustlamalloy: sure, https://github.com/swannodette/mies-node-template
17:05augustlspecifically https://github.com/swannodette/mies-node-template/blob/master/src/leiningen/new/mies_node/project.clj
17:05amalloythat is really weird. i don't know why he is writing it that way
17:06augustlperhaps it's an intellij thing or something
17:06TimMcThe syntactic transform would look like this: https://www.refheap.com/97879
17:08amalloyTimMc: it's less featureful/flexible, but for simple cases flatland.useful.debug/? does similar stuff
17:09turbofaili feel like that indentation style does make some amount of sense for maps
17:09augustlturbofail: not sure what's not to like about it :)
17:09turbofailit's nice to be able to keep the keys and values together without having them push too far to the right
17:10turbofailthat said i still use the emacs default style
17:11turbofailand i don't know if there's any straightforward way to make emacs do that
17:11TimMcamalloy: The forms I'm looking to attach do all sorts of things: Logging, debug printlns, metrics, debug response headers... basically, I want to get all that crap out of the main control flow and logic.
17:12amalloyTimMc: it sounds kinda like you are looking for haskell's where instead of let?
17:12TimMcI know that dire does some of that, but it only applies at var boundaries.
17:12TimMcTell me about this "where".
17:12amalloyTimMc: it's just a let with the bindings after their use instead of before it
17:13TimMcNah, I want to be able to intercept values within an expression and have the intercept logic be all shoved down to the end of the fn.
17:14hiredmanI do something like that in my raft implementation
17:14amalloyTimMc: but like, your example is just defining a function named † and calling it
17:14hiredmanhttps://github.com/hiredman/raft/blob/master/src/com/manigfeald/raft/rules.clj#L101-L115 bindings at the end
17:15amalloywith the definition of † at the end of your "primary" function instead of at the beginning
17:15TimMcamalloy: Ah! The transformed version, yeah.
17:15hiredmanoh, nope
17:15hiredman(I just saw "haskell's where")
17:17TimMcMy coworkers might kill me if I put non-ASCII in our source files.
17:17amalloyas well they should
17:18amalloythey might symbolically leave a flaming 💩 on your doorstep
17:19TimMchah
17:19TimMcOh man, this looks so much nicer, though.
17:19TimMc(defmacro essentially [& args] `(let ~(last args) ~@(butlast args)))
17:21TimMchttps://www.refheap.com/97879 so good
17:21amalloyTimMc: that is *definitely* just where
17:21TimMcyeah
17:21amalloywhich is fine, where is cool
17:21TimMcI *could* do *1, *2, *3 and so forth, even though it shadows clojure.core stuff.
17:22TimMcThose don't get used in main source, right? And they're lexical, so there's not even a warning.
17:22amalloyyou'd get a warning from eastwood
17:22TimMcWhat doesn't.
17:52TimMcamalloy: Not quite good enough, upon further reflection. This doesn't give me the ability to use the lexical scope of the places the spy expressions are referenced. What I really want to do is inject aspects...
17:53TimMcAm I reinventing Spring? Please tell me if I'm reinventing Spring. I don't want to be that kind of person.
18:50crazydiamondHi. How to check what kind of value I'm dealing with? E.g. is it map, vector/list or scalar-like? I tried like (instance? (class {}) v), but failed 'cause (not= clojure.lang.PersistentHashMap clojure.lang.PersistentArrayMap)
18:50justin_smithcrazydiamond: map?
18:50justin_smith,(map? {})
18:50clojurebottrue
18:50crazydiamondyep :)
18:50crazydiamondthanks
18:50amalloycrazydiamond: but don't use list?
18:51crazydiamondamalloy, why?
18:51justin_smith~list?
18:51clojurebotexcusez-moi
18:51amalloycrazydiamond: seq? is a function that does what you actually *want* list? to do, whereas list? does something that is not useful
18:51Bronsa,(list? (cons 1 nil))
18:51clojurebottrue
18:51justin_smith,(list? (list 1 2 3))
18:51clojurebottrue
18:51Bronsa,(list? (cons 1 ()))
18:51clojurebotfalse
18:52crazydiamondyep, I see
18:52crazydiamond,(list? [])
18:52clojurebotfalse
18:52crazydiamondthanks!
18:52aperiodic,(seq? [])
18:52clojurebotfalse
18:52crazydiamondoops
18:52aperiodic,(sequential? [])
18:52clojurebottrue
18:52crazydiamond:)
18:52aperiodic,(sequential? (list 1 2 3))
18:52clojurebottrue
18:53aperiodic,(sequential? (cons 1 nil))
18:53clojurebottrue
18:54aperiodicoh and also ##(vector? [])
18:54lazybot⇒ true
18:57aperiodiccrazydiamond: you should probably study the "type tests" subsection of the "collections" section of the clojure cheatsheet: http:///conj.io
18:57crazydiamondaperiodic, thanks. I believe I should study the whole
19:39coventryDoes anyone here use scala with emacs? Does it have anything like cider? I've been playing with ensime, just started looking at sbt-mode.
19:56jodarocoventry: i think M-x sbt-start does something similar
20:22crazydiamondHi. Is there shorter way to write (fn [x] x)?
20:22justin_smith#(do %)
20:22crazydiamondthx
20:22crazydiamond'cause #(%) is trying to call the arg
20:22justin_smithof course you can always do (def i identity) and then just use i
20:23justin_smithright
20:23amalloythe shortest way to write something is not usually the best way
20:23justin_smithcan't get shorter than a one letter function name
20:23justin_smithamalloy: excellent point
20:23amalloyjustin_smith: new programming language: features 0-character identity function, implicitly added before every value
20:24justin_smithhahaha
20:24amalloyanalysts amazed that this is indistinguishable from previous languages
20:25justin_smithoooh - you could define a unicode composing character, so when you call it on a value it shows up above or below the first letter of the arg, instead of as a separate word
20:25crazydiamondamalloy, well, in my case I asked that only for experiments in REPL
20:25justin_smithnot that this would confuse anyone at all!
20:26amalloyjustin_smith: ẍ is (identity x) in this groundbreaking new language
20:28justin_smithright
20:29justin_smithwe could use the little tail that Spanish puts on the letter ç for deref (it would be a little tail on the first letter of the binding's name of course)
20:29crazydiamondif ẍ doesn't matter
20:29crazydiamondI mean, if ẍ is a funciton
20:29crazydiamondso x itself doesn't matter
20:31amalloyjustin_smith: spanish doesn't use the cedille for anything, you're thinking of french
20:32justin_smithoops
20:32amalloyalthough apparently it used to, though
20:32amalloycalling it cedilla
20:34justin_smithahh, used in Portugese too I see
20:34justin_smithI misremembered which one semester middle school foreign language class had introduced that letter
20:34nuwanda_definitely portuguese too :p çç
20:35rpauloyup..
20:36rpaulojustin_smith: "used in Portuguese" is incorrect. It still uses it and will continue to use it for the foreseable future
20:36rpaulojustin_smith: ugh, I misread.
20:36justin_smithrpaulo: I meant the present case
20:36justin_smithit's OK
20:37rpaulo?
20:37rpaulolooks like my IRC client can't even display it
20:37justin_smithdoesn't send it it looks like
20:38crazydiamondç
20:38crazydiamondäåéëþüúíóöáßðïœøæœ©®bñµç
20:39crazydiamondseems it's displaying fine
20:39rpauloç
20:39rpaulook, I was using the JIS encoding
21:31codesineHi all, looking for guidance regarding ring or compojure.
21:32codesineI want to start with learning ring to do webapp development, and have been going through this resource: https://brehaut.net/blog/2011/ring_introduction
21:32codesineAre there any recommendations (possibly more up to date items?)
21:33justin_smithcodesine: I don't see anything out of date there, anything else usually is built on ring
21:33justin_smithand a lot of people still use compojure
21:33codesineoh cool, so i can go by that
21:33justin_smithit's definitely a good starting point yeah
21:34codesinesee I'm confused as to where ring and compojure stand, is ring just a third party library the same as compojure?
21:34justin_smithring is an api that wraps various web servers with a common interface
21:34justin_smithcompojure is a routing lib
21:34codesineah got it
21:34codesineYeah, I was looking at this luminusweb item, but, I get confused because it seems to be doing things for me
21:35amalloycodesine: but yes, it is also a third-party library, not associated with clojure the language
21:35codesineAh ok.
21:35justin_smithpeople write various adaptors so that you can use eg. aleph, or jetty, or http-kit or tomcat but via the ring api
21:35codesineis there something in clojure core that does http serving etc?
21:35justin_smithno
21:35codesineok gotcha both
21:36justin_smithcodesine: since the jvm is so "batteries included" and there are so many libs for java that are easy to use via interop, clojure's core tends to be abstract stuff
21:36codesineah
21:36justin_smithlibs for specific pragmatic things will be adaptors or wrappers that are not part of hte core lang
21:36justin_smithtypically at least
21:36codesineYeah, see, I am worried to use luminusweb or compojure -- because I think that it will allow me to take things for granted
21:37codesineso it _is_ ok to start with ring, and do a pure web app in ring
21:37justin_smithso clojure.core is all about data types and protocols etc.
21:37codesinelike a todo list to get my feet wet
21:37justin_smithright
21:37justin_smithI think that's a good idea
21:37justin_smitheventually how ring does things will matter
21:37justin_smith(unless you use one of those rare web libs for clojure that don't use ring)
21:37codesineyeah when i looked at the dependencies for luminus and compojure I made :/ face when it was a buncha libraries i'm not familiar with lol
21:38codesineah
21:38codesineso i'm thinking if I were to do a todo list that would interface with mongodb
21:38justin_smithcodesine: luminus is just making a bunch of good default library choices for you
21:39codesineI'd just need something like monger
21:39codesineand ring
21:39codesineand i can do sessions in ring anyways
21:39justin_smithsure
21:39codesineok
21:39codesinenothing else i might need right?
21:39codesineI'm just not confident lol
21:39justin_smithbut looking at the default luminus project.clj, there's nothing in there I have not had to use, and nothing I totally hated. So that's cool.
21:39codesinei will look at the dependencies, and learn some of them little by little
21:40justin_smithyou can use monger and ring, sure. As long as you understand the pitfalls of mongodb of course :)
21:40codesineI've always used sql, i just finished one of the 10gen courses
21:40codesinelol
21:40codesinefigured i might as well put myself out of my comfort zone
21:40codesinemonger ring and selmer (:
21:40justin_smithcodesine: after you get your bare bones server running, take a moment to look at the github project (at least the readme) for each luminus dep. They are all useful for a backend web stack.
21:41justin_smithfor the bare bones you can even leave out selmer, but you still probably want compojure (or some routing lib)
21:41justin_smithunless you want a case statement with regexes and the :uri key of the request or something
21:41codesinein the lazy sequence blog it details how to do routing with ring
21:41justin_smithfollow the guide from brehaut, it is decent
21:42codesinei figured i'll make it hard on me and do it manually from the request mapping
21:42codesine(<
21:42justin_smithcodesine: that's not ring, that's compojure, from what I see
21:42codesineat the very top
21:42codesineit is ring
21:42codesinethen he shows how to do mustache
21:42codesineand compojure
21:43justin_smithoh, OK, at the very very top
21:43justin_smithyeah, you are right
21:43codesineya!
21:43ob_i really enjoy sql for its proximity to the data. is clojure similar in that regard?
21:43justin_smithinstead of his usage of moustache, you can swap in selmer
21:44justin_smithob_: clojure has a very data-first philosophy yes
21:44codesineyeah i heard moustache wasn't used as much?
21:44justin_smithcodesine: that may be the one out of date thing in this intro
21:45codesineyeah i'm gonna primarily use only the ring part, and do the routing myself for a learning experience (tedious, but just to instill it more firmly heh)
21:45codesinehigh5 justin_smith
21:45justin_smithbest of luck, I do back end web stuff in clojure as my full time job, and I love it
21:45justin_smithit's a great stack
21:45codesineI do python and django, so i've been just spending 2 hrs a day trying to pick this up
21:46codesineI'm doing that there brave clojure tutorial
21:46codesineI do have the 2nd edition of joy of clojure
21:46codesinebut it's over my head
21:46justin_smithI don't think many of the web-specific parts will be new or surprising if you do django already
21:46codesineD:
21:46justin_smithbut have fun with the clojure stuff :)
21:46codesineoh and 4 clojure
21:46justin_smithyeah joy of clojure is not introductory level material for most people
21:46codesinethanks
21:46codesinei have the other 2 yr old book, clojureprogramming from oreilly
21:47justin_smithyeah, 4clojure is good too, especially if you look at solutions from more experienced users after you solve it yourself
21:47codesinebut damn me if i can focus enough to read 600 pages
21:47codesineya!
21:47justin_smithhaha
21:47codesineexactly
21:47codesinethere was some really terse solutions
21:47codesinethen i realize
21:47codesinewtf
21:47codesinethis is really short but unreadable
21:47codesinethen i realized there is code golfing...
21:47codesineD:
21:47justin_smithwell, a lot of it is more readable once you know the style / idioms
21:47justin_smithand yeah, some people are golfing (4 is a pun on fore)
21:48codesinehaha
21:48codesineyeah i could understand it
21:48codesinebut i realized, it was abusing a trick
21:48codesineto be shorter
21:48amalloyjustin_smith: the name 4clojure is totally not related to the fore in golf
21:48justin_smithoh? never mind then
21:48amalloyi've never heard anyone make that connection before, actually
21:48justin_smithI totally thought it was a pun
21:48codesineno i think he means
21:48amalloyjustin_smith: it's a pun on foreclosure
21:48codesine4 as a pun on fore
21:49codesineread 4clojure as foreclosure
21:49codesineforeclosure on a home lol
21:49justin_smithright
21:49amalloybut the golfing features were added later on, by a different person than the one who named the site
21:49codesineit's cool some solutions of people i follow (those who answered all 156 questions)
21:49codesinecode how i think
21:52bashedIs it possible to import a java class without loading it? It seems like clojure does that. I need to reference some java classes that depend on that.
21:53codesineI'm a clojure beginner but I think (require) does that
21:53codesinemaybe someone else can correct me if i'm wrong
21:53justin_smithcodesine: require is for namespaces / clojure code
21:53amalloyno, that is not consistent with how classloaders on the jvm work
21:53codesineohh... so i'm wrong
21:53codesineidk bashed, justin prob knows (<
21:54justin_smithcodesine: import is for jvm level classes (usually java code, but maybe also a record or deftype sometimes)
21:54justin_smithor amalloy :)
21:54codesineoh ok, so i'll use import if i ever want to do what bashed does
21:54justin_smithamalloy: is there a behavioral difference between using import or not using import and just using the fully qualified package name?
21:55amalloyjustin_smith: no
21:55justin_smiththat's what I thought, just double checking
21:55justin_smithamalloy: does referencing a class in a function that gets compiled force some initialization then?
21:56amalloyjustin_smith: it causes the class to be loaded when the function is compiled (if it wasn't loaded already), which runs the class's static initializers
21:57justin_smithaha, yeah, I can see where that would be an issue for badly designed classes
21:58codesineI wonder if it's advisable to make an attempt to read o'reilly's clojure programming back to back with coffee as fuel (:
21:58justin_smithyou'd probably learn more if you went slower and did things in the repl to test what you think you are learning
21:59codesineyeah i've done it with clojure for the brave and true
21:59codesinejust hand typed everything
21:59justin_smithclojure is very repl freindly - more than most languages the interaction in the repl really follows all the same rules as code in files
21:59codesineok thx for everything
21:59codesinei'll try to be a regular here from now on xD
21:59hiredmanhttp://dev.clojure.org/jira/browse/CLJ-1315
22:00codesinei just discovered (clojure.walk/macroexpand-all)
22:00codesinethis helped me with some questions i had in my head
22:00justin_smiththat's a helpful one
22:01codesinehow'd you start when you were a clojure padawan
22:01codesinesince you do it for work now
22:01justin_smithme? I got hired because an old friend knew I was into FP.
22:01justin_smithand I learned it on the job.
22:01codesinecome to think of it for every language i've learned i've never read a book front to back
22:01justin_smithI was mostly using OCaml and Scheme until I got hired
22:01codesinescheme is cool
22:01justin_smithindeed
22:02codesineesp that gambit scheme
22:02justin_smithml and scheme turned out to be a great combo of things to make learning clojure easier
22:03justin_smiththe jvm part took me longest
22:03codesine-_-;;;;;; i started with ansi c and then python
22:03codesinei never learned java tho
22:03codesinei can use the interop with just googling so not worried -- mostly just interested in idiomatic clojure stuff
22:03justin_smithbut with some c and python experience, at least the javadoc for the included libs with the jvm should be readable
22:03codesineso this stuff really busts my head
22:03codesineyeah
22:04justin_smithfor idiomatic clojure, another thing is to read code by people who know the language well
22:04codesinei take peek at random github repositories and try to understand what i can or the solutions on 4clojure
22:05justin_smithamalloy_: (for example the flatland/useful lib) or seancorfield (who also hangs out here, he works on clojure.java.jdbc among others), stuartsierra
22:05justin_smithsorry, didn't mean to tag amalloy_ there, just listing him as someone with good code to read
22:05codesinei've saved this irc buffer so i don't lose anything
22:06justin_smithhiredman also has some good stuff on github to learn from
22:06justin_smithheh
22:06justin_smith(I've definitely been there)
22:06codesinewhere i'm at? nonsense
22:06justin_smithcodesine: getting suggestions and then just deciding to save the whole irc transcript to go through later? yeah, done that a few times
22:07codesinethis is the second time i've used irc, never realized it was so helpful, this is not clojure related but if it'sok to ask, irc just let's you key in a handle and it joins the room with the handle, what's to keep another person from logging in with your name
22:07codesineyeah, in another saved buffer in emacs heh
22:07justin_smithcodesine: register with nickserv
22:08codesinekk
22:08codesinety
22:08justin_smithvia nickserv you can boot someone using your handle without permission
22:08justin_smithand people can check if you are registered with nickserv (though how often someone actually does that is another question)
22:09codesinei've just registered
22:09justin_smithcodesine: another caveat about that brehaut article - I wouldn't use Korma or ClojureQL
22:10codesinekk
22:10codesineoh crap forms and sessions
22:10codesinei'll figure it out (will prob check luminus dependencies and learn one of those)
22:11codesineok going to study some more now
22:11codesine*waves all*
22:11justin_smithoh, haha, luminus uses korma. I mean it's not totally terrible, but...
22:11codesinei don't wanna use korma
22:11codesinei just wanna use mongodb
22:11codesineprob that monger thing
22:12codesinedo you have a recommendation for postgres then?
22:12justin_smithI like yesql but have not used it in anger
22:12justin_smithit compiles regular sql files into clojure code you can call
22:12justin_smithclojure.java.jdbc is totally usable
22:13codesinejustin_smith: got it -- bbl and thanks for all