#clojure logs

2012-06-28

00:24gerthi! Is there a way to get the values of a transient map? (vals (transient {})) doesn't work (because the transient map doesn't implement ISeq)
00:55denysoniquehey
00:55denysoniquejava.io.FileNotFoundException: Could not locate clojure/string__i
00:55denysoniqueI installed Clojure by apt-get install clojure on Ubuntu
00:56denysonique(use 'clojure.string) throws the above error
00:56mybuddymichaeldenysonique: Use leiningen instead.
00:56TheBusbydenysonique: you probably want to use leiningen instead
00:56denysoniquethanks
01:06technomancyRaynes: most conference recording is very short-staffed, but I think in the case of InfoQ they spread them out to guarantee a continual stream of traffic
01:16lynaghk`New C2 release, including some new data-binding and computed-observable stuff that may be of interest to anyone developing cljs apps: https://groups.google.com/forum/?fromgroups#!topic/clojure/KCe96DbMD6k
02:24ktsujitechnomancy: I've started using leiningen2 and found that when I use lein run, "All namespaces already :aot compiled." is outputted to stdout even after it has been compiled once.
02:24ktsujithis didn't happen in leiningen1 but is there a way to turn off that output? I did some searching but could not find out the solution so far.
02:27ktsujithis goes the same with lein trampoline run as well.
02:28ktsujiI'm using Leiningen 2.0.0-preview7.
02:34antares_ktsuji: can you post your project.clj?
02:34SrPxWhen I define a function with (defn [a b] etc...) can I get the form I used after?
02:35SrPxI read clojure programs can modify clojure programs easily. What that is supposed to mean.
02:36antares_SrPx: defn just defines a var but you can print it back to string that Clojure reader can read
02:37SrPxwhat?
02:37antares_I think "loading code and transforming it" case is pretty rare. It is more common to use a concise DSL that generates forms once.
02:37antares_SrPx: lets start with what Clojure reader is
02:37antares_SrPx: do you know what parser is?
02:38antares_parsers take strings and produce abstract syntax trees, a tree of code elements
02:38antares_in Clojure, they just produce Clojure forms
02:38antares_,(read-string "1")
02:38antares_clojurebot: hello?
02:38SrPxbut for example, I want to code a function search functionality that will search for some patterns on my source code's functions... I wonder if that is possible (I mean besides the ugly way)
02:38SrPxantares_: hm
02:39amalloyantares_: clojurebot is dead, long live lazybot
02:39SrPxantares_: sure
02:39amalloy(he's actually just disabled for a while)
02:39antares_amalloy: ok
02:39antares_SrPx: try (read-string "1") or (read-string "[1 2 3 4]") in the REPL
02:39SrPxokay
02:39amalloy&(read-string "1")
02:39lazybot⇒ 1
02:40antares_SrPx: of course, all programming languages have parsers, the difference is, at best you typically can only get an AST for some code in e.g. Ruby or Python
02:40muhoostuff added with pomegranate doesn't show up in (System/getProperty "java.class.path")
02:40muhoois ther eany way to get a complete classpath that includes stuff added with pomegranate?
02:40amalloymuhoo: no such classpath exists
02:40antares_SrPx: in Lisps and Clojure in particular, you can get, transform (if needed) in Clojure itself and it will be compiled
02:41amalloypomegranate uses a separate classloader, not the classpath-based classloader
02:42muhooah, but is there any way to get a list of what its classloader thinks is loaded? kind of alike a "lein2 deps :tree" output, but from within the repl?
02:42antares_SrPx: but there may be many ways in which you use it in practice. For example, defn is a macro and it does code transformation and it is written in Clojure itself, it is not something special Clojure compiler has support for
02:42SrPxAST?
02:42antares_SrPx: defn basically expands to (def fn-name (fn [a] …)), more or less, and it will attach docstring to the var it defines if you provide it, its. So it has some logic inside that generates code.
02:42antares_SrPx: AST is that tree structure that parsers produce
02:43SrPxantares_: and after that?
02:44antares_SrPx: after defn has done its work and defined a var, it is compiled to JVM bytecode (for JVM Clojure) and your program uses that var by calling the function in it or passing it around
02:44SrPxhmm
02:45SrPxbut wait
02:45SrPx(fn [a b c] (+ a b c))
02:45antares_SrPx: the point is that all code in almost any reasonably popular language can be represented by a tree and that's what compilers, IDEs, code tools and so on actually use. They do not use strings per se, strings are parsed to trees and then trees as used.
02:45SrPxthis is all compiled into bytecode?
02:45antares_SrPx: (def myfn (fn [a] a)) is compiled to bytecode, yes
02:45SrPxI mean, clojure doesn't keep track of the fact it is a function with 3 arguments that uses the other function "+"...
02:46antares_what do you mean does not keep track?
02:46antares_there are things the compiler does check, like references to vars that do not exist
02:47antares_other than that, it just takes those forms and turns them into JVM bytecode for JVM to execute
02:47antares_SrPx: a more advanced example, have you seen http://sqlkorma.com ?
02:48antares_it basically lets you write Clojure forms that are "compiled" to SQL, with some nice features about it
02:48antares_Korma manipulates Clojure data structures quite a bit to make that happen
02:48SrPxantares_: no, I mean I thought it keept it stored as ([a b c] (+ a b c)) (not in text, but with the reference to "+" and info regarding the position of the arguments).
02:49SrPxand then called the machine code when you tried to access its value
02:49antares_SrPx: it is "stored" but in the bytecode form. When you load a namespace or file in Clojure, it is compiled. Including at runtime.
02:49antares_there is no interpreter or interpreted mode
02:49SrPxI'll see it hold on
02:50antares_so yes, you have information about + and your own functions at runtime, they are stored in namespaces (which are basically map/dictionary-like things)
02:50SrPxantares_: this is pretty (=
02:52amalloySrPx: clojure doesn't keep track of + in some way; once it sees (fn [x y] (+ x y)) it emits bytecode that says, basically, "look up the symbol + in the namespace clojure.core, resolve it to a var, and then call theVar.invoke(x, y)"
02:52SrPxantares_: but back to the problem, how can I write a program that will allow me to search for a function by name, arity, etc., in some clojure files?
02:52amalloyafter that, it throws away all the information it used to construct the bytecode
02:52SrPxantares_: actually wait, I can just read all the code can't I
02:52ktsujiantares_: just the template project.clj reproduces this issue.
02:52ktsuji(defproject test-lein2 "0.1.0-SNAPSHOT"
02:52ktsuji :description "FIXME: write description"
02:52ktsuji :url "http://example.com/FIXME"
02:52ktsuji :license {:name "Eclipse Public License"
02:52ktsuji :url "http://www.eclipse.org/legal/epl-v10.html"}
02:53ktsuji :dependencies [[org.clojure/cloju
02:53antares_SrPx: your program would load said files and then use runtime information about functions to perform searches. But as amalloy points out, not everything is preserved for runtime. But you also treat code files like data structures and implement searches over arity, etc. This is how clojuredocs.org analyzer works, more or less.
02:53ktsujisorry the last line is :dependencies [[org.clojure/clojure "1.4.0"]])
02:53SrPxamalloy: theVar.invoke(x,y) wouldn't that cause it to run imediatedly
02:54SrPxantares_: sure, thanks (=
02:54amalloythe bytecode emitted is not immediately executed; it's loaded into the .invoke method of a new class that represents your function
02:55SrPxhmmm
02:56SrPxoh and, does clojure has any kind of support for events?
02:57antares_what events?
02:57antares_events are produced by libraries and parts of a program, any language can support them
02:58antares_I/O, network, fs events and so on are available through JDK libraries, 3rd party libraries that build on top of that and so on
03:02SrPxI just mean a way to define this behavior: an object that can fire an event and other objects can sign in to listen it and get a callback called when it does happen
03:03SrPxeh also some lib for keyboard/mouse events but I can just google that
03:05SrPxfor example...
03:06SrPxon Python you can say value = input("What is your decision?")
03:06SrPxand then do something with that input
03:06SrPxyou could (defn get-input [prompt] (println prompt) (read-line)) and then just do the same on clojure
03:06SrPxbut I feel like it is the wrong way?
03:07RaynesNothing wrong with that.
03:07SrPxI guess the 'right' way to do it would be to have a kind of object representing the prompt... have it fire an event when the user writes something... and let whoever signs to it deal with the event
03:08SrPxsomething like (watch input-machine enter-text (fn [text] (println text)))
03:08SrPx"on" in the place of watch would make it more readable
03:09SrPxRaynes: what do you think
03:09michaelr`depends if you want to block on input or not
03:09SrPxI don't mean it's wrong just not the way Clojure was supposed to work, I guess
03:09Raynes*shrug*. Seems like two different problems.
03:10SrPxmichaelr`: not!
03:10michaelr`events are good sometimes but they can also turn into a mess in a medium to big application
03:10SrPxreally? why?
03:10michaelr`events sphagethi
03:10Rayneslazybot is entirely event-based.
03:10SrPxhow?
03:10Raynes<3 events
03:10SrPxRaynes: <3
03:10SrPxso can I do it? create a class that can fire events and can be signed for those events?
03:11RaynesWell, Clojure isn't object oriented, so it's best to stop thinking in terms of objects and classes and the like.
03:11denysoniqueException in thread "main" java.io.FileNotFoundException: Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath: (server.clj:0)
03:12denysoniquewhen I try to run $ clojure myscript.clj
03:12michaelr`well, let's say that when the application grows it is harder to keep track of all the evented connections in the application, thus methods such as mvc developed to make it a bit more manageable (backbone.js as an in example from the js world)
03:12denysoniquein the lein repl I can import it fie
03:12denysoniquefine*
03:13michaelr`SrPx: think an event which triggers a function which modifies a model which in turn triggers multiple events subscribed to the changed property on that model and so on
03:13denysoniquemichaelr`: re backbone, what is a good Clojure library for exposing a RESTful API for Backbone.js?
03:14michaelr`denysonique: sorry, my experience with backbone was on .net :)
03:15denysonique echo "(use 'clojure.contrib.server-socket)" | clojure
03:15muhootrying to use korma to get access to an sqlite3 db, and getting this: https://www.refheap.com/paste/3349 when doing (select foo (:limit 1)) or (select foo (:order :ASC)). but just (select foo) seems to work
03:15michaelr`denysonique: but i guess the default would be compojure or noir
03:15denysoniqueresults in Clojure 1.2.1
03:15denysoniqueuser=> java.io.FileNotFoundException: Could not locate clojure/contrib/server_socket__init.class or clojure/contrib/server_socket.clj on classpath: (NO_SOURCE_FILE:0)
03:16denysoniqueworks fine when I pipe that into lein repl
03:16SrPxmichaelr`: hm
03:16denysoniqueHow do I use clojure.contrib with /usr/bin/clojure?
03:17denysonique'clojure.contrib*
03:18amalloydenysonique: i think the answer is: never use /usr/bin/clojure, it's not designed to do anything actually-good
03:18RaynesYou don't 'install' Clojure, so your 'clojure' thing isn't going to work the way you want. Use Leiningen. If you want to run a script, make a project with leiningen.
03:18RaynesAnd regardless, clojure-contrib was split into several independent libraries ages ago, so you probably don't want that either.
03:19aduomg
03:19aduI just tried clojurescript
03:19adu:D
03:19denysoniqueand what is it like?
03:19amalloyspeaking of which, let me tell you how good it feels to just be like "i'ma start a new project, put 1.4.0 in project.clj, and require some libraries" and have it just work. the pain of 1.3.0 is finally over
03:20adudenysonique: return [cljs.core.str("Hello "),cljs.core.str(n)].join(''); … beautiful!
03:20Raynesamalloy: Feels even better to only have :requires in my ns in non-library projects. :>
03:20denysoniqueadu: what is the output of this?
03:20denysoniqueor lisps
03:21adudenysonique: it's what (defn greet [n] (str "Hello " n)) compiles to
03:21adudenysonique: might be called "Hello " + x in other languages
03:21denysoniqueright
03:21denysoniquethat looks nice
03:21denysoniquenice js output
03:22adudenysonique: yes, yes it is
03:22adudenysonique: how long have you been into clojure?
03:23denysoniquejust installed it about an hour ago
03:23muhooamalloy: what was painful about 1.3 that is fixed in 1.4?
03:23adudenysonique: I have a great command-line app I wrote a couple days ago
03:23RaynesDynamic vars.
03:23RaynesFor one.
03:23amalloymuhoo: well, a few things. but mostly the pain was in going from 1.2 to 1.3+
03:24muhoooh gawd, i missed that transition, and i'm damn glad i did. :-)
03:24amalloyand now that everyone's basically done that, 1.4 is just as easy as 1.3
03:25muhoocool. maybe i should just try 1.4 and enjoy the uneventful non-breakage then
03:26denysoniqueadu: I would like to see it
03:27denysoniqueadu: What do you think about ClojureScript on the serverside on node.js?
03:29aduhttps://gist.github.com/3009680
03:29adudenysonique: I don't
03:29aduI'm a big fan of compilers to JavaScript, but I'm not a big fan of node.js
03:30denysoniquewhy?
03:30aduthe idea of node.js is great, but the way it's implemented doesn't respond well to scrutiny
03:33adubesides, if you're doing stuff on the server-side, then I would think clojure->jvm would be the way to go
03:33aduunless you have an existing node.js code base you need to integrate with
03:41adudenysonique: anyways
03:41aduthe commandline app is similar to the 'mustache' command-line tool
03:59xumingmingvany usecase for clojurescript?
04:00adua webgl app?
04:04xumingmingvdont know whether front-end developer would like to change from javascript to clojurescript?
04:04xumingmingvor clojurescript is for backend-developer to write front-end code?
04:04xumingmingvor it is for writing code to run on v8 engine on backend?
04:05aduif you have a code base for your server logic, then it's nice to use that in client logic too
04:13ro_stxumingmingv: writing clojure client and server side makes things like github.com/shoreleave possible
04:39muhoowhat would be the current state-of-the-art if i wanted to just get a hello world going in cljs, possibly with some stuff like crate and fetch up in the mix too?
04:42ro_stisn't there a lein project template for cljs?
04:42ro_stand the lein-cljsbuild plugin
04:44ro_stmuhoo: you could probably grab this and remove noir (or not, as you prefer): https://github.com/ibdknox/cljs-template
04:45ro_stit includes fetch, crate, jayq, noir, and noir-cljs: https://github.com/ibdknox/cljs-template/blob/master/src/leiningen/new/cljs_template/project.clj
04:55muhoofantastic, thanks
04:59ro_sti can't wait to start playing with cljs myself
05:00muhooi have a few weeks off, and my two goals are 1) cljs, and 2) datomic
05:00ro_stisn't datomic like really expensive?
05:00ro_styou can't just grab it and use it like you would mongo?
05:00muhoothat's what they want you to think :-)
05:01muhooit's free for the first 2 peers, IIRC
05:01muhooplus you can run it using postgres instead of the amazon thing.
05:01ro_stpeers meaning one app instance and one database server
05:02muhooi'll find out over the next 2 weeks :-) but they spell it out here: http://datomic.com/product/pricing
05:03ro_stnice
05:03ro_stenjoy. fun learning new things
05:04muhooi'm old, so learning new things really isn't fun. but learning BETTER things, that i enjoy. and datomic has got to be better than what i've had to deal with so far in db-land.
05:08ro_stold? what, like, 30? -grin-
05:09_nmmnim old too then :\
05:09ro_st(i'm 33)
05:09_nmmnand you are old also ;]
05:40ro_stseconded
05:46ro_stBIKKIT
05:54muhoohm... ok.... https://www.refheap.com/paste/3350
05:54muhoolooks like the only thing uglier than java stacktraces is cljs stacktraces
05:55muhooalso looks like there's no "use" or "require" in cljs?!
06:02ro_stmuhoo: this livecode might be instructive
06:02ro_sthttps://vimeo.com/43808810
06:02ro_stcode from the talk https://github.com/bodil/mylittlecthulhu
06:08muhoothx
08:25maarukswhere is source code of clojure 1.4 ?
08:27maaruksomg github :-)
08:56antares_maaruks: Clojure is at github.com/clojure/clojure
09:03progouuuglyyy. I have to update more than one value in a map. Nested update-ins aren't elegant.
09:12llasram&(-> (update-in {} [:first] (fnil inc 0)) (update-in ,, [:second] (fnil conj []) :value))
09:12lazybot⇒ {:second [:value], :first 1}
09:12llasramprogo: What abotu that?
09:12llasramwell, looks nicer when you align the `update-in` forms, but you get the gist
09:13progollasram, I guess that has to do :)
09:27chico_chicotehi all. i'm trying to launch a standalone swank-clojure server, but i can't find the executable (downloaded it with leiningen2)
09:27chico_chicoteany tips?
09:28ro_styou need lein-swank installed
09:28ro_stthen you can simply lein swank
09:41antares_ro_st: heya
09:41chico_chicotero_st: if i lein swank, i get a 'Couldn't find project.clj, which is needed for swank'
09:42chico_chicotefrom what i understand, this means i must be in a leiningen project, right?
09:42chico_chicoteisn't there a way to just launch a standalone server?
09:42duck1123lein swank should work standalone
09:42duck1123but it's just as easy to create a dummy project
09:42duck1123lein new foo; cd foo; lein swank
09:43duck1123that way you have a project file for your next question "how do I add a library"
09:43S11001001or "how do I change clojure versions to something recent"
09:48ro_stantares_: :-) howdy
09:49antares_ro_st: you are a monger user if I remember correctly, is this right?
09:50ro_styes, daily at the moment
09:50antares_ro_st: ok. Is there anything you want to see improved in the docs?
09:52ro_staside from the one or two things i mentioned before ( :nested.field.access and the simplest way to get the :_id for a newly inserted document ), not really
09:52ro_stalso, i was thinking it might be handy for monger.core to have a convenience fn for ObjectId
09:52ro_stso that we don't have to import it all the time - makes repling that bit easier too
09:52antares_ro_st: there are a few in monger.util
09:53antares_ah, I see
09:53antares_well, you still have to refer to monger.core functions
09:53ro_stie, {:_id (new-object-id) :myField 1 :myOtherField 2} etc
09:55wingywhen i learned node.js the main concept was: one thread -> do async style! in clj, immutability, everything is an expression
09:56duck1123I'd like one like this https://github.com/duck1123/jiksnu/blob/master/src/jiksnu/model.clj#L219 so I can pass an id or just get a new one
09:57ro_styeah that looks great
09:57antares_duck1123: the real problem is monger.collection/insert which returns write concern
09:57antares_that was a mistake but it is too late to change what is returned
09:57antares_what we can do I guess is use a subclass that effectively works like a Clojure map
09:58duck1123Yeah, that was the biggest issue for me when I switched
09:58duck1123I've had to resort to always generating my own id
09:58antares_ok, I will think about
09:58ro_sti think pre-setting the id is better
09:58antares_duck1123: that's what I do, too
09:58ro_stfor testing
09:58ro_stby making that the 'way', it makes testing automatically easier
09:58antares_ro_st: MongoDB Java driver tries to mutate the object you insert
09:58antares_but we don't return it
09:59antares_we can add a new function but all the options I have suck
10:00antares_insert-map, insert-doc, insert! are all not very good names
10:01duck1123perhaps a monger.sweet with a higher-level api ?
10:02antares_duck1123: hm, no, I don't like "sweet API" namespaces
10:02antares_the entire API should be sweet, why have sweet and bitter parts :)
10:02antares_I think returning a subclass of WriteResult that acts like a Clojure map + has the actual document may work
10:04antares_we can also call the next release Monger 2.0 and break this thing
10:04antares_I am open to that
10:04antares_anyway, my question was mostly what is missing in the docs :)
10:05duck1123more information about different ways to dynamically create queries
10:05antares_with monger.query?
10:05foxdonutantares_: do you know of anyplace one could host a webapp with clojure and mongo?
10:05antares_foxdonut: heroku
10:06antares_with the mongolab addon. Or is it monghq. Or both.
10:06antares_Monger supports connections via URI, specifically for those platforms
10:06ro_styup. you can have it running in 10 minutes
10:06ro_stsuper easy
10:11foxdonutantares_, ro_st: great, thanks
10:12duck1123antares_: yes. I don't even know if this is possible, or how you'll go about it, but I know I'll need it soon. Looking for ways to compose the query options. (in response to external parameters)
10:12antares_duck1123: it is possible
10:12duck1123I figured it was. I'm sure I can figure it out, but it's not in the docs
10:13antares_duck1123: https://github.com/michaelklishin/monger/blob/master/test/monger/test/querying_test.clj#L253-287
10:13antares_yeah, ok
10:13antares_I am finishing the indexing guide tonight
10:13antares_then I can work more on querying and maybe How-Tos
10:13ro_stindexing, awesome. i still need to do that
10:14ro_stit's pretty straightforward i believe
10:14wingyis there a favorite CSS preprocessor in Clojure world?
10:15ro_stwingy, don't think a clojure one exists
10:15ro_sti use sass, works for me
10:15wingyaight
10:15antares_wingy: LESS has a Lein plugin
10:16duck1123are you looking to generate css from clojure, I think there is one, it's in my following list, have to find it
10:16antares_which uses the official Java compiler
10:16antares_works great for me
10:16wingyantares_: i find SASS better alternative .. LESS seems less maintained
10:16antares_I don't do much frontend development so I can't speak about sass but i had huge issues with haml before
10:17antares_haml is the single library I absolutely hate
10:17ro_sthaml isn't great. sass is fantastic
10:17wingyduck1123: not necessarily from clojure .. from a higher level CSS like SASS/Stylus etc .. but I am opened to any suggestion
10:17antares_it is developed by people who don't give a damn about any sort of compatibility
10:17wingyseems that with clojure you can have a DSL for everything
10:17antares_and sass is developed by the same dude
10:17wingyperhaps in the future it would be simpler to just generate CSS from clj?
10:17antares_https://github.com/paraseba/cssgen
10:17wingylike you do with HTML
10:17antares_wingy: you can with https://github.com/paraseba/cssgen :)
10:18wingyhmm seems unmaintaned
10:18wingyis it abandoned?
10:18ro_st2 months ago
10:18wingyoh 2 months ago
10:18ro_stthat's pretty recent
10:19ro_stmaybe it does everything it should, already :-)
10:19wingyyeah .. im used to node.js maintainance .. they are having far more watchers and maintainence
10:19wingylike 8 hours ago .. 2 days ago...
10:19wingy:)
10:19wingy2000+ watchers
10:20wingyis it bad thing to couple styling with clojure code
10:20wingysince now you cannot outsource styling to designers
10:20wingyand developers might do a terrible job in styling
10:29scriptordon't a lot of projects use enlive or something like it for layout?
10:29TimMcwingy: Eh, they can learn it.
10:29scriptorif designers have to touch the html…I wonder how easy that is for them
10:30TimMcIt's a restricted subset of Clojure.
10:33TimMcparaseba doesn't look like it can handle some important things like embedding values in selectors, e.g. a[href="$FOO"]
10:33TimMcIf you don't give a convenient way to escape data values for embedding in syntax, you're gonna break something.
10:34TimMcOr rather, the people using your lib will.
10:37foxdonutwingy: there is also https://github.com/briancarper/gaka
10:39foxdonutI used this fork for more recent clojure version: https://github.com/crimeminister/gaka
10:39foxdonutpretty simple (and effective) stuff.
10:40antares_wingy: commits does not necessary mean maintenance and node.js break things every release (as told me by a person working at a Node.js cloud platform provider)
10:41antares_0.8 has so many serious changes that we have a blog post going out mentioning them for travis-ci.org users
10:42antares_what sucks about some Clojure libraries is that their developers never have any docs or state what Clojure versions are supported
10:47wingygaka seems really unmaintained
10:47wingyone of my rules is to never use unmaintained repos
10:48wingythe library ecosystem seems so small compared to ruby/node
10:48antares_that's a good rule to live by
10:48wingythats the only disadvantage of clojure in my opinion
10:50wingybut on the other hand i can ditch libs like: LiveScript, prelude-ls (which is LiveScript's std lib), async (for node.js async style), sugar (utility methods since JS lacks a lot)
10:50wingywhat is the best way to make HTTP requests?
10:50duck1123clj-http or aleph.http if you want async
10:51wingyduck1123: is there really synced http requests?
10:51antares_wingy: yes, there are sync HTTP clients, what's the problem?
10:51wingyantares_: not used to it haha
10:52antares_async is not silver bullet. clj-http uses a thread pool under the hood, people build Web crawlers with it just fine
10:52wingyas long as it works with high concurrency i have no problems
10:52wingyhave to investigate on thread pool and how clojure does things
10:52antares_wingy: if you take Java libraries into account, Clojure has access to more libraries that most languages. And some of those libraries are very mature and pretty good.
10:53wingyantares_: oh yeah forgot that
10:53wingythat should make npm and gem seem like baby poops
10:53wingyand then i can use JS libs/frameworks on frontend with cljs
10:54wingyso more power than JS only!
10:54duck1123In many cases, it's easier to make a sync request in a different thread than an async one with a callback. (depends on the situation)
10:54wingyduck1123: how much does the thread take in memory?
10:55wingywill server manage 100 000 http requests at once?
10:55wingyduck1123: did you mean this one: https://github.com/dakrone/clj-http/
10:56duck1123depends, how awesome is your server? yes
10:56wingybut node.js can make 100 000 without needing a very great server .. seems it so cheap with async operations
10:56wingysince it ..
10:57duck1123there's also an clj-http-async (or something) but I just use aleph since I'm already using it
10:57wingyok i have to yet decide what to use
10:57duck1123If you think async is going to be important for you, check out lamina/aleph
10:59uvtcantares_, Do you mean Java standard libraries, or 3rd-party Java libs? Or both?
10:59wingyduck1123: so it boils down to async with one thread: aleph/netty and sync with many threads: noir/jetty .. is this correct?
11:01antares_uvtc: 3rd party but JDK itself has plenty of good parts and if you have to do any kind of work that involves a lot of PKI, TLS and related stuff, JDK is a life saver compared to Ruby, Python and (I am sure) node.js
11:02uvtcMy guess is that new Clojurians who have no experience with Java have very little idea what 3rd-party libs are available, or where to find them. Is there a "clojure-toolbox" for Java?
11:02wingyheh .. error in the book
11:02wingy(reduce max [0 -3 10 48])
11:02wingy;= 10
11:03cemerickwingy: yeah, we'll be haunted by that :-|
11:03cemerickOf all the things…
11:03wingycemerick: but why did he do like that?
11:03duck1123not quite. Noir sits atop it all and can be used with either jetty or netty/aleph. Both of them don't care what you're doing with threads, but with aleph, you get a channel that you can asyncronously emit your response to
11:03wingywhy use reduce
11:03wingyah
11:03wingythe collection is a []
11:04metellusyou could also use apply in that case
11:05wingyyeah
11:05antares_uvtc: in practice if you want a library for a data store or something NLP or IR related, there is always a Java library, often an official Java client for your store and so on. There are "clojure toolboxes" with 100+ projects each in the Java world: Apache, Eclipse, even Codehaus
11:06antares_uvtc: search.maven.org may be useful. But typically finding a library is not a problem. A bigger problem is finding an easy to use or wrap, well documented library and knowing which alternative to pick. But it's a good problem to have in my opinion.
11:07wingyi wonder if i would enjoy working in FP style if I haven't done OOP
11:07foxdonutwingy: most of the time I agree but for something as simple as taking a clojure data structure and generating css, there isn't a whole lot to maintain
11:07uvtcclojurebot: IR
11:08uvtcantares_, NLP == "natural language processing"? "IR"?
11:08TimMcInformation Retrieval
11:08wingyperhaps the reaction would be .. "OOP looks so natural, not like math, i want a book for my app so i create a book"
11:09uvtcTimMc, sounds like something out of the ministry of information. :)
11:09TimMcwingy: You still "create a book", it just doesn't have methods attached.
11:10TimMcThe difference is in how code is applied to data.
11:10wingyyeah
11:10antares_uvtc: information retrieval, search and indexing. Lucene and related projects.
11:10wingythere is a good slide that explains what i have realized very well *looking*
11:11uvtcantares_, thanks for the info. Yes, pretty good problem to have (need to choose among alternatives). Perl's CPAN seems to have some of that issue.
11:11wingyhttp://www.slideshare.net/smartrevolution/how-a-clojure-pet-project-turned-into-a-fullblown-cloudcomputing-webapp
11:11wingypage 92
11:11antares_uvtc: I think all mature communities do, to some extend Python has it, too
11:12wingyto page 100
11:12antares_uvtc: Clojure's sweet spot is data processing, things like Web crawling, large scale stream processing, indexing and so on. those things in the Java ecosystem really shine. clojurewerkz.org is so focused on DB clients for the same reason.
11:12cmajor7is there a way to include dependency (e.g. [clj-time "0.4.3"]) just for a single repl session, e.g. without creating a project?
11:13antares_uvtc: also, statistics, math, linear algebra, machine learning in Java are well covered. One of the best in its kind. Of course, some things (like LESS and SASS implementations) are in significantly worse shape and it does affect Clojure
11:13duck1123There are some libraries and functions that allow you do manipulate the classpath, but you get into some dark magic there
11:14cmajor7duck1123: you mean https://github.com/cemerick/pomegranate ?
11:15uvtccmajor7, I think there's a lein plug-in for that ...
11:15wingyperhaps thats one of the main benefit of using clojure .. there isn't a huge pool of libs compared to OOP langs since you don't need any
11:15wingyor not that much
11:16wingyyou dont need ActiveModels like in Rails. or Doctrine like in Symfony
11:16uvtccmajor7, https://github.com/mtyaka/lein-oneoff
11:17aduduck1123: "dark magic"?
11:17duck1123cmajor7: That should do the trick. I haven't used that one, I just know that add-classpath used to be a pain
11:17TimMcDoesn't oneoff require a file?
11:17uvtccmajor7, is that what you mean?
11:18cmajor7uvtc: almost :) it does require you to code "in a file", I was looking for a pure repl based dep
11:18uvtcOh, I mis-read. Right. :)
11:19cmajor7e.g. I'd like to play with [clj-time "0.4.3"] without having to create a file/project
11:19cmajor7it is not all that hard, I can create a single "playground" project for things like that, and just keep adding deps into the "project.clj", and run "lein repl"
11:19cmajor7just thought there is a easy way :)
11:20uvtcThat's what I do (create playground projects).
11:20cmajor7or should I say "simple" :)
11:22duck1123you could try listing it as a plugin in your profile. that might work
11:23cmajor7duck1123: you mean just drop the jar into "~/.lein/plugins/" ?
11:23duck1123worth a shot. I haven't tried it as I don't have my clojure setup here
11:23wingyanyone here using cljs and have opinions about google closure?
11:23wingyatm im using ExtJS but they are so OOPish and wont fit with cljs
11:25cmajor7duck1123: thx, I'll try that
11:25kmicuwingy: G Closure LIbrary?
11:25wingykmicu: yeah for UI http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/index.html
11:25wingyseems pretty sweet
11:26cgagi feel like no one uses it, or at least I don't think I've ever heard it mentioned outside the context of cljs
11:26wingycgag: what are people using then?
11:26wingythey create html/css from scratch?
11:26duck1123They're using one of the hiccup clones
11:26cgagno idea, i haven't done much with javascript
11:27wingyduck1123: but those dont provide UI elements
11:29uvtcantares_, I added Apache and Eclipse the list at http://www.unexpected-vortices.com/clojure/brief-beginners-guide/libs-available.html#other-java-libraries ,
11:29uvtcbut I didn't see any libraries listed at http://www.codehaus.org/ .
11:29antares_uvtc: feel free to link to clojurewerkz.org, too :) we focus on things for day-to-day development, like data stores
11:29uvtcOh, right, almost forgot. Thanks!
11:30uvtcIf you know of any other places for users to find Java libs, please let me know.
11:31antares_uvtc: codehaus site is a bit silly and not friendly. Groovy is hosted there, JRuby started there, but it does a terrible job of actually letting you browse and track project development. I'd just link to search.maven.org instead.
11:31uvtcantares_, Yep, got that one, thanks.
11:32antares_uvtc: also, you may want to add a note that eclipse.org is just a huge umbrella foundation. there are both tools (eclipse/jdt, for example) and libraries (like jgit)
11:32antares_and many tools have components that can be used as libraries
11:32cmajor7wingy: "what are people using then?": I just use hiccup.. quite simple really, enlive is also praised, but I have not used it
11:32antares_Jetty is now also an Eclipse project
11:33duck1123I tried using Closure templates, but reverted to using hiccup
11:35cmajor7it feels that some folks prefer enlive to hiccup, do you know why?
11:35antares_uvtc: also, I'd suggest you to rename "Java standard libraries" to "Java standard library: JDK" and link it to http://docs.oracle.com/javase/7/docs/
11:35kmicuwingy: I do not recall a project that uses gclosure ui libs, some poor examples @ https://github.com/search?q=goog.ui&amp;repo=&amp;langOverride=&amp;start_value=1&amp;type=Everything&amp;language=Clojure
11:36duck1123some people like enlive because it forces that separation of concerns. Some people don't like it for that same reason
11:36cmajor7duck1123: separation from what and what? :)
11:37kmicucmajor7: in enlive you can jack-in to existing html created by gfx artist, hiccup is good when developer want to create some html in clojure :]
11:39duck1123envlive take html and plugs in the values using matching. With hiccup, you produce all your html as a sequence of vectors, keywords, and maps
11:39cmajor7kmicu: huh.. that's neat. yea I create it myself, but that'd be a cool ability. especially for "inspired" existing html/css
11:39wingyi wonder why noone is using closure
11:40duck1123wingy: I think beccause the people really into cljs built cljs libraries that accomplish many of the same things but feel nicer.
11:41cmajor7duck1123: I see, jquerymobile follows the same "separation".. you give it HTML, it hooks to it
11:41wingyhope someone is going to release something soon so we can all benefit from it
11:41wingya UI framework working on tablets and phones as well
11:41cmajor7wingy: is twitter bootstrap not cutting it for you?
11:44wingycmajor7: *checking it out*
11:46wingycmajor7: cool concept
11:46pbostromI like the enlive/bootstrap combo personally, since there is a lot of existing bootstrap html/css out there, it's a lot of work to translate it all to hiccup
11:48duck1123actually, with hiccup, you can write functions thaat abstract a lot of that away
11:49duck1123for example: https://github.com/duck1123/jiksnu/blob/master/src/jiksnu/sections.clj#L7
11:50cmajor7duck1123: yep, that is what I have.. several hiccup builders that I reuse all over
11:50cmajor7pbostrom: thx, I'll check out enlive, feels like I have to, to be in the loop
11:51cgagi've only really used enlive for scraping so far, haven't done any generating
11:51pbostromduck1123: I'm pretty lazy, so that constitutes "a lot of work" :)
11:51cgagit's selectors are nice for that
11:51wingyenlive is generating HTML using CSS selectors while Hiccup is using clojure right?
11:52wingy32 000 watchers of bootstrap lol
11:52raekyou only use css selectors to specify where to apply the rules
11:52raekthe transformations are written in clojure
11:53raekthe selectors can be too
11:53wingyraek: ah .. so you have a regular HTML file with skeleton, then you apply html elements dynamically
11:53raekyup
11:53cgagthis tutorial is pretty solid for enlive: https://github.com/cgrand/enlive/wiki/Table-and-Layout-Tutorial,-Part-1:-The-Goal
11:53wingycool
11:54wingywell .. seems to ExtJS is history for me
11:54pbostromI also like dnolen's tutorial: https://github.com/swannodette/enlive-tutorial/
11:54wingydo most of the people here suggest enlive or hiccup?
11:54wingyand aleph or noir
11:55raekwingy: you wonder if those two together are the most common, or which one of them is the most common?
11:56duck1123wingy: the choices are aleph / jetty and noir / not-noir
11:57cgagi'm curious to hear people's opinions on the aleph / jetty choice
11:57wingyduck1123: is not-noir its own stack?
11:58m0smithhello, is anyone home?
11:58duck1123A lot of people do just fine not using noir. and there are other options slighty in that space
11:58wingyraek: i wonder what stack is the "best" to use for serving HTTP
11:59duck1123My choices have been: Hiccup, Aleph, Ciste
11:59m0smithI use hiccup with stencil to keep the html separate
12:00raekwell, before noir came "the stack" was just your own combo of your favorite libs
12:00gtrakduck1123: Ciste, attempting to provide a structure to clojure applications, ha
12:00m0smithswing: there are lots of choices, do any stand out?
12:00raekwingy: take a look at the diagram under the Common Stack section here: http://brehaut.net/blog/2011/ring_introduction
12:01gtrakWhat's a documentation-generation stack I can use with lein that will handle tables and things?
12:01raekI think noir initially some of those libs bundled together with added syntactic sugar
12:02raekalso, most web-related libs (including ring-jetty-adapter, aleph, and noir) are based on the Ring spec
12:10m0smithIs anyone using Swing?
12:10qbert_noone uses compojure ?
12:13technomancycompojure is the best
12:15gfredericksthat statement is true even when totally unqualified
12:16uvtcgtrak, you mean for just generic documentation, or for api docs in the source code?
12:19qbert_out of curiosity, what are you guys building currently with clojure ?
12:20gfredericksan SVG-based demo of quantum computation
12:20technomancyleiningen
12:20gfrederickstechnomancy: that's quite a pun
12:21achengobservation re: clojure.test + lein + test selectors ... my fixture marked for :each test apparently runs for both unit tests in my namespace even though only one test is selected to run
12:23technomancyyeah, test selectors run inside fixtures
12:24mmarczykgfredericks: ping
12:24gfredericksmmarczyk: pong
12:24mmarczykgfredericks: hi
12:24gfredericksgreetings
12:24mmarczykgfredericks: just a quick question
12:24achengtechnomancy: ok. it's still a great improvement over actually running those extra tests.
12:25mmarczykhave you been working on cljs-324? (format)
12:25achengbut if i have 30 tests and only wish to run 1, i'll get 29 instances of firefox opening and closing :-P
12:25gfredericksmmarczyk: nope. I took a quick look at the java docs and panicked :)
12:25mmarczykgfredericks: oh, ok
12:26achengmaybe i'll run the one by hand as a regular fn then
12:26mmarczykgfredericks: :-)
12:26mmarczykgfredericks: GClosure does actually provide a formatter
12:26gfredericksmmarczyk: phew
12:26gfredericksis it similar?
12:26mmarczykgfredericks: I can attach a patch and you can try it out :-)
12:26gfredericksI assume it doesn't should be identical
12:26mmarczykgfredericks: honestly, I've no idea
12:26mmarczykgfredericks: the sprintf-like basics should be pretty close
12:27gfredericksright
12:27mmarczykgfredericks: I mean, they should be the same :-P
12:27gfredericksI don't know about the acceptance criteria for the issue; I assume dnolen's opinion is more relevant than mine
12:27mmarczykgfredericks: just wanted to know if you were in the middle of writing our own sprintf-like formatter :-)
12:28gfredericksI did fantasize about that for several seconds
12:28mmarczyk:-D
12:30mmarczykok, attached a patch to cljs-324 with GClosure-based format and printf... if they won't cut it, at least it's an 11-liner :-P
12:31mmarczykso no great loss of effort
12:31gfredericksmmarczyk: sweet
12:31dnolenmmarczyk: gfredericks: cool
12:32mmarczyk:-)
12:32gfredericksdoes lein-cljsbuild let you specify or provide a particular version of cljs?
12:32mmarczykdnolen: hi! cljs-324 applies on top of cljs-328
12:32mmarczykdnolen: the latter being a bugfix for a bug in :require handling... missed the (:require [lib.ns]) case
12:33dnolengfredericks: not really, I'm increasingly convinced it should do anything at all. You need to specify CLJS yourself.
12:33dnolenshoudln't
12:33brainproxywingy: I'm using hiccup to generate "templates", i.e. my term for logic-less skeletons of html documents
12:33dnolenerg
12:34brainproxywingy: then I use enlive to realize views of data in terms of one or more templates
12:34gfredericksdnolen: so a lein-cljsbuild patch along those lines would be welcome?
12:35mmarczykI thought lein-cljsbuild already uses the version of cljs specified among the project's :dependencies (if any)? or at least that it used to...? otherwise I've no idea how some of the things I've been doing with locally built CLJS versions could have possibly worked
12:36gfredericksI've never specified cljs in my deps
12:36gfredericksI'm not even familiar with the maven releases of cljs, if there are any
12:36gfredericksso apparently I don't know how things work
12:37mmarczykthere are
12:37mmarczykfor tags in the main repo
12:37mmarczykhm, not sure if the last tag actually got a release
12:37brainproxywingy: doing that way helps me (I think) to build up the semantic profiles for my hypermedia base type w/o getting bogged down in fine details of uri schemes and the particulars of parsing data into a representation, i.e. with respect to templates
12:37mmarczykanyway, gotta dash now, bbl
13:01gtrakuvtc: generic documentation
13:01gtrakI guess I'd probably have to use latex or something
13:02uvtcNah. I suggest you write them in markdown, but use the extras that Pandoc provides http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown . Then just process the docs yourself with the `pandoc` command.
13:03uvtcIt supports tables, definition lists, LaTeX math, and some other goodies.
13:03gtrakoh neat
13:06uvtcgtrak, here's a brief example: http://www.unexpected-vortices.com/sw/gouda/quick-markdown-example.html .
13:36wingydo you prefer to use anonymous functions or function literals in HOFs?
13:37antares_wingy: for anything non-trivial, I personally try to use named functions (because they can be tested easily)
13:38scriptorthey could also be re-used elsewhere
13:38wingyokay
13:50TimMcIf you do (map (fn munger [x] ...) ...) then "munger" appears in stack traces.
13:52wingyTimMc: it seems that named functions is always the best then
13:52wingyif it was me and fn literals have very little gain..i would have ditched it from the lang
13:53antares_duck11231: do you think this section on object ids is good enough? http://clojuremongodb.info/articles/inserting.html#document_ids_objectid
13:53antares_wingy: they are useful in those rare cases when you need to use loop/recur with otherwise trivial functions
13:56ffwacomsexp motherfuckers
13:56duck11231antares_: the link didn't go to the section, but the text looks good
13:56antares_duck11231: ok, thank you
13:58duck11231"Unfortunately, it does so" reads oddly, and I would drop "So" from the next paragraph
13:58dnolenwingy: fn literals, anon fns, letfn all have their use cases. takes some time to figure it out.
13:59wingysince FP is separating data and code, perhaps the presentation should be separated as well
13:59antares_duck11231: refresh
13:59antares_wingy: it is easy to take analogies too far
13:59wingywhich means twitter bootstrap (CSS/HTML) is more suitable than ExtJS
14:00wingythey separate everything in object level .. MVC
14:00wingyFP + Html/Css is it's equivalent without all the objects/classes
14:01wingyantares_: but it seems right to have it like that .. the data {:name "foo"} has nothing to do with the logic map/reduce which has nothing to do with how you present the data to users
14:01antares_duck11231: Monger docs are OSS and I am not a native English speaker so feel free to edit them and submit pull requests ;) https://github.com/clojurewerkz/monger.docs
14:02wingywhere you are using <div>/.div and html templating where you pass in a collection and it will render a table
14:02antares_wingy: I agree but sometimes more separation does not yield anything in practice
14:02wingyantares_: where is the _more_ in this kind of separation?
14:02antares_just like sometimes the best solution is to not remove duplication if it makes code harder to understand
14:02wingyhow can i possibly have presentation in the collections
14:03antares_wingy: I am not talking specifically about one case or idea
14:03wingyi am :)
14:03antares_just suggesting not refer to Clojure and FP's ideas of separation as the universal law applicable to everything:)
14:03wingyit could?
14:04wingysimplicity is what i want to achieve .. seems nothing can be more simple than data in data out
14:04wingythen the presentation stuff is just for people right
14:04TimMcwingy: Non-named and literal fns improve readability in many, many cases. Less to read!
14:04wingyhow to present a collection for users .. which has nothing to do with data -> fn -> data
14:05wingyfeels that im getting much smarter reading about FP than OOP where they abstract everything away .. heading towards complexity
14:06wingyTimMc: yeah
14:13antares_uvtc: by the way, another huge umbrella project for a lot of Java tools and libraries is JBoss: http://www.jboss.org/projects, Clojure on JBoss App Server: http://immutant.org
14:25uvtcThe docs (manual) for immutant are easy to navigate. Easy to see right where you are at any given point. Very nice.
14:25jcrossley3uvtc: thanks! :)
14:25uvtcWhat are you using to generate them?
14:26jcrossley3uvtc: tcrawley is so happy you asked that!
14:26tcrawleyheh
14:26uvtctcrawley, did you whip something up to generate them?
14:26tcrawleyjcrossley3: does that mean you are delegating to me to answer it?
14:26jcrossley3tcrawley: yes, i'll just bask here in your glow. :)
14:27uvtc(Oh, I almost thought I'd made a mistake; it says "jboss.org" at the top of http://immutant.org/documentation/current/ )
14:27tcrawleyuvtc: the docs themselves are written in emacs org-mode format. We then run them through emacs in batch mode to export html
14:28technomancywhat's the motivation behind having immutant be installed in ~/.lein/immutant?
14:28tcrawleyuvtc: that html is then munged by a ruby script to match the jboss.org doc format, which allows us to use the jboss.org doc css
14:29tcrawleyuvtc: which assumes you are generating the docs from docbook
14:29tcrawleytechnomancy: good question!
14:29austinhIs there a way to make paredit-reindent-defun (M-q) keep a function definition's parameters on the line after the doc-string?
14:29tcrawleytechnomancy: I wish I could remember the answer :)
14:30uvtctcrawley: Neat! I'd written a doc generator myself, which produces something sorta similar in structure, but not nearly as polished: http://www.unexpected-vortices.com/sw/gouda/ . Instead of org files (?) it uses a flat dir of .md (er, .txt) files.
14:30jcrossley3tcrawley: technomancy: i think it was a pretty arbitrary decision at the time. it was a directory we knew would exist. :)
14:30technomancytcrawley: it's just that lein is generally pretty project-centric; the only outside-project stuff it's done has been shell wrappers, which were mostly unused.
14:30uvtctcrawley, Oh, you have better navigation. I should fix the gouda header to have the arrows on each side like yours.
14:31technomancytcrawley: two thumbs up for supporting meta rel=next/prev
14:31tcrawleytechnomancy: seriously though, I put it there since it was installed by and managed by a lein plugin. it may be better to use ~/.immutant
14:31technomancytcrawley: so you're using leiningen as a general clojure CLI interface rather than specifically a tool to operate on projects?
14:32tcrawleytechnomancy: correct - most of the plugin's commands work inside or outside of a project
14:32technomancyinteresting
14:33tcrawleyfor example: 'lein immutant deploy' will deploy the current project if you are in one, otherwise you can give it a path to one from anywhere: 'lein immutant deploy foo/bar'
14:33tcrawleyand can be used to deploy apps that aren't even lein projects (but why anyone would do that I don't know)
14:33technomancyis the stuff installed by `lein immutant install` used at dev time or for deployments?
14:33technomancyor both?
14:34tcrawleywell, the question becomes 'what is dev time?' - if you are developing an immutant app, you're probably deploying it quite a bit
14:35tcrawleyor deploying a basic version of the app w/swank enabled, and doing repl based development
14:35tcrawleyinside the immutant container
14:35tcrawleybut what's installed is a full blown installation of immutant
14:36uvtcThanks for that heads-up, antares_ . Added.
14:36tcrawleyuvtc: I'll take a look at gouda, thanks for the tip
14:38technomancytcrawley: have you considered a higher-order task?
14:38tcrawleytechnomancy: what do you mean?
14:38jcrossley3uvtc: thx for the link on your page
14:38technomancy`lein immutant swank` could run the swank task inside immutant
14:38technomancytcrawley: eval-in-project is a multimethod, so you could add support for :eval-in :immutant
14:39technomancyand have all eval-in-project code sent to the app server
14:39technomancythen all existing lein tasks could port over, provided you can handle classpath stuff
14:39technomancyjust a thought
14:39tcrawleytechnomancy: ah, right. that would require some clojure app deployed to the app server to receive it, but that wouldn't be difficult. it would need the deps of the current project, yeah
14:40tcrawleybut it's doable
14:40technomancyideally you could make it work without the need for an explicit `lein immutant install` step
14:40jcrossley3that'd actually be pretty cool if jack-in could run the swank task inside immutant, too.
14:40technomancyanyway, that's what I would do
14:40technomancybut I'm obsessed over higher-order tasks
14:40technomancyso take it with a grain of salt
14:41tcrawley'install' installs immutant itself, so there would have to be an install happening at some point.
14:41tcrawleyso 'lein immutant swank' would d/l and install immutant on the first call
14:41technomancyright; ideally you could have it happen on-demand
14:41technomancyand the project could declare the version it needs (separately from :dependencies probably)
14:42tcrawleyI like that idea a lot
14:42tcrawleyI'll put that on the list
14:42tcrawleytechnomancy: thanks for the suggestion!
14:42technomancyno problem; lemme know how it works out for you
14:42tcrawleywill do
14:58wingywhat does "concrete types of data" mean?
15:02amalloynot much without context, i suspect
15:08uvtcwingy, the concrete data types are hash-map, vector, list, and set. There's syntax for them, and you create them in your code. They implement various abstractions that Clojure has notions of.
15:11uvtcI was just looking at amalloy's solution at http://stackoverflow.com/questions/11225562/idiomatically-merge-maps-into-a-map-of-value-sets-with-clojure ,
15:11uvtcand thought it seemed like I could do the same like so:
15:11uvtchttps://gist.github.com/3013269
15:11uvtcBut I'm getting "UnsupportedOperationException nth not supported on this type: PersistentHashMap".
15:12uvtcAm I going about that the wrong way?
15:12wingyuvtc: why are they called _concrete_? strings, booleans and numbers are data types but not concrete?
15:13gfredericksuvtc: I think your my-merge-maps is set to use varargs but you call it with a single arg
15:13uvtcgfredericks, Doh! Thanks!
15:15uvtcwingy, my understanding is that those are all concrete data types. You can make them in your code ... hold them in your hand, so to speak. :) As opposed to abstract data types which are descriptions of how a data type would act if it were to implement said abstraction.
15:23CheironHi, I'm trying to mimic "Composite columns" section of https://github.com/Netflix/astyanax/wiki/Getting-Started
15:23Cheiron(defrecord Session [^{Component {:ordinal 0}} gid ^{Component {:ordinal 1}} tid])
15:37wingyanyone know how i get a error message: https://gist.github.com/3013395
15:38cgagyou're calling columns
15:38xeqiwingy: you're calling columns as a function on line 7
15:38amalloyhow to get an error message? easy, just keep doing what you're doing
15:39RaynesHahahaha
15:41wingycgag xeqi oh thx
15:56uvtc`merge-with` figures out what the new val should be by calling `(f curr-val this-new-val)`, correct? That is, the job of `f` is to come up with a completly new replacement for the val ... is that correct?
15:57nDuff uvtc, yes.
15:58uvtcNice. Thanks, nDuff.
16:02gfredericks,(merge-with + {:a 2 :b 4} {:c 100 :d 200})
16:02clojurebot{:d 200, :c 100, :a 2, :b 4}
16:02gfredericksthat was a terrible example
16:03progo:)
16:03uvtcAnd for that, you must pay. 5 laps around the hash-map while the rest of the team waits.
16:03gfredericks,(apply merge-with + (repeat 100000 {}))
16:03clojurebot{}
16:03gfredericks,(apply merge-with + (repeat 100000 {:a 1}))
16:03clojurebot{:a 100000}
16:04gfredericks,(apply merge-with + (repeat 100000 {(rand-int 4) (rand-int 4)}))
16:04clojurebot{1 100000}
16:04gfrederickswhoops
16:04gfredericks,(apply merge-with + (repeatedly 100000 #(hash-map (rand-int 4) (rand-int 4))))
16:04clojurebot{0 37323, 1 37768, 2 37303, 3 37310}
16:05uvtcgfredericks, I was trying to get this to work https://gist.github.com/3013575 but it's returning
16:05uvtc[{:a 1, :b 2} {:a 11, :c 5, :b 22} {:a 7, :c 6}]
16:07uvtcIf the key is already in the result, but `curr-val` is not a set, then `curr-val` must just be the first number that made it in...
16:09llasramuvtc: missing an `apply` -- `merge-with` is getting passed a vector of maps, rather than maps as a sequence of arguments
16:10uvtcllasram, Ah!
16:10scriptorhmm, probably can't use cljs, but that's not gonna keep me from trying to code like I was
16:19uvtcllasram, it works (updated the gist). At first I didn't see why, but then remembered that you can pass in optional args to `apply` after the func but before the sequence you wish the func applied to.
16:19solussdhow do you change chunk size?
16:19llasramAwesome!
16:20uvtcllasram, yes. Thanks. :)
16:21llasramArgh. I seem to do no better than chance at choosing the correct one of #{< >} in Clojure. A problem I don't seem to have with any other operators, or in languages where those operators are infix. Anyone else experience this?
16:22aperiodicit took me a few months to get the hang of that, but i must confess that i've just gotten good at mentally rearranging it to infix notation in my head
16:22uvtcllasram, if it's ">", then everything after it gets smaller.
16:22uvtcIf it's "<", then everything after gets bigger.
16:23uvtc(I mean, for the expression to be true.)
16:23aperiodicooh, that's a good mnemonic
16:23gfredericksincreasing vs decreasing
16:23uvtcDon't want to take credit for that one. Read it somewhere... (maybe in Joy of Clojure?)
16:24llasramThat's pretty similar to how I'd started thinking of it, but I just found a place where I messed it up again. Guess the solution is just to be more careful...
16:24hiredman,(doc >)
16:24clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically decreasing order, otherwise false."
16:24hiredmanit is how the doc string describes what it does
16:25uvtcHa. Thanks. Guess that's where I saw it. :)
16:25amalloyyou can also write (-> x (> 10)), which reads kinda well as "x greater than ten"
16:25Bronsanice trick
16:26uvtcI'll have a monotonic, on the rocks.
16:26technomancyI thought monotonically increasing meant increasing by one but apparently that's not it. sneaky prefixes!
16:26uvtcWait. Make that diatomic.
16:27amalloytechnomancy: i think it's just a fancier word for "strictly" in that context
16:28raekI think of monotonic as "derivative does not change sign"
16:28aperiodica monotonic function only goes in one direction; strictly monotonic ones *always* go in that direction
16:29aperiodicconstant functions are monotonic, but not strictly monotonic
16:29amalloyaperiodic: that's what i thought too, but if so the doc for > is wrong, right?
16:29amalloy$dict monotonic
16:29lazybotamalloy: adjective: of or using the Greek system of diacritics which discards the breathings and employs a single accent to indicate stress.
16:29amalloy$google monotonic increasing
16:29llasramOh, that makes sense
16:29lazybot[Monotonic function - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Monotonic_function
16:30amalloy&(doc >=)
16:30lazybot⇒ ------------------------- clojure.core/>= ([x] [x y] [x y & more]) Returns non-nil if nums are in monotonically non-increasing order, otherwise false. nil
16:30aperiodicamalloy: yes, a mathematician would say that the doc for > should say "strictly monotonically"
16:31amalloyaperiodic: or you could just discard "monotonically" from the docs for all the comparison functions, at once making them more accurate and easier to understand
16:31amalloy> decreasing, >= non-increasing: done
16:32aperiodicyeah, that's much more accessible
16:34amalloyperhaps someone more strong-willed than i am could make a jira ticket suggesting that
16:36uvtcamalloy, tehehe :)
16:36llasramgithub pull requests are not a valid way of submitting patches?
16:36technomancy=(
16:37llasramOh
16:37llasramOh well. I probably should have guessed
16:39juhu_chapaHi All! How can a method from a proxied class use a binded var?
16:39hiredmanbound
16:40llasramjuhu_chapa: Do you have a particular example in mind?
16:42nDuffjuhu_chapa: it should just work, unless the method is only called somewhere else (outside of the binding's scope, ie. a different thread or a different time)
16:42wingyare you guys using java std lib a lot when using clojure?
16:43wingyare there any libs in java you prefer when doing web apps
16:44technomancywhy doesn't c.j.jdbc convert numbers into j.sql.Timestamps upon insertion?
16:44nDuffwingy: ...I really tend to prefer compojure for building webapps, or do you mean libraries for a specific purpose beyond what Clojure-native bits provide?
16:44juhu_chapanDuff: the method is called from another thread.
16:44nDuffjuhu_chapa: non-root bindings are thread-local by nature, so it sounds like they may not be the right tool for what you're trying to accomplish.
16:45hiredmantechnomancy: I don't think c.j.jdbc does any conversion, any conversion that happens is from the jdbc driver
16:45technomancyoh, gotcha
16:46juhu_chapanDuff: How can I declare a root binding?
16:46ppppaulanyone know of an HTML to JSON converter?
16:46hiredmanwhich makes things really painful, because different jdbc drivers map standard sql types to different jvm types
16:46nDuffjuhu_chapa: ...well, (def var value) is setting the root binding of var to value...
16:47technomancyhiredman: yeah, well database portability isn't
16:47juhu_chapanDuff: thank you.
16:47nDuffjuhu_chapa: ...there's also alter-var-root, but if you want to use that from a proxy method, it means that a var is probably the wrong tool and maybe you should be using a different abstraction (an atom, perhaps?)
16:47timvisher|worktechnomancy: thoughts on why swank.cdt would fail when I try to require it with the latest version of jack-in?
16:48timvisher|worki'm getting CNFE
16:48technomancytimvisher|work: probably because tools.jar is specifically designed to make good tooling impossible =\
16:48timvisher|workfigures
16:48nDuffjuhu_chapa: (that said, using def from inside a proxy would be even more wrong than alter-var-root, so... yar, a continuum, but probably an atom is more the right tool)
16:48technomancythe cdt bits of lein-swank haven't been updated for 2.x
16:48timvisher|workwhat's even weirder is that i swear i had this working some time last week
16:48timvisher|workand i don't think i've changed anything
16:49timvisher|worki shouldn't need to specifically specify it as a plugin or anything, yes?
16:49nDuffmy impression is that it _is_ a separate plugin
16:50timvisher|workthe cdt jar shows up in .m2
16:50technomancythe problem is tools.jar
16:50technomancyit hasn't been updated to work with 2.x yet
16:50timvisher|worknDuff: agreed, of course, but my impression was that jack-in does all sorts of fun stuff to get it on your classpath for easy access
16:50wingynDuff: yeah any Java lib you usually need in addition to clojure ones
16:50timvisher|workso what you're saying is that it won't work under 2.x?
16:50nDuffwingy: ...nope, I don't have any of those.
16:50technomancythat's basically what I'm saying
16:51technomancyin a nutshell, yes =)
16:51juhu_chapanDuff: is it ok to do root binding at -main method?
16:51timvisher|workgotcha gotcha
16:51timvisher|worklol
16:51timvisher|workok, thanks!
16:51technomancyshould be an open issue for it in swank-clojure if you want to give it a crack
16:52timvisher|worklol, i'm getting a backlog of things i should give a crack at :)
16:52timvisher|worksigh…
16:52timvisher|workif only i had more time or different priorities
16:52timvisher|work:)
16:52nDuffjuhu_chapa: ...problematic. During ahead-of-time compilation, anything that expects to reference the var will want it to be defined earlier, ie. at top level.
16:53nDuffjuhu_chapa: you might consider a promise, and then deliver to it from your -main
16:53nDuff(that, or an atom)
16:55mattmossI'm working on some java interop, and I wonder if you might have opinions on this: https://gist.github.com/3013845
16:56mattmossTrying to handle calls into clojure code from java code on a separate java thread.
16:56juhu_chapanDuff: ok, let me check that.
16:56mattmossJust wondering if I'm thinking too hard about the problem and making things more complicated than they need to be.
16:57mattmossThe code works, but... seems maybe I'm doing overkill?
16:58hiredmanwhy not just have a single queue?
16:58mattmosshiredman: All events into one agent?
16:59hiredmanno
16:59hiredmanwhy are you using agents at all?
16:59hiredmando you really want a reference type? or a queue of events?
17:00mattmosshmm... I think initially I put in an agent because I thought "coming in from non-main thread", but that's probably wrong thinking.
17:00hiredmanyou may want to look at something like lamina
17:00mattmossAlso, I wanted "the clojure way" which this probably isn't.
17:01mattmossI also wanted someone able to watch just event-3... but reify needs all three functions defined, even if they do nothing.
17:02mattmossI suppose, overall, I thought letting clients add watches was better than adding multiple listeners, but I can't say why I thought that was better.
17:03llasramI think it depends on what "watch" means for your application, but ref-watching is probably not the right fit
17:04mattmossApologies, also, that I can't be more specific about what event-1 et. al. actually are.
17:04llasramSecrets!!!
17:04mattmosslolz
17:05llasramFrom what you've presented so far, you could just allow each watcher to register a different listener, making it pretty by keeping internal the reify'd Listener closing over the functions to invoke. Maybe?
17:05mattmossI should probably just drop the agents, and write functions more like the swing utils add-action-listener
17:06achengi have (defmulti name "doc string" :key) ... but (doc name) doesn't show "doc string"... what did i do wrong?
17:07mattmossllasram: Yeah, something like that.
17:12jweissi'm using clojure to write tests, and as i posted on the mailing list, i'm having trouble writing out my tests (which can be considered both clojure code and data) in a way that I can read it back in. i keep coming back to eval, but everyone says eval is bad. i know no other way to conserve the original code as data, other than very fancy stuff like serializing all the functions and java objects and everything else.
17:12gfredericksjweiss: read-string doesn't help?
17:13jweissgfredericks: that would turn a string into clojure data, but it would barf on #< ...>
17:13jweisswhich it always does, for me, since my data is full of that
17:13gfrederickswhy is your data full of that?
17:14jweissgfredericks: well, let's say i have a data driven test. and one of the pieces of data is the function it needs to call to produce some value. the function gets printed out as #< ...>
17:14jweissso now my results are unreadable
17:14jweissif i used eval i could have saved the unevaluated form first.
17:15TimMcjweiss: Does serializable-fn help? It's half-joke, half-awesome.
17:15jweissTimMc: actually i do use serializable-fn. it helps for functions. but there are plenty of other non-serializable types.
17:16RaynesTimMc: It's hardly half-joke. I'm using it for pretty important stuff in clojail as of today.
17:16TimMcok
17:16RaynesIt works really well for a lot of things.
17:16TimMcI didn't say it wasn't useful. :-)
17:16technomancyyeah, those don't have to be mutually exclusive =)
17:16technomancylook at elnode
17:16technomancywell actually don't
17:17aperiodic...i don't even
17:17technomancyI warned you
17:17TimMcI thought it had its genesis as a reaction to the repeated attempts at serializable functions.
17:17jweissTimMc: i also have a lot of timestamped values. so i don't want my results to say "I tested abc-123454654564" i want it to say 'I tested (timestamp "abc")'
17:17TimMctechnomancy: Is that what I think it is?
17:17technomancyTimMc: run away!
17:17RaynesTimMc: An evented IO server in Emacs.
17:18jweissserializable-fn would just show me the implementation of the timestamp function, which i don't want.
17:18TimMcahhh WTF
17:18technomancyjweiss: a var might help
17:19jweissyeah i realized i could refer to the function by var instead of symbol. that would make the output nicer but my code uglier.
17:19technomancylife is full of compromises =\
17:19TimMcjweiss: I have used eval for printable inputs: https://github.com/timmc/seqs-and-colls/blob/master/src/seqs/core.clj#L175
17:21jweisstechnomancy: that is true, but i don't want to assume i have to compromise until i'm sure i have to :)
17:23jweissTimMc: ok if you did it, it is not such a crazy idea. My intent was to just quote the code and eval it when the test is executed. i figured the main issue might be namespaces, but i think syntax quote should take care of it.
17:24TimMcjweiss: In my case I used strings, but that's because of the function literals. If not for that, I would have 'quoted them.
17:24jweissall right then i guess i will branch and try out eval and see how it goes :)
17:25TimMcgodspeed
17:26wingyis it possible for a pure function to use a library when you do not know if the functions you are using are pure or not
17:26wingyif they are introducing side effects then your fn is not pure either
17:26TimMcClojure doesn't have reified "pure functions".
17:35timvishertechnomancy: so with lein2-preview6 on my mac, swank.cdt works, but on windows at the same version it doesn't
17:35timvisherthoughts?
17:35mhansonAll the things, they are broken.
17:35mhansonWhoops, wrong channel.
17:36achengphew!
17:36wingymhanson: that's why they are broken!
17:36wingyyou are not using clojure
17:36mhansonwingy: Hah.
17:36wingyHAH!
17:36mhansonBut it's true, I'm using Groovy.
17:36mhansonYuck!
17:37technomancytimvisher: I don't understand how it could work on lein2 anywhere
17:37xeqitimvisher: do you have CLASSPATH set?
17:38timvisherxeqi: nope
17:38xeqior whatever the mac equivalent
17:38timvisherlein version: Leiningen 2.0.0-preview6 on Java 1.6.0_33 Java HotSpot(TM) 64-Bit Server VM
17:38timvisher
17:39timvisherhttps://gist.github.com/3014101
17:39wingyok noob question
17:39wingyhttps://gist.github.com/3014094
17:39wingywhy isnt the first line in the body executed
17:40llasramwingy: Your code is just referencing the function, not calling it
17:40llasramUse/mention distinction!
17:40wingyyeah haha
17:40wingyhaha im such a noob
17:40timvisherwingy: Also if you're in a full featured environment like slime you won't see that output unless you pop open the repl
17:41wingytimvisher: hm havent used slime im on light table
17:41wingyslime is something for emacs?
17:41xeqitimvisher: how bout something like (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))) ?
17:41timvisherwingy: nice!
17:41timvisherlike it?
17:41wingyyeah a lot
17:41wingybest repl ever
17:42timvisherxeqi: https://gist.github.com/3014112
17:42wingycould someone explain what slime is
17:43timvisherwingy: i wonder how long the best features will take to port to emacs
17:43timvisher:)
17:43timvisherstill, light table's one of the more impressive demos i've seen for an ide
17:43xeqihmm, I don't see it there either.. wonder if the mac jdk is built differently :/
17:43wingytimvisher: how does it compare to emacs
17:43wingyso lispers are usually using emacs and not vim?
17:44tbaldridgewingy: the thing with emacs is, it's written in lisp (more or less)
17:44wingytbaldridge: yeah .. why people is using it more in lisp world i guess
17:44tbaldridgeso for me it came down to 1) use vim that's just a real barebones ide, or 2) use a editor that has been editing lisp for years
17:45wingyyeah pretty natural thinking
17:45tbaldridgeSo for instance, in emacs you can type (+ (1 2) 3)
17:45tbaldridgeNow place your cursor over the 1 and hit ALT+s and it turns the code into this (+ 1 2 3)
17:45wingyor 3) use light table which is built on Clojure
17:46tbaldridgeonce you understand paredit it's insane how easy it is to throw things into lists
17:46aperiodictbaldridge: you can do that with paredit.vim, though it's not as full-featured as emacs's paredit
17:46RaynesIt's pretty good.
17:46m0smithwingy: where would one get Light Table?
17:46TimMcm0smith: It's more "when" than "where".
17:47RaynesAnd combined with Vim's built in text objects, I found myself never wanting anything from it that I couldn't get.
17:47wingym0smith: its not fully featured yet .. just a demo
17:47wingyor the REPL version of it
17:47m0smith:(
17:47wingym0smith: http://www.chris-granger.com/2012/06/24/its-playtime/
17:48timvisherxeqi: it is a special port of the jdk
17:48timvisheras far as i understand it
17:48timvisheroh well
17:48m0smiththanks
17:49wingynp
17:49wingycould be used as a good repl atm
17:49wingyits using clj 1.5
17:49m0smithon another subject is there a defacto way of interacting with Swing or another such?
17:59technomancypeople say seesaw is nice for swing
18:00m0smithok thanks
18:06wingymemoize is cool
18:07wingydoesn't FP mean that all our functions should be wrapped in memoize since what is the point in recalculating if the return value always is the same?
18:07wingygiven the same args
18:07technomancydepends how you feel about memory leaks, I guess
18:08amalloyand about doing lookups in a large map to find the result of (inc 1)
18:09gtrakwingy: we shouldn't write code, only lookup tables, clearly
18:09technomancyamalloy: what do you think about implementing a clojurebot backend for clojure.core.cache?
18:09amalloyheh. this just made me think: "classes are cool. maybe we should wrap all our functions in classes"
18:09amalloy"oh nooooo what have we done"
18:10rlbwas reading something recently talking about some of the tradeoffs being different than you might expect with the jvm, i.e. (re)computation cheaper than storage, etc.
18:10amalloytechnomancy: what do i think? knock yourself out, dude
18:10technomancyamalloy: I guess you've been around too long to fall for my tricks.
18:11Raynestechnomancy, amalloy: If we all delegate work to each other, I'm pretty sure none of it can ever get done.
18:12wingyso use memoize only in big calculations?
18:12gtrakhmm... how do I make my lookup table more dynamic...
18:13gtrakwingy: use it in good taste?
18:13wingygtrak: taste is best practice for me
18:13wingytrying to figure out what that one is for memoize
18:13wingydont forget im a beginner in all this
18:13gtrakperformance opts best practice is to do it after profiling
18:14wingywhat is a good way to profile your code?
18:14gtrakwrite for clarity and see how far that gets you first?
18:15gtrakwingy: jvisualvm has some profiling built-in, you can mess with that, you have to simulate some kind of load, you can send a ton of web requests with apachebench (ab)
18:15gtrakthen look for hotspots and things
18:16gtrakclojure itself has a 'time' function
18:18gtrakI'd say though you should *never* use memoize if you inputs/outputs are out of your control? prefer something like core.cache
18:18technomancyI wish core's memoize just got slightly more clever and c.c.cache built on that
18:18technomancybecause there are lots of cases where pulling it in is huge overkill
18:19wingythis one ? https://github.com/clojure/core.cache
18:19gtrakor just make static things static, ie do the work at compile-time
18:22gtraktechnomancy: shouldn't be too hard to write a simple cache?
18:23technomancyyeah, but it would take 3 lines to make the built-in memoize significantly smarter
18:24gtrakyou could also use google's thing
18:24technomancyjust place the cache atom on the metadata of the function returned and accept an argument for an alternate swap! function
18:24technomancynow you can easily switch to LRU or some other strategy
18:24CheironHi, I'm wrapping Hector library in Clojure to be used in realtime system. should I use type hints?
18:25brehautCheiron: only if a) *warn-on-reflection* warns you or b) you need it for interop call site resolution
18:26Cheironi'm thinking to use types hints since the software is realtime
18:26gtrakCheiron: realtime is not java
18:26hiredmanis realtime the same thing as webscale?
18:26brehautCheiron: type hints are magic pixie dust, and they are not static types.
18:27Cheironwell, I'm using Storm (realtime processing) , you are right.
18:27TimMcI thought they *weren't* magic pixie dust.
18:27brehautsorry
18:27wingyhave you guys encountered many aspies in programming world?
18:27brehautTimMc is write and i typoed
18:27hiredmantype hints let you avoid the overhead of reflection, so unless you know you are using relfection, don't use them
18:27technomancyif you have to ask, don't type hint
18:28gtrakmaybe storm is 'real-time' in comparison to batch, the way that hadoop is normally used
18:28Cheironok. crystal clear
18:28Cheironone more thing would you please check section :composite columns: of https://github.com/Netflix/astyanax/wiki/Getting-Started ? I tried to mimic it
18:28Cheiron(defrecord Hit [^{Component {:ordinal 0}} gid ^{Component {:ordinal 1}} tid])
18:28technomancytype hints are for after you've determined 0) it's slow and 1) it's slow because of reflection
18:29hiredmanCheiron: that isn't even correctly type hinting
18:29CheironI'm not type hinting here
18:29CheironI'm using annotations
18:29Cheironearlier I typed: one more thing, so this is another topic :)
18:30Cheironso, this is a valid use of annotations in Clojure?
18:31hiredmanCheiron: there is little to no use of the annotations stuff (as far I as can tell) so generally you best bet is to read the code
18:32hiredmanof course I've read the code, and don't recall, I think when I messed with it I didn't need an annotation with a value
18:32hiredman(and of course I wanted an annotation on a constructor, which wasn't (isn't?) support)
18:32hiredmansupported
18:32Cheironin case of Astyanax (the link I posted) , annotations are necessary
18:33hiredmanhttp://dev.clojure.org/jira/browse/CLJ-948
18:34hiredmanmost likely you'll need something more like what a java consumer would expect, strings for keys (maybe the annotation stuff calls name?)
18:35CheironI don't know really, I'm experimenting :)
18:44wingyso in clojure besides executing a function, what are the differences between lists and vectors?
18:44wingywhich one should i use as an array in other langs to store multiple items
18:45nDuffwingy: Depends. Do you need efficient indexed access? Do you need to add things to the beginning or the end?
18:45wingyif i do that would be vector?
18:45nDuffwingy: the beginning, or the end?
18:45nDuffwingy: which one?
18:46wingyend!
18:47nDuffwingy: for efficiently adding to the end, or efficient indexed access, you want a vector.
18:47nDuff(likewise for efficient removal from the end)
18:48nDuff...which is why neither lists _or_ vectors make good queues
18:49aperiodicwell, lists make great FIFO queues
18:49aperiodicer, LIFO queues
18:49aperiodic:P
18:50nDuffgreat stacks, indeed
18:50brehautwingy: a simple rule if you havent internalised the details: you want vectors unless you are writing a macro ;)
18:50nDuff...but the point I was trying to make to wingy was the need for PersistantQueue
18:50nDuffwingy: ...also, if you don't care about where you add something (beginning or end), use conj, and it'll do whichever is efficient.
18:51wingyok
18:52TimMcbrehaut: For macros I use seqs, not lists.
18:54brehautTimMc: i take any excuse to use list*
19:02TimMc&(type (list* 1 2 [3]))
19:02lazybot⇒ clojure.lang.Cons
19:02TimMcbrehaut: FYI ^
19:02brehauta mere technicality :P
19:03TimMchah!
19:05wingybtw what is the real point in having vectors and lists and not one data type for them?
19:05wingywith indexed access in it
19:05brehautwell to start, lists arent an indexed
19:06nDuffwingy: ...so, vectors are fast, but adding and removing things from the head of a linked list is _incredibly_ fast.
19:06wingydoes that mean they have no order?
19:07wingyok
19:07wingythey are fast!
19:08wingylist is an unindexed fast vector
19:08nDuffThey're fast for different things.
19:08nDuffBecause vectors are indexed, they're fast for random access
19:09nDuffwhereas lists are only fast when working with the head.
19:09wingynDuff: so there is no way to pick a specific item in the middle of a list?
19:09nDuff...not "no way"
19:09nDuffno _fast_ way.
19:09nDuffit's an O(n) operation depending on how far into the list it is.
19:09brehautwingy: only by walking (potentially) the entire list
19:09wingyok
19:10nDuffwhereas vectors are O(log32 n)
19:10wingyi get it more now
19:10nDuffwhich is practically O(1)
19:10nDuff("amortized constant time")
19:10wingyyeah if things arent indexed you have to traverse
19:16Cheironclojurebot: Tesla or Edison?
19:16clojurebotExcuse me?
19:17amalloybrehaut: i disagree with "if you don't know the difference, use vectors". it leads to people being like "halp i have this function that produces a list but i need a vector because brehaut said so"
19:17duck1123Has anyone experienced an issue with the new lein and cljsbuild? I'm not seeing it as a task
19:18brehautamalloy: geez, that would be the single worth appeal to authority in the world :( i agree with your refutation
19:19CheironI need to use a fixed list of values, so I create a mao of keywords. any better ideas?
19:20duck1123ok, I had it specified in my project.clj, but not in my .lein. I see it now. Should it show up if it's in profile.clj?
19:21duck1123ok, ignore my question altogether
19:21aperiodicCheiron: why not a set?
19:25CheironHmm. also possible
19:26Cheironbut I don't feel using a map or set is neat
19:26clojurebotIn Ordnung
19:26Cheiron(:A set) (:B set)
19:30aperiodicyou can get all the members of a set in a seq by just calling seq on it, if that's more convenient
19:31kovasbohpauleez: hey, are there any sample apps in the shoreleave repo set? most interested in the pubsub and services stuff
19:32ohpauleezkovasb: I haven't had time to finish up the app I showed at the meetup (which uses the google maps service and the pubsub stuff)
19:32ohpauleez(traveling a little this week and next)
19:32kovasbohpauleez: understood. are there any examples of usage somewhere?
19:34kovasbi think i saw some on your slides.. will try to look them up
19:38ohpauleezThere are some on the slides, and I just put this together: https://gist.github.com/3014746
19:38ohpauleezshould give you a very rough idea
19:40ohpauleezkovasb: ^
19:40kovasbohpauleez: thanks! will bug u if i have any issues :0
19:40ohpauleezCool, thanks for trying it out
19:44ohpauleezkovasb: And services (google maps geocode) : https://gist.github.com/3014768
19:44kovasbtight.
19:53gfredericksis it really CinC before jvm-clj is finished?
20:01ohpauleezgfredericks: what do you mean?
20:01gfredericksohpauleez: just trolling
20:29frozenlockIs there a function to recursively replace a matching key in a map with a new value?
20:29frozenlockKinda like `update-in', but for any depth.
20:31technomancyfrozenlock: clojure.walk might have something
20:32frozenlockI must be using it wrong :(
20:32frozenlock$(clojure.walk/prewalk #(if (:b %) {:b 10} %) {:a {:b 2 :c {:e 4}}})
20:33frozenlock,(clojure.walk/prewalk #(if (:b %) {:b 10} %) {:a {:b 2 :c {:e 4}}})
20:33clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>
20:33frozenlockWut.. it works on my machine.
20:33frozenlockWell no it doesn't work, but it gives something -_-
20:34aperiodicfrozenlock: you probably want (assoc % :b 10) instead of just replacing the map in your then clause
20:34frozenlockOf course!
20:35frozenlockWorks like a charm, thanks to both of you :)
20:36aperiodicyou're welcome
21:06devnhow do I update the clojure.org documentation?
21:06wingyis there a reference for all functions for a collection, sequence, string etc
21:06aperiodicwingy: http://clojure.org/cheatsheet
21:07devnhttp://clojure.org/cheatsheet
21:07wingycool
21:07aperiodici win this round of "cheatsheet URL quickdraw" ;)
21:07devnwingy: you might also be interested in clojureatlas.com
21:07devn(ooohhh I just 1up'd you aperiodic)
21:07wingythis project seems dead http://clojuredocs.org/
21:08aperiodicaw, nuts
21:08devnwingy: it's not. I submitted examples recently.
21:09wingyhavent been updated for a while
21:09devnaperiodic: you ever print clojure code with the pretty printer?
21:09wingyand its showing 1.3
21:09devnwingy: the changes from 1.3 to 1.4 are still pretty small. is there something you're looking for in particular?
21:09wingyi couldnt find seq
21:10aperiodicdevn: i don't recall having done so off the top of my head, why?
21:10devnwingy: http://clojuredocs.org/clojure_core/1.3.0/clojure.core/seq
21:10wingybecause i was blind
21:10devnlol, no worries
21:10wingya lot of references!
21:10devnaperiodic: hm, it's just not working like it used to
21:11devnwingy: are you referring to the very limited "see also" section?
21:11wingyin which reference? im having at least 4 up :)
21:12wingyhttp://clojure.org/Reference http://clojure.github.com/clojure/ http://clojure.org/cheatsheet http://clojuredocs.org/quickref/Clojure%20Core
21:13devnheh, i was referring to the seq examples on clojuredocs
21:13devnseq should probably have quite a bit of "see also" in it
21:14wingyatlas looks cool
21:14wingyand productive
21:17wingya good feature for the REPL could be that when you hit ENTER or enter it for the first time it will place you in (_)
21:17wingyno need to type () all the time
21:18amalloywingy: i kinda have to point out that (a) you type parens all the time anyway, and (b) that makes lots of things impossible, such as printing [(foo) (bar)] or *clojure-version*
21:19wingyone backspace for deleting them
21:19wingysince they are paired .. but probably unnecessary since its just a simple repl
21:20devnwingy: yeah, that's up to other tools IMO
21:20wingyactually better without since now you can copy paste :)
21:20wingyi thought i was smart
21:22wingyhe has a great product but the demo is killing it .. cut it down to 1-2 min .. im falling asleep
21:26wingyanyone here using Atlas? do you recommend it?
21:28brehautwingy, im pretty sure cemerick would recommend it ;)
21:29wingyhe's the author?
21:29brehautyes
21:46alfred1is there a clojure wrapper for neo4j, the graph database?
21:51wingyalfred1: https://github.com/mattrepl/clojure-neo4j
21:51wingythis is a better one i think: https://github.com/michaelklishin/neocons
21:51clojurebotOk.
21:51wingyclojurebot: ?
21:51clojurebotIt's greek to me.
21:51wingyclojurebot: i bet
21:51clojurebotsharing code between client and server is not as simple or great as it sounds: http://blog.ianbicking.org/2011/03/30/js-on-server-and-client-is-not-a-big-deal/
21:55alfred1second one, neocons, looks cooler, thank you wingy
21:55wingynp
21:55wingyalfred1: cypher is pretty cool as well .. you can do a lot with it nowadays
21:56wingyjust a post request to HTTP cypher endpoint
21:57wingyCREATE (person {name: {name}, age: {age}})
21:57wingyso the need for a lib is smaller with the latest version
21:58wingyone of the few things it doesn't do is indexing when you are creating an entity .. that's what i think neocons would help you with
21:59alfred1i'v just started tasting neo4j, haven't got clue of what cypher really is, is it the query language used in neo4j?
21:59wingyyeah for CRUD
21:59wingyand traversal
22:00wingy(wingy)-[:LIKES {since: "yesterday"}]->({name: "Clojure"})
22:01alfred1cool.
22:15eckwhat is generally used for parsing command line flags/options
22:16aperiodiceck: I usually use https://github.com/clojure/tools.cli
22:16eckcool, thanks
22:17gtuckerkelloggaperiodic, how to you find that compares to clojopts?
22:23aperiodicgtuckerkellogg: i haven't used clojopts before (or heard of it, even). it looks pretty similar, but a bit nicer, with the only thing missing being a handy way to create flags.
22:25frozenlockIf I want to change a static variable in a jar, could I just open the .clj inside the jar, change the value, save and close? This way I could make "personalized" jar without doing lein uberjar each time.
22:35wingyi cant distinguish lists and seqs
22:36wingythey look the same
22:36amalloygood. don't distinguish them. just treat them as seqs
22:37wingyamalloy: thats the way?
22:37Scriptorwingy: they're supposed to have the same interface, what do you need to differentiate them for, might be able to solve the source of the problem
22:37wingyreading Clojure Programming
22:37wingy"Sequences are not lists"
22:38Scriptornot all sequences are lists, yes
22:38wingydonno .. i guess i just want to know the details when someone say list or seq
22:38wingy'(1 2 3)
22:38wingyis that a list or seq
22:38Scriptorthat's specifically a list
22:39Scriptorbut lists implement the interface for seqs
22:39Scriptorfirst, rest, next
22:39TimMclists *happen to be* seqs.
22:39Scriptoryep
22:39wingyok seq is an interface
22:39Scriptorall squares are rectangles, but not all rectangles are squares
22:39Scriptorsame things
22:39TimMcwingy: No, seq is an abstraction.
22:39wingyok
22:39Scriptorwingy: yes, ISeq is the name of the actual interface
22:39wingyTimMc: Hah!
22:39Scriptorwell, TimMc is also right
22:40Scriptorwhen we talk about seqs, we talk about the general idea
22:40Scriptorand ISeq is just the code that implements that idea
22:40TimMce.g., nil can be used in the seq abstraction, but does not implement ISeq
22:40wingyso now this is a seq: (seq '(1 2 3))
22:40Scriptor'(1 2 3) is also a seq
22:40wingyoh yeah .. that implements seq as abstraction/interface
22:41TimMc'(1 2 3) is reflectively a seq; (seq '(1 2 3)) is... semantically? a seq.
22:41wingyso there is no need for doing: (seq '(1 2 3))
22:41Scriptorhere's ISeq.java https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java
22:41wingysince '(1 2 3) is already a seq?
22:41Scriptorit's astoundingly simple
22:41Scriptorright
22:41ideally_worldhas anyone here been able to get Slime to work with ClojureScriptOne?
22:42TimMcwingy: If this seems confusing, you're right -- this is a grungy part of Clojure that incurs a bit of cognitive load.
22:42wingyso "string" is also a seq?
22:42TimMcNope!
22:42wingysince we can do first on it
22:42Scriptornah, that just "happens" to be able to support first
22:42TimMcwingy: 'first calls 'seq on its arg.
22:43TimMcThis is true of a lot of seq-consuming fns.
22:43wingyah
22:43amalloywingy: strings and vectors are seqable, but not seqs
22:43TimMcAnd the fn 'seqable? is a lie.
22:43wingyis a list seqable or a seq?
22:43TimMcYes.
22:43TimMc(Both.)
22:43Scriptorlist is a seq
22:43wingyis list the only seq?
22:43amalloyit is a seq, and implements seqable by returning itself
22:44TimMcwingy: (range), (seq [1 2 3]), and (cons 5 []) are all different kinds of seqs.
22:44Scriptorwingy: no, there's also lazy lists
22:44ideally_worldseq is seqable, but seqalbe isn't necessarily a seq?
22:44wingyideally_world: thats sounds right
22:44Scriptorideally_world: seqable just means you can call (seq ...) on it and it will reqturn a valid seq
22:44TimMcor nil
22:45TimMc&(seq [])
22:45lazybot⇒ nil
22:45TimMcNil-punning is a hell of a drug.
22:45Scriptorcheck out the java source for first() https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L564
22:45wingyok there are different kinds of lists .. they are all seqs and seqable
22:45wingyso only lists are seqs?
22:45Scriptornot quite
22:46Scriptor(cons x ...) returns, internally, a cons object
22:46joshua__&(source seq)
22:46lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
22:46wingythis is bad design shouldnt be this hard to get haha
22:46TimMcwingy: (range), (seq [1 2 3]), and (cons 5 []) are not lists!
22:46Scriptoragain something you can see by looking at the source! https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L554
22:46TimMcwingy: Half bad idea, half good idea.
22:47Scriptoryea, once you internalize it it makes a lot of sense
22:47wingyScriptor: im not a source code guy :/
22:47wingyyet
22:47Scriptorah, still, try to check them out
22:47TimMcwingy: http://www.brainonfire.net/files/seqs-and-colls/main.html
22:47Scriptorthe functions are pretty small
22:48Scriptorfor example, in cons, you can see that (unless you're consing onto null, ignore that for now) you get: return new Cons(...)
22:48Scriptorso an object of the class Cons, which is a different class than what lists use
22:48Scriptorhowever, both Cons and PersistentList (the class for lists) are seqs
22:49brehautwhere does the .lein directory (and thus the lein2 profile.clj) live on windows?
22:51wingycool to look at the source
22:51wingyhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IPersistentCollection.java
22:51Scriptorright? :)
22:51wingyall collections are seqable
22:51wingybut the doc should make that clear
22:52wingyis there a way to know that all collections are seqable besides looking from the source?
22:52xeqibrehaut: reading the shell script mentions %USERPROFILE%\.lein
22:52brehautxeqi: thanks
22:53wingyi hope light table fixes this in the future .. no more jumping around
22:53wingythat's their goal i guess
22:53technomancywingy: there's no way to tell
22:54wingyi have like 4-5 references up
22:54technomancyjust try it
22:54wingyactually there is
22:54wingyif the java doc was generated
22:54wingyand we get something like this: http://docs.oracle.com/javase/7/docs/api/index.html?java/lang/String.html
22:55metellusi don't really see why you would need to know about seqable at all, unless you were digging into clojure's internals
22:55aperiodicwingy: http://clojure.org/data_structures notes that all collections support sequencing
22:55wingyits confusing to not knowing the differences when you are trying to learn a programming language .. you dont know how its all related and dont know how to look it up
22:56technomancydon't look it up
22:56technomancytry it in the repl
23:00PeregrinePDXIndeed I think I've learned more from just trying in a repl
23:00PeregrinePDXwith the occasional (doc ) in the repl as well
23:06TimMc"Empirical programming", a coworker called it.
23:06anierohey, i'm trying to figure out the best concurrency mechanism in clojure to use for wrapping a Process
23:07anieroi've got multiple incoming threads that need to access it, but it may or may not be running yet, or may have failed, or whatever the case may be, and i need to have all but the first thread waiting for the process to start correctly before proceeding, while the first thread in sets it all up
23:08anierothe best i can think of is to use an agent for the Process, and use (await (send-off (find or create ...))), but joy of clojure implies this is an antipattern
23:09brehaut,(let [p (promise)] (dotimes [n 5] (future (do @p (prn "done")))) (Thread/sleep 3000) (deliver p true)) ;; no idea if this is a good idea
23:09clojurebot#<SecurityException java.lang.SecurityException: no threads please>
23:10brehaut&(let [p (promise)] (dotimes [n 5] (future (do @p (prn "done")))) (Thread/sleep 3000) (deliver p true)) ;; is lazybot my friend?
23:10lazybotjava.lang.SecurityException: You tripped the alarm! future-call is bad!
23:10brehautnope
23:10TimMcHey, clourebot used to allow threads, yeah?
23:10brehauti thought so
23:11brehautbut hiredman has been tweaking his eval recently
23:11xeqihiredman did some security updates recently.. threads might have been a casuality
23:11wingythe book says (range 1 5) is returning a collection
23:11wingybut the repl and doc says seq
23:11TimMcwingy: http://www.brainonfire.net/files/seqs-and-colls/main.html
23:12anierobrehaut: hm, use a promise to say "hey, this thing is all good"?
23:12brehautaniero: maybe? misuse of promises is a great way to deadlock though
23:13anierohmmm, if i create the promise at init time before letting any of the threads through, there won't be a race condition for initializing it either... hm.
23:13technomancyaniero: does it have to be synchronous? you could use in-process queues
23:13xeqiRaynes: I saw the clojail update, is lazybot updated too?
23:14anierotechnomancy: first thread in needs to initialize some stuff, anything coming in during that needs to wait, after that everything's fine
23:14anierothis is on-demand or i'd do the initialization first :)
23:14brehaut(let [p1 (promise) p2 (promise)] (future (do @p1 (deliver p2 :done))) @p2 (deliver p1 :done)) ;; aniero
23:14cemerickwingy: all seqs are collections, too
23:15cemerick,(coll? (range 1 5))
23:15clojurebottrue
23:15wingyyeah
23:16wingyso we have two seqs
23:16wingy(range) and '()
23:16amalloybrehaut: that...never terminates, right?
23:16brehautamalloy: correct
23:17brehautamalloy: just showing that its easy to deadlock with promises, even if they are created before they are used
23:17wingywhat would i do without that reference
23:17technomancywingy: it occurs to me that you're heading towards burning out on splitting hairs and would have a lot more fun if you just got to coding; most of this stuff makes sense once you've been using it for a while
23:18wingytechnomancy: no going forward without knowing!
23:18brehautwingy: not knowing never stopped a PHP programmer ;)
23:18wingyi feel happier to read on when i dont ignore things
23:18aperiodicaniero: in this sort of situation i use an atom that initially holds nil, and to decide which thread does the init, they (swap! atom (fn [id] (or id (.getId (Thread/currentThread)))) and see if the swapped value was their id
23:18wingythats why they are using PHP
23:18wingyif they only knew
23:18cemerickwingy: non satis non scire
23:19wingyphp was my first lang
23:19wingyno it was bash
23:19aperiodicheh, my first lang was ActionScript2
23:19wingyno . dos!
23:20TimMcYou freaks. Mine was English.
23:20TimMcI still don't know how it works.
23:20aperiodicnobody does, that's why it's so much fun
23:20anieroaperiodic: ah, so when a thread sees that it didn't set its own id, it waits somehow for the winner to do its job?
23:21aperiodicaniero: yeah, and you can use a promise for that w/out deadlock; winner delivers, everyone else derefs
23:22technomancyhuh; did github switch back to showing SSH clone URLs by default? thank goodness
23:23wingywhy did they show HTTPS
23:23technomancyugh
23:23wingywanted to add security?
23:23anieroaperiodic: (let [id (.getId (Thread/currentThread)] (if (= (swap! a (fn [i] (or i id)))) (do (initialize) (deliver p)) (deref p)
23:23technomancybecause some pitiable souls have horrible firewalls, I think
23:24technomancymaybe also so you could use the same URL for public clones and pushes
23:24aperiodicaniero: looks good, except you're missing the comparison to id (that is, = only has one arg)
23:24anieroer, right. but cool, ok!
23:25hircusLauJensen: ping
23:25anieroand then i get to figure out how to handle timeouts / restarts of that shared resource...
23:25technomancyhircus: hey, how goes the packaging?
23:27anieroaperiodic: thanks!
23:28aperiodicaniero: you're welcome!
23:29TimMctechnomancy: When I wrote to them to tell them they were showing HTTPS by default, they said "That's a known bug, we have a ticket open to get it fixed."
23:29TimMcThat was June 4.
23:29technomancyoh, cool
23:29TimMcOr... hmm. That was re: showing HTTPS in the new-repo instructions, which is a bit different.
23:31wingy(cons [1 2] [4 5 6])
23:31wingyReturns a new seq where x is the first element and seq is
23:31wingythe rest.
23:31wingythe last one is not a seq!
23:31TimMcIt gets seq'd.
23:32wingylol
23:32TimMc&(type (rest (cons 1 [2 3])))
23:32lazybot⇒ clojure.lang.PersistentVector$ChunkedSeq
23:37wingyi guess i dont want to know the details after all
23:38wingyas long as it just works
23:38brehautTimMc: surely you mean 'class not 'type
23:38TimMcbrehaut: Surely I do!
23:38TimMcBad PHP and Python habits.
23:38brehautoff
23:44cemerickWhat's wrong with type? A bit of a child of its times, but…
23:49TimMcOne rarely wants the ad-hoc hierarchy info.
23:49amalloyTimMc: if a multimethod dispatches on type, as print-method does, you can customize how a particular instance of a single class behaves by giving it metadata
23:49hircustechnomancy: hullo! going well, but Leiningen itself is stalled on some Maven2 packaging bugs
23:50amalloyeg, serializable-fn uses this to make closures serialize
23:51hircus(the Maven2 maintainer wanted to wait for some packaging guideline clarification before creating more Maven2 compatibility modules, and right now the shipped modules are... er, missing dependencies). can Leiningen 1.x work with Maven 3?
23:57JulioBarrosAnyone know of an easy way to generate the SHA1 hash of a file?
23:57JulioBarrosOr of a project I could borrow some code from?
23:58wingyare you guys unit testing your functions?