#clojure logs

2009-05-12

01:25pjolkso what is the advantage of clojure over scala?
01:26tWipthat seems like a loaded question
01:27slashus2It is dynamic? It is a lisp (homoiconicity).
01:27hiredmanthe persistant immutable datastructures, the s-expressions, the simple core
01:27hiredmanthe lack of a dog slow compiler
01:27tWipdon't know scala (at all really), I've always favored lisps over anything else
01:27pjolk, (let [f (compose (+ 1) (* 3))] (f 10))
01:27clojurebotjava.lang.Exception: Unable to resolve symbol: compose in this context
01:27pjolkyes the scala compiler takes forever
01:28hiredmanclojure doesn't do automatic currying
01:28hiredmanor uncurrying
01:28pjolkbut scala works well with the JVM
01:28hiredmanwhicheever
01:28hiredmanso does clojure, that is what it is made for
01:28pjolkisnt dynamic typing a problem when you start to get 5K loc +?
01:29dnolenpjolk: no
01:29pjolkunittests for things the compiler can show(and doesnt miss)
01:29dnolenpjolk: SmallTalk implementation have 300,000 LOC of code.
01:29hiredman,((comp (partial + 1) (partial * 3)) 10)
01:29clojurebot31
01:29slashus2That is a strawman argument with respect to dynamic typing.
01:29pjolk, (let [f (comp (+ 1) (* 3))] (f 10))
01:29clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
01:30pjolkslashus2: why?
01:30hiredmanpjolk: did I not just say clojure does not automatically curry functions?
01:30slashus2It is also specious.
01:31dnolenpjolk: because your statement is not backed up by anything, at least in the real world. in anycase, are you trolling? or you actually trying to assess something.
01:31pjolkslashus2: how is it a strawman?
01:31pjolkim trying to decide what to use, scala or clojure
01:31pjolki might do an app for the android as well
01:31slashus2It is an argument that is easily knocked down. Therefore it is a strawman argument.
01:32pjolkdnolen: isnt it backed up by the fact that most big projects in the world are written n static languages like retard-java and monster-c++
01:33dnolenpjolk: no.
01:33slashus2I don't think the fact that most projects are written in static languages leads to the conclusion that dynamic languages have problems with programs over 5K lines of code.
01:34pjolkok 20K?
01:34pjolk50K?
01:34pjolkbut nce if it doesnt
01:34slashus2It is very dependent on the skill level of the programmer.
01:35pjolk_but do you compensate with loads of unittests?
01:37slashus2I would think a healthy amount of unit tests would help.
01:37dnolenpjolk: in static languages you'll need to write unit tests as well. anyways, write some code Clojure and Scala, and decide for yourself. there is no quick answer to your question.
01:38pjolk_i like scala better than java but it feels like wielding a 200pound broad sword to slice bread. heavy and clumsy
01:38hiredmanhave you spent anytime in #scala?
01:38pjolk_yes
01:39hiredmanthe constant gripingabout compiler bugs doesn't scare you away?
01:39hiredmanwell
01:39pjolk_gripingabout?
01:39pjolk_you mean there are a lot?
01:39hiredmanconstant is an exageration
01:40pjolk_and clojure doesnt have (m)any?
01:40hiredmanat least once a day
01:40hiredmanI am sure it must have some
01:40hiredmanI mean, come on, this is the real world
01:40pjolk_well the compiler is slow, thats a bit annoying
01:41hiredmanit sounds like scalas complexity is a real problem
01:42hiredmanwhich is often the problem with static typing, you end up with large complex codebases
01:43hiredmanand the zest the scala guys have for all kind of crazy haskell stuff doesn't help, I am sure
01:45dnolen,(let [f (comp (partial + 1) (partial * 3))] (f 10))
01:45clojurebot31
01:46hiredmanand, I mean, come on, scala isn't even a lisp
01:47pjolkzest?
01:47slashus2hehe
01:47pjolkwell i love haskell but i think for it to work it needs perhaps its own environment. it needs purity, laziness etc
01:48pjolkotherwise it is just having features that doesnt really work
01:48pjolkand scala really is a kitchen sink
01:48hiredmanit is java all over again
01:49hiredmanscala is to functional programming what java is to oo programming
01:50pjolkyou mean a horrible clusterfuck and misinterpretation?
01:50pjolkbut maybe it will make functinal rpogramming popular
01:51pjolkthen well have people using haskell in 2020
01:51hiredmannah
01:52hiredman2012 to 2112 is the century of clojure
02:25replacasometimes I wonder which is the bot, clojurebot or hiredman. Neither seems to sleep.
02:25replacamaybe clojurebot invented hiredman so that hiredman could invent clojurebot
02:26slashus2That is a paradox.
02:26slashus2:-(
02:27replacaonly if you assume time is linear
02:27replacaand a western model of causality
02:27slashus2I do assume that.
03:03unlinknth says it will be O(n) for sequences, but this is incorrect--it should be ?(n)
03:05jdzso most people don't understand its performance?
03:05pjolk_omega(n)? what does that mean?
03:05jdzexactly
03:06opqdonutpjolk_: Omega(n means lower bound
03:06opqdonutwith a large omega, with a small one it means "truly asymptotically larger than"
03:29pjolk, (map inc (range 10))
03:29clojurebot(1 2 3 4 5 6 7 8 9 10)
03:29pjolk, (reduce + (map inc (range 10)))
03:29clojurebot55
03:31pjolk> (filter #(> 5) '(1 23 45 4))
03:31pjolk, (filter #(> % 5) '(1 23 45 4))
03:31clojurebot(23 45)
03:31pjolk, (filter #(> 5) '(1 23 45 4))
03:31clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--5472$fn
03:32jdzpjolk: don't you have a repl?
03:48hiredmanhttpunit demanding valid and trusted ssl certs is amazingly frustrating
03:52__macI've never used that, is it good besides the cert frustration?
03:52hiredmanhard to say
03:52hiredmanit looks like it
03:53hiredmanbut I hit the ssl block very early
03:53__macI've used selenium before but depending on a browser is very slow and frustrating at times
04:14unlinkjdz: Your sequence is free to take n^n time each iteration if it wants.
04:14jdzunlink: umm, what's that about?
04:15jdzomega?
04:15unlinknth
04:17jdzwhen i see O(n), i expect a linear time access behaviour, when i see ?(n) i'm not really sure what to expect
04:18jdzexcept that it's quite similar to O(n) with some nitpicking from academics added
04:18unlinkno, O(n) is an upper bound, which is wrong
04:19jdzwhy is it wrong?
04:19unlinkit can take arbitrarily long, it should be a lower bound
04:19jdzsince when nth can take arbitrarily long?
04:20unlinkwhen your sequence does expensive computations each iteration
04:20jdzit's still O(n)
04:21unlinknot if it's, say, O(n^2)
04:22unlinkimagine a naive implementation of a fibonacci sequence
04:23unlinknth is O(2^n)
04:23jdzand in Clojure it's O(n)
04:23unlinkwhy do you think that?
04:24unlinkclojure doesn't automatically optimize your slow algorithms
04:24jdzwell, it does
04:25jdzthis hand waving is not gonna get us anywhere, let's talk about code!
04:25jdzwhere is the code?
04:29unlink(nth (map (fn fibs [n] (condp = n 0 0 1 1 (+ (fibs (- n 1)) (fibs (- n 2))))) (iterate inc 0)) N)
04:29unlinknth takes O(2^N) time
04:30jdzit's not nth that takes O(2^N) time, it's the map
04:31unlinkNo, the map is lazy. The nth forces evaluation.
04:31unlinkAnd it is certainly not O(N)
04:35jdznth does exactly N steps to get at the required element
04:36jdzso it's O(N)
04:36opqdonutnth destructures n conses
04:36opqdonutthat's all that can be said, really
04:36opqdonutbut it is true that the 2^N effort happens "inside" map
04:37opqdonutwith laziness you really can't look at when the work happens, you have to look at inside which closure it happens
04:40hiredman~javadoc javax.net.ssl.X509TrustManager
04:41hiredmanugh, void return methods
04:46hiredmanI think I will pretend to sleep
04:46__machiredman: Yeah that bothered me as well when I did some X509 stuff a while back. In fact, void returns always bother me these days :/
04:47__macBut it's particularly bad there because a boolean return would have sufficed but instead they use an exception in case of denied access etc.
04:52tWipit's bad legacy api... but easy to wrap and be done with
05:23jdzunlink: btw, Clojure way of generating fibonacci numbers is (def fibs (concat [0 1] (map + fibs (rest fibs)))); a lot simpler.
05:24jdzand nth on fibs in this case might work in less than O(n) time
05:25Holcxjo Less?
05:26jdzyes
05:26jdzbecause of the caching
05:26unlinkhttp://en.wikipedia.org/wiki/Big_O_notation
05:26__macCan kill your heap though ;)
05:27HolcxjoIt's a list; and nth of a list is O(n), right?
05:27jdzHolcxjo: it's a sequence.
05:27jdzlazy at that one
05:28jdzunlink: nth walks a sequence "sequentially", so it's run time is O(n). end of story.
05:34AWizzArdone could make nth O(1) by making it much slower
05:35unlinkuser=> (use 'clojure.contrib.seq-utils :only '(indexed))
05:35unlinkjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Boolean (NO_SOURCE_FILE:0)
05:35unlinkam I doing something wrong here?
05:36AWizzArd(use '[clojure.contrib.seq-utils :only [indexed]])
05:38unlinkThanks.
05:41unlinkWhy is the library wrapped in a vector?
05:42AWizzArdthe [indexed] itself could as well be a list if you wish
05:42unlinkI noticed.
05:43AWizzArdYou can also do some magic such as (use '[clojure.contrib [def :only [defvar-]] [seq-utils :only [indexed]]])
05:43unlinkThat's what I was looking for. Thanks.
05:53tWipI miss nil punning
05:54unlinkYou mean from CL?
05:55tWipfrom previous versions of clojure
05:55unlinkor vs old lazy sequence semantics
05:56unlinkWhy? What can't you do now?
05:56tWipwell, just tongue in cheek assertation really :P
05:57tWipI had to change 2 lines of my old code, which frustrated me
05:57unlinkSorry to hear it. It happens sometimes.
05:59tWipbut all joking aside, upgrading from the dec 2008 release to 1.0.0 has been pretty painless
06:05unlinkDon't you wish every upgrade could have been like the road to Django 1.0?
06:40tWipunlink: what's django? isn't that some python thingy
06:41__macCould also be an australian animal, but I doubt they have version numbers.
06:56rsynnott__mac: young earth creationists would no doubt disagree with you there :)
06:56rsynnottoh, anyone know if swank works with clojure 1?
07:01jdzrsynnott: works for me
07:01rsynnottcool
07:02jdzi think it should have been: works for me (TM)
07:49asbjxrnMostly works for me. I've got a strange "slime-compile-defun" compiles everything in the user namespace.
07:49asbjxrnBut then, I didn't use slime before, so it might have been there earlier as well. Probably related to my setup more than clojure 1
09:26chessguy_workso here's something i've been thinking about re: macros
09:26chessguy_workin some ways, macros aren't any different from functions
09:26chessguy_workin that both can take a clojure program and transform it
09:26chessguy_workthe real difference is WHEN it happens
09:26Chouseryes
09:27Chouserin fact a macro *is* a function, with a flag on its Var's metadata
09:28Chouser,^#'if-let
09:28clojurebot{:macro true, :ns #<Namespace clojure.core>, :name if-let, :file "clojure/core.clj", :line 1107, :arglists ([bindings then] [bindings then else & oldform]), :doc "bindings => binding-form test\n\n If test is true, evaluates then with binding-form bound to the value of test, if not, yields else"}
09:28chessguy_workso the question of whether to write a macro or a function becomes "when do you have the code that needs to be transformed?"
09:29chessguy_workif you can get it at run-time, you write a function. if you can't, you write a macro
09:33stuartsierramore or less
09:33Chouserwell, most macros return forms that are meant to be eval'ed
09:33Chouserwhile most non-macro functions do not.
09:34chessguy_workhmm. not sure what you mean by that
09:34Chouserif your function returns a list (1 2 3), it would cause an error when run as a macro
09:34chessguy_workyou mean things like (f 1 2 3) as opposed to '(1 2 3)
09:34chessguy_workgotcha
09:42__macWhat about suppressing evaluation of arguments? A macro does not eval it's arguments, when using a regular function a user has to use quote to get the same effect. I know it's functionally equivalent with quotes but it's an important difference for me regardless because you can make stuff like [x & body] in with-open for example.
09:46dobrekone(hi 'there)
09:48jdzmacros are for source code transformation. if the arguments were evaluated before passing them to macro, it would no longer be able to transform anything
09:48rhickeythe purpose of a macro is that you want to write THIS and you want the compiler to see THAT. Thinking about them as functions that don't evaluate their arguments get fuzzy real quick.
09:57stuartsierraFor everyone in NYC, my presentation tonight was canceled - venue problems. LispNYC will still meet for drinks.
09:59dnolenis a future just an agent or it's own thing entirely?
10:02stuartsierrait's a little different
10:02stuartsierrafutures use java.util.concurrent.Future
10:02durka42is there a function i can call, like, macroexpand, to see what the compiler might inline?
10:03stuartsierraThe Clojure compiler or the JVM compiler? Either way, I think the answer is no.
10:03durka42the clojure compiler
10:04durka42like (inline-expand '(+ 2 3)) ==> (. clojure.lang.Numbers (add 2 3))
10:05stuartsierraNo such thing exists, but it wouldn't be hard to write, since inlined functions have :inline metadata.
10:05dnolenstuartsierra: thx
10:06stuartsierradnolen: welcome
10:09durka42i think (defn inline-expand [form] (if-let [inline (clojure.lang.Compiler/isInline (first form) (count (next form)))] (.applyTo inline (next form)) form))
10:10durka42from analyzeSeq in Compiler.java
10:10clojurebot?
10:28durka42this code is evil
10:28durka42:inline-arities (proxy [clojure.lang.IPersistentSet] [] (contains [i] (> i 2)))
10:30stuartsierraWhere did you find that?
10:30durka42i wrote it
10:30stuartsierraah
10:31stuartsierraThat will inline all calls, right?
10:31durka42all calls with more than 2 arguments
10:32stuartsierraBut definline doesn't work with variadic functions.
10:33durka42well
10:33durka42the function/macro/thing at :inline can be variadic
10:33stuartsierraok
10:34durka42~def int-array
10:35stuartsierraI see
10:36stuartsierraSo in theory you could write :inline-arities (proxy [clojure.lang.IPersistentSet] [] (contains [i] true))
10:37durka42which would then be almost equivalent to defmacro
10:37stuartsierrayeah, almost
10:37Chouserit has to be a set? seems a shame.
10:38durka42,(contains (proxy [clojure.lang.IPersistentSet] [] (contains [_] true)) (java.util.Date.))
10:38clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
10:38Chouserseems like it could just be a predicate, since sets are callable.
10:38durka42c.l.Compiler/isInline calls .contains
10:38ChouserI wonder if it has to.
10:39durka42also it casts the {:inline-arities (meta func)} to an IPersistentSet
10:39durka42i mean (:inline-arities (meta func))
10:39durka42Compiler.java:4437 or thereabouts
11:08jmanessdoes anyone have any good resources that describe the actual cost of object creation in Java (# of instructions, memory overhead, etc.)?
11:53dobrekonejmaness: you've the "javap" tool included in the JDK that allows you to disassembling into bytecode
11:54jmanessdobrekone: thanks I'll look at that
11:54dobrekone"new" is a JVM instruction so creating a new object is a single instruction for the JVM
11:55dobrekone 0: new #2; //class java/lang/Object
11:55dobrekone 3: dup
11:55dobrekone 4: invokespecial #1; //Method java/lang/Object."<init>":()V
11:55clojurebot?
11:55dobrekone 7: pop
12:03stuartsierraSome material on Java Object initialization cost: http://lingpipe-blog.com/2009/05/11/javaobject-allocation-costly-inner-loops/
12:05jmanessstuartsierra: thanks
12:44thickeyrhickey: wow!
12:45tWipme too... if anyone is interested Webjure is now on github (http://github.com/tatut/Webjure/tree/master) and works with Clojure 1.0.0
12:47stuartsierrarhickey: cool
12:49gnuvincedamn...
12:50gnuvinceI guess I'll clone at the end of the summer
12:50drewrgnuvince: You don't have to care! http://hg-git.github.com/
12:51jmanessyeah and "This plugin was developed by the folks at GitHub"
12:51StartsWithKdrew: tried it? any problems?
12:52gnuvinceStartsWithK: there's a big ACHTUNG that it's still very in development.
12:52drewrStartsWithK: No. I use git so I haven't really needed it.
12:52drewrWhat I need is git-hg.
12:52StartsWithK:)
12:53drewrI figured stuff like this would eventually come around. Conceptually they're similar enough that they should be able to talk to each other.
12:53drewrIt might be a harder problem than I realize though.
12:55stuartsierraI thought git could already speak hg.
12:56drewrIt would be nice if we could agree on a storage mechanism and create porcelains that cater to everyone's tastes.
13:40rhickeystick your iTunes library in sdb: http://github.com/richhickey/sdb/blob/386815b51f727902d2a286c42a9db22e39175143/src/examples/itunes-to-sdb.clj
13:42durka42cool!
13:44rhickeyhaving sdb sitting around at all times waiting for you to squirrel away things from the repl is really neat
13:46durka42doesn't line 27 have the args backwards?
13:49ciaranwhat is sdb?
13:49RaynesSomething database.
13:50svdmhttp://aws.amazon.com/simpledb/
13:50rhickeydurka42: fixed -thanks
13:50RaynesSimple database.
13:50Raynes:D
14:06jmanessif sdb supports blobs, rhickey can upload his mp3s
14:13stuartsierrasdb has a maximum of 1000 bytes per field value
14:13stuartsierraBut you can use S3 for anything up to 5GB.
14:13jmanessah iteration 2 then
14:23stuartsierra2nd announcement: Clojure talk at LispNYC canceled tonight, but still meeting for drinks.
14:24ataggarteast-coasters get all the fun
14:28jmanessis there anyone in the RDU involved with Clojure?
14:28jmanessRTP I mean
14:29stuartsierraWhat's RTP?
14:29jmanessResearch Triangle Park in NC
14:29stuartsierraah
14:30unlinkhmm... monads sans type classes is an interesting idea
14:36rhickeyanyone get sdb working yet?
14:37stuartsierrahaven't had time to try it yet, but I'll play with it some time soon
14:37stuartsierraI use SDB a little.
15:13cp2afternoon
15:14stuhoodheya
15:41someguy98249234If I have a java file in the current directory, how can I import it from clojure?
15:42cp2if by current directory you mean working directory
15:42cp2(import 'classname)
15:43cp2ideally you should package it
15:43cp2(import 'org.myself.Blah)
15:44stuartsierraWell, the java file has to be compiled, and the .class file has to be on the Java classpath.
15:45someguy98249234ah
15:45cp2yeah, important details i left out
15:45someguy98249234*reads about classpath*
15:46cp2well, if its not in an archive, and it is in the working dir, it will be in the classpath
15:47stuartsierraonly if "." is on the classpath, I think
15:48cp2yeah, its there by default iirc
15:48twismhmmm
15:48cp2not sure if it gets removed with -cp
15:48cp2i would include it just to be safe though
15:49cp2-cp foo:bar:baz:.
15:49twism(clojure.contrib.json.write/json-str [[[nil {:test "test"}]]]) -> "[[[]]]"
15:49twismis that rihgt?
15:50someguy98249234ok Foobar.java: "public class Foobar { public Foobar() { System.out.println("hi"); } }"
15:50someguy98249234I should be able to import with (import 'Foobar)?
15:50stuartsierratwism: no
15:50cp2someguy98249234: if it is in classpath then yes
15:50danlarkintwism: clojure-json, clojure-json! :)
15:50cp2so uh
15:50stuartsierratwism: But you can't have non-string keys.
15:50someguy98249234cp2: How can I check if . is in the classpath
15:51cp2it should be already
15:51twismstuartsierra: ah
15:51twismdanlarkin: i was using clojure-json
15:51cp2lisppaste8: url
15:51lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:52danlarkintwism: was, like past tense? why did you stop
15:52twismbut wanted the library im working on to use cllojure.contrib so as to minimize dependencies
15:53twismsince most people have clojure.contrib
15:53lisppaste8cp2 pasted "cp stuff" at http://paste.lisp.org/display/80095
15:53cp2someguy98249234:
15:53twismdanlarkin: but i guess i have to plug your stuff :P
15:54twismi heart clojure-json
15:54stuartsierratwism: fixed, SVN 803
15:55twismstuartsierra: thanks!
15:55someguy98249234it works! But not from the interpreter...
15:56cp2someguy98249234: hmm, are you doing java -jar clojure.jar
15:56cp2to spawn a repl?
15:57twismdanlarkin: i still have to use clojure-json
15:57someguy98249234it's the ':.'
15:57someguy98249234I wasn't doing that
15:57cp2oh
15:57cp2k
15:57someguy98249234thanks!
15:57cp2btw, on linux the seperator is :
15:57cp2but on windows its ;
15:57twismso i will be giving you a shout out when i release
15:57danlarkintwism: :)
15:57cp2no problem =p
15:57someguy98249234good to know
15:59danlarkintwism: why do you have to use clojure-json even in light of this bug being fixed?
16:00stuartsierra,{:foo 1, :foo 2}
16:00clojurebot{:foo 1, :foo 2}
16:01stuartsierraIs that a bug?
16:01Chousernope
16:01danlarkin,(identical? :foo :foo)
16:01clojurebottrue
16:01durka42,(:foo {:foo 1, :foo 2})
16:01clojurebot1
16:01cp2no bugs, just features
16:01durka42,(:foo {:foo 2, :foo 1})
16:01clojurebot2
16:01Chouser,(assoc {:foo 1} :foo 2)
16:01clojurebot{:foo 2}
16:01stuartsierra,(hash-map :foo 1 :foo 2)
16:01clojurebot{:foo 2}
16:02durka42,(sorted-map :foo 1 :foo 2)
16:02clojurebot{:foo 2}
16:02durka42,(type {:foo 1, :foo 2})
16:02clojurebotclojure.lang.PersistentArrayMap
16:02Chouser,(let [x :foo, y :foo] {x 1, y 2})
16:02clojurebot{:foo 1, :foo 2}
16:02svdm,(keys {:foo 1, :foo 2})
16:02clojurebot(:foo :foo)
16:03Chouserit's been brought up before and ruled not-a-bug
16:04dnoleninteresting, what's the use case for this?
16:04Chouser,(apply array-map [:foo 1 :foo 2])
16:04clojurebot{:foo 1, :foo 2}
16:04stuartsierraChouser: ok
16:04Chouserit's undefined behavior
16:05stuartsierrafair enough
16:05dnolen,(zipmap [:first :first :second] [1 2 3])
16:05clojurebot{:second 3, :first 2}
16:05Chousermost programmatic ways for building a map will not allow duplicate keys.
16:05Chouserthe (apply array-map ...) case there worries me a bit, but anyway.
16:06Chouserone major benefit of array-maps is efficiency of creation, that you can just wrap one around an existing array.
16:06stuartsierraok
16:06Chouserif Clojure had to check the keys for uniqueness, you'd lose that.
16:06ChouserI guess if you're not sure the keys are unique, use a hash-map instead.
16:07dnolen,(merge {:foo 1 :foo 2} {:foo 3 :foo 4})
16:07clojurebot{:foo 4, :foo 2}
16:07dnolenthat's pretty weird
16:07cp2haha what
16:08Chouserhm...
16:09Chouserdnolen: that's freaks me out a little
16:09stuartsierratotally
16:10dnolenyeah, of course I'm not sure, but perhaps this undefined behaviors can be a source of really strange accidental bugs.
16:11svdmconj seems to replace the [:foo 1], so when merge conj's on [:foo 3] and [:foo 4] it just overwrites the entry twice
16:11Chouserwell... as long as the weirdness is only on initial map creation, and only for array-maps, I could be placated.
16:11stuartsierra,(merge {:foo 1 :bar 2} {:bar 3 :foo 4})
16:11clojurebot{:foo 4, :bar 3}
16:12Chouserbut yeah, having it leak through and mess with 'merge' later.
16:12Chouserhm. I guess it was still an error to create such a map in the first place.
16:12stuartsierratrue
16:13twismdanlarkin: beacouse the library i'm working it would be better for users to have keywords as keys
16:14dnolen,(let [m {:foo 1 :foo 2}] (merge m m))
16:14clojurebot{:foo 2, :foo 2}
16:14stuartsierrawoah!
16:15dnolenI guess there's no way to repair a borked map?
16:15Chouserstuartsierra: were you seeing breakage in a real program and track it back to this?
16:15Chouserdnolen: sure, just put it in a hash-map
16:15Chouseror a sorted-map
16:16stuartsierraNo, I didn't start this thread.
16:16Chouseroh
16:16stuartsierraOr did I?
16:16Chouserdnolan: were you seeing breakage in a real program and track it back to this?
16:16Chousersorry. :-)
16:16stuartsierraYes, I did, but I was checking c.c.json.write.
16:16Chouseruh
16:16twismdanlarkin: where im using contrib.json is a private library that isn't going to be touched
16:16dnolenChouser: no, I was just following along :)
16:17Chouseryeah, sorry. I'm all confused.
16:17Chouser{:started-thread 'dnolan :started-thread 'stuartsierra}
16:17Chousuke:P
16:17dnolenChouser: so how to repair a borked map with hash-map? this eludes me at the moment.
16:18bstephenson,(merge {:foo 1} {:foo 2})
16:18clojurebot{:foo 2}
16:18stuartsierra,(into (hash-map) {:foo 1 :foo 2})
16:18clojurebot{:foo 2}
16:18Chouser,(into {} {:foo 1 :foo 2})
16:18clojurebot{:foo 2}
16:18bstephenson,(merge {:foo 3} {:foo 4})
16:18clojurebot{:foo 4}
16:18bstephenson,(merge (merge {:foo 3} {:foo 4}) (merge {:foo 1 :foo 2}))
16:18clojurebot{:foo 2}
16:18bstephensonodd
16:19dnolengreat thx!
16:19Chouserno, the only way thing that's undefined here is the result of building a new array-map with identical keys.
16:20Chouserif the array-map has all unique keys (a.k.a. non-b0rked map), then any operation on it will be fine: conj, merge, assoc, etc.
16:21bstephenson! OIC
16:21Chouserbut building a new array-map either with {...} or (array-map ...) allows you to create a b0rked-map.
16:22Chouserthe only way to prevent it would be for Clojure to build a set of the keys in order to check uniqueness, at which point you've lost the main reason for using an array-mao
16:22Chouserarray-map
16:22Chouserso if you're not sure about uniqueness, better put them in a hash-map in the first place.
16:23stuartsierra,(into {} [[:foo 1] [:foo 2]])
16:23clojurebot{:foo 2}
16:34dnolenso there's not reasonable way to modify the classpath at runtime right? (sorry I know this has come up many times)
16:44dnolenperhaps too many times :) reading about the deprecation of add-classpath...
16:48grzmanyone know of a way to get at the HTTP headers sent with a request in compojure? I'm trying to switch off of the Accept header.
16:48grzmthought I could use headers (if I'm reading http://en.wikibooks.org/wiki/Compojure/Core_Libraries correctly)
16:48grzmbut that symbol doesn't seem to be available
16:57hiredmananyone know how to get java to accept "invalid" ssl certificates?
16:58durka42buy new ones?
16:58hiredmannot mine to buy
16:59StartsWithKin java-utils there is 'with-system-properties', is that even thread-safe? shoudn't that be removed or something
17:03hiredmanin various blog and mailing list posts people say httpunit's WebClient has a setUseInsecureSSL
17:04hiredmanbut it doesn't
17:04Chousermaybe they took it away
17:04Chousertoo insecure
17:05hiredmanthis blog post is from january 09, and the last httpunit release was may 08
17:06hiredmanah
17:06hiredmanhttpunit vs. htmlunit
17:06hiredmanwonderful
17:26bagginsso in my job, i write java. i'm a known fan of lisp there.
17:26bagginsa guy was asking for help with a problem.
17:26bagginswe are all in moods at the moment there
17:26bagginsso i managed to help him see the problem.. and then he basically dismissed us who were lingering
17:27bagginsand i said
17:27baggins"so what? I want CLOSURE dammit!"
17:27stuhoodheh
17:27klin1
17:27bagginsand he said to me: "no you know management would never go with clojure"
17:27baggins"... it's not 'proper' java!"
17:28bagginsi just didn't see the pun coming...
17:28klijust sneak it in anyway
17:28bagginsjust thought i'd share it
17:28Chouserahh... hah
17:28bagginsi guess it was funnier at the time
17:29Chouserwell, I doing C++ now. again.
17:29ChouserWhich would be perfectly fine if it had closures.
17:29Chouserand garbage collection. and immutable containers.
17:30bagginswell i was talking about closure on the narrative of solving his problem... nothing computing... i guess it loses in translation (to irc)
17:30Chouserbaggins: yeah, I got it, but I had to re-read it a few times.
17:30bagginsheh
17:30Chousertoo many meanings for "closure" I guess
17:31Chouseroh, I also need clojure's reference types. I could make do with the remaining deficiencies.
17:39StartsWithKChouser: hide lua in c++ project, modify clojurescript to target lua instead of javascript, they are almost the same language :) no one needs to know :)
17:46Chouser:-)
17:57Chouserwell, rhickey wants to have an ObjectiveC target. If that can be done, I don't see why not C++.
17:57ChouserI believe there are garbage collection libraries for C++, even.
17:57unlinkyes, there are
17:57Chouserwhich raises the question...
17:58Chouserwhy isn't it done alread?
17:58unlinkCompiling clojure to C++?
17:58Chouseryes
17:58unlinkIt's a lot of work?
17:58Chouserhm.
17:59Chousersounds like an excuse.
18:00StartsWithKwhy not one of the javascript vm, or lua?
18:00unlinkIf you're going to target C++, you might as well target LLVM. (Or JVM :)
18:00StartsWithKlua has very simple register machine, excelent c and c++ bindings
18:01ChouserI just need to convince the rest of the team that the JVM would be fast enough.
18:01unlinkYeah on second thought the JVM would probably be unworkable.
18:13unlinkWho do I appeal to to get stuff added to contrib?
18:20mrsolo_anybody knows the release date for programming clojure?
18:36hiredman~book
18:36clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
18:38hiredman"->" works pretty well with htmlunit
18:39hiredman(-> (WebClient.) (.getPage "someurl") (.getAnchorByName "foo") .click)
19:15eeeyo
19:15eeerhickey I'd like to list the heap stuff as a third party lib. is that appropriate?
19:33eyerisWhat is the syntax for applying a type hint to a function?
19:34eyerisI want to do it in the defn, rather than hinting every use of it because I want to return a DataColumn[] where each member is really an object of a class derived from DataColumn
19:35gnuvince_eyeris: (defn read-buffer [#^ByteBuffer buf] ...)
19:35gnuvince_adapt for the type you need
19:35eyerisgnuvince_: doesn't that hint the type of buf?
19:36gnuvince_yes
19:36eyerisI want to hint the type of read-buffer
19:36gnuvince_Is that not what you want?
19:36gnuvince_oh
19:36gnuvince_I don't know that there's a syntax for that
19:36gnuvince_Would it help though?
19:37eyerisI think it would help in my situation.
19:37gnuvince_I mean, if *warn-on-reflection* doesn't warn you...
19:38Carkfunction return values are always boxed
19:38eyerisI have a vector of objects of classes derived from a common base class. I need to create an array from this list with the type DataColumn[] to feed to a constructor in a Java lib that only accepts DataColumn[]
19:39Carkgnuvince : i've seen you've been trying to talk to me, sorry i'm way busy right now =/
19:39eyerisI would like to be able to use (to-array [(DataColumnString. "one") (DataColumnInteger. 1)])
19:39eyerisand type hint the that as [#^DataColumn[]]
19:39gnuvince_Cark: no problem, just wanted to inform you I was able to get a 12% speed increase in my program if that interests you.
19:39Carkgnuvince : though i did read your blog post, and it was very informative
19:39gnuvince_It was the no destructuring binding one.
19:40Carkright
19:40gnuvince_removed it from two tight loops
19:40eyerisI guess I will have to use make-array and then populate it.
19:40gnuvince_(doc into-array)
19:40clojurebot"([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
19:40Carki would have expected a seq on a vector to be really fast
19:41gnuvince_Cark: I guess direct vector access is fater that first/rest recursion
19:41Carkheh abstraction is both a curse and a blessing =P
19:42gnuvince_Indeed
19:43gnuvince_I think my next move will be to try and switch all the little vectors that represent fields to arrays, see if that can help
19:44Carkyou're not doing clojure anymore =/
19:44eyerisgnuvince_: It looks like into-array is what I need, but I am having trouble with the syntax
19:44Carkmhh though the use is pretty simple in this program, so i guess it's no big deal
19:44gnuvince_eyeris: the syntax for arrays of references is sort of weird
19:44gnuvince_eyeris: hang on...
19:44eyerisk
19:45gnuvince_Oh wait
19:45gnuvince_that's for type hints
19:45gnuvince_Can't you do (into-array DataColumn my-vector)?
19:46eyerisYep, apparently I can
19:46Carkdoes it really need to be type anyways ?
19:46Carktyped
19:46eyerisI was trying (into-array #^DataColumn my-vec) :]
19:46eyerisCark yes, read your scrollback buffer for an expl
19:46eyerisThat is, it does for this purpose.
19:46gnuvince_Cark: maybe not regular Clojure code, but it's still fun to play around with.
19:47gnuvince_Cark: I would really like to have my cake and eat it too: write my code in a nice declarative way and still be within 1.5-2x of Java's performance
19:48Carkwell on the other hand i don't see where it would be usefull to be faster than it is now
19:48Carkwhat's the use case ?
19:48Carkmaybe a web page with stats on a single game
19:48Carkhow long to parse it then ? fast enough for a very fast web page =P
19:49gnuvince_Cark: one of the use case I have in mind is being able to take a collection of replays (and some people have tens of *thousands* of them) and generate statistics.
19:50gnuvince_There's also a large part of just wanting to see where I can take that program.
19:50Carki can understand that
19:51Carkstill
19:51Carkif you want it to be fast, there must be a use case ....if it's a one time computation, i'd say it's good enough
19:52Carkor get dirty and go down to c =P
19:52Carkor completely change your access method
19:52Carkuse memory mapped files
19:52Carkand cherry pick what you want to decode
19:54Carkanyyways got to go, gnight all
19:54gnuvince_see ya
20:07slashus2Have you all heard of Axum? I just read about it from Microsoft�'s website.
20:08slashus2I wonder if Novell� will implement it on Mono.
20:09technomancyI think I will stick with the Java� Programming� Language�.
20:09slashus2Okay�
20:14albinothey're way too far behind to implement it anytime soon, if they do it will be like 5 years from now
20:15technomancyalbino: clojure is little over 2 years old. =)
20:16cp2haha
20:16cp2i love this channel
20:16technomancybut one person can move much faster than a team. yay Brooks' law.
20:18powr-tocJust seen that Rich has posted a library hosted on github... Could this be him familiarising himself with git/github for clojure?
20:18technomancypowr-toc: I noticed that... fingers crossed. =)
20:19powr-toctechnomancy: yeah, git rocks! :-)
20:20technomancyI have no idea if github's issue tracker is as good as google's though.
20:20technomancyand a big transition is a tough sell after we just got everyone used to the fact that no, we are not on sourceforge anymore...
20:20technomancywe'll see
20:21ataggartwhen your VCS is a cobbled together mess of C executables and everything has to be done at the command line and there's no authoritative server... no thanks.
20:22albinoa naysayer
20:23ataggartmade as such by the git-vocates
20:24ataggartin any case, I thought googlecode was adding mercurial, not git
20:24technomancythe elisp interface for it is badass
20:25technomancysweet; I'm on the evri page for Clojure: http://www.evri.com/product/clojure-0x151efb
20:27cp2can i have an autograph?
20:30technomancycp2: I used to work for them. =)
20:30cp2ah
20:31cp2so uh, getting a new laptop soon hopefully
20:31cp2anyone have any recommendations (based on personal experience of course)
20:32technomancycp2: I've been very happy with the thinkpads I've owned
20:32technomancynever seen one break
20:32cp2hm
20:33technomancythe downside there is that you don't get an excuse to upgrade your laptop as often since they last forever.
20:33cp2hah
20:33powr-toctechnomancy: did you sell them on the benefits of clojure? :-)
20:33technomancypowr-toc: actually I didn't start Clojure until I left that job. =)
20:33technomancyimmediately after I left; not sure if that counts as irony?
20:34powr-toclol
20:34dnolenso I've started messing around with with Google App Engine, what do you all think of a community (by invite) maintained package/dependency system hosted there?
20:34cp2technomancy: so what model of thinkpad do you use most often
20:35powr-tocwell what with clojure being a lisp, and lisp being classically used in linguistics you'd think it'd play into their problem space
20:35cp2i want to know who decided to put an s in the word lisp
20:35gnuvince_John McCarthy?
20:35cp2think of the people who have to explain their impediment
20:36cp2heh gnuvince_, not the language
20:36gnuvince_oh
20:37technomancycp2: right now I have a X61 tablet. it's very nice, but it's not an LED screen, so you'll get a brighter display with a newer model
20:37cp2i see
20:37technomancycp2: I move around a lot though, so I need a smaller model. before I had a T61 that was solid as a rock and had a much bigger screen.
20:38cp2well, what i would be upgrading from is a dell latitude cpx with only one functional ram slot
20:38cp2so anything is good really =P
20:38cp2yeah technomancy, that doesnt matter so much to me
20:38cp2i just need something that i can move
20:38cp2because my laptop is somewhat unusable now
20:38cp2not that i used it much in the first place
20:40cp2technomancy: that looks like a nice tablet though
20:41technomancycp2: as long as you don't use it outside (or next to bright sunny windows) it's a great screen
20:41ataggartin case anyone hasn't see this: http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html
20:42cp2yeah technomancy thats alright
20:42technomancycp2: I have the 1440x1024 one; it's extremely crisp. (like an iPhone screen in terms of DPI)
20:42cp2oh nice
20:42technomancythey're pretty affordable now too since the newer X300 models have come out
20:42cp2mhm
20:42technomancyunfortunately you can only get the high-res screen in the tablet X61
20:42cp2what os are you running on it?
20:43cp2also, how is battery life and such
20:43technomancylatest ubuntu. it detects everything out of the box, even the tablet input device.
20:44technomancycp2: I got 4 hours when it was new, now it's down to 3 if I turn off wifi and don't use 100% brightness.
20:44cp2hm
20:44technomancyit's a year and a half old now
20:44cp2yeah, was about to say
20:44cp2still looks decent though
20:45cp2whats the story with these 'ideapads'
20:47p_laka netbooks, but from Lenovo? :P
20:47cp2heh
20:48technomancycp2: I think they're the consumer-level ones
20:48cp2sounds about right
20:49cp2technomancy: well, im trying to spend under a thousand, so i might end up with one of those
20:49cp2but im still looking
20:49cp2oh my
20:49cp2=p
20:50unlinkXMLisp is incredible.
20:50p_ljudging from my experience, I'd recommend getting something that has better resolution than 1280x800 if you're buying something around 15,4"
20:50cp2yeah p_l, thats one of my deciding factors
20:51cp2i dont like small screens much
20:51p_lI wasn't bothered so much by it before, but in last few months I find myself screaming at lack of display space
20:51cp2yeah
20:51cp2im so used to having 2 20" widescreen displays
20:51p_lif it's a ~12", then it's alright, but 15,4"? No thanks. Unfortunately I missed my chance to get 1920x1200 15,4"
20:51cp2would like to avoid shock hah
21:21Modius_cp2 I recommend the Samsung netbook
21:30cipherwhat's the easiest way to make a timer... just want something to happen on a regularly scheduled basis.
21:36hiredmanTimer
21:36hiredmanactually
21:37hiredmanjust send-off to an agent
21:38hiredman(send-off (agent nil) (fn this [& _] (send-off *agent* this) do stuff here (Thread/sleep 1000)))
22:08ataggarthiredman: can you please explain how that timer function works? I've read up on 'send-off' but I'm getting thrown by the fn's bindingd and the second call to send-off.
22:09hiredman_ is conventional used as the name for bindings you don't care about
22:10ataggartahh ok
22:10hiredmansend-offs inside an agent action are held until the action completes
22:10ataggartall clear now
22:10hiredmanso the send-off at the top acts like you would imagine a send-off at the bottom would act
22:10ataggartthanks very much
22:10ataggartyep
22:10hiredmansure