#clojure logs

2010-03-20

00:19dcnstrctI want to build a tiny webapp in a jar file using compojure. Is there a way for me to serve a static file such as an image or some javascript from within the jar or should I write it to the fs when the program starts ?
00:22psykoticdcnstrct: http://java.sun.com/j2se/1.5.0/docs/guide/lang/resources.html maybe
00:23dcnstrctthnx
00:25psykotici guess you could also use java.util.zip.JarFile directly
00:25psykoticperformance would probably suffer though.
00:26psykoticwhen it's stored on the file system, you have things like file system caching, etc,
00:26psykoticso that would be my recommendation
00:26psykoticif you want, you can always _deploy_ everything in a jar (a la google appengine) and then have your deployment script unjar the relevant parts to some subdirectory
01:52dcnstrcthttp://paste.lisp.org/display/96665 <-- do I just not understand how ExecutorService/submit works ? I'm trying to make a function that will run another function in the background
01:53dcnstrctif I pass it #(doall (Thread/sleep 10000) (println "foo")) it returns a future but I never see "foo"
01:56danleidcnstrct: where do you run it?
01:56dcnstrctslime repl
01:56dcnstrctis that why ?
01:56danleiyes
01:56rfgdcnstrct: check the *inferior-lisp* buffer.
01:56danleiif you want to print in the repl, bind *out*
01:57dcnstrct!!! there's my foo !!!
01:57dcnstrctthanks
01:58KirinDavedcnstrct: If you're going to experiment with that, you might want to do somethng like the clojure.inspector as meeting point for messages. Emacs isn't very friendly in that regard.
02:00danleisomething like (run-in-background (let [out *out* ] #(binding [*out* out] (print 'hello)))) should do it
02:01danleithere used to be a var slime-redirect-inferior-output but I think it's gone
02:03danleis/var/function/ and it's not gone, but doesn't seem to work with slime/clojure (used to in CL for me )
02:07KirinDaveOne of these days I need to ask technomancy
02:07KirinDaveWhy lein's defproject uses keywords
02:07KirinDaveinstead of just symbols.
02:08KirinDaveOr even inverted keywords.
02:08KirinDavewhy :description instead of description:
02:09danleiwhat's wrong about keywords?
02:10KirinDavedanlei: It just seems strange to use them.
02:10KirinDaveWhy bother?
02:10danleithat's just habits
02:12danleione generally uses keywords there so that one can use them without qualifying/using, it's the usual thing to do for dsls
02:12rfg,:description
02:12clojurebot:description
02:12rfg,description:
02:12clojurebotInvalid token: description:
02:12KirinDave,description
02:12clojurebotjava.lang.Exception: Unable to resolve symbol: description in this context
02:13KirinDaveThe macro isn't really any different for that
02:13danleidifferent for what?
02:13KirinDavefrom the macro phil uses now.
02:14danleiI don't understand what you mean
02:14KirinDaveI'm saying, supporting keywords was a choice.
02:14KirinDaveI wonder why he made that choice.
02:14danleithe obvious choice, yes
02:14KirinDaveIt's not an obvious choice at all.
02:15KirinDaveIt's a macro. It looks like what you want it to look like.
02:15danleisure
02:15KirinDavePLT Scheme and CL have keywords, you don't see them using them in macros.
02:15danleithen jou have not seen many macros
02:15danleiespecially in CL, can't talk for PLT
02:15KirinDavedanlei: I've seen a ton of macros. I've used them for years.
02:15danleiwell, then you know that many, many dsls in CL are done like that
02:16rfgKirinDave: I've used keywords in CL macros.
02:16danleinot all of them, agreed
02:16KirinDaverfg: I know people have. I just find it an odd choice.
02:16danleibut still a lot
02:16KirinDaveEvery time I look and go, "Huh. I wonder why."
02:16danleiI told you
02:16danlei1.
02:16KirinDavedanlei: Except that issue never comes up with defproject. Not a valid concern.
02:16danleibecause you can pick the symbols to mean something else
02:17danlei2. because you won't have to qualify them or use the ns
02:17danleithat are the reasons
02:17KirinDaveThe ns argument is not valid here.
02:17KirinDaveDefproject files don't get ns qualifications and are always in the namespace of phil's choice.
02:17danleiwell, you dont HAVE to, I didn't say that
02:18rfgAnother reason, purely aesthetic and moot, is syntax highlighting.
02:18KirinDaverfg: That's my suspicion.
02:18KirinDaverfg: Free syntax highlighting in emacs.
02:19KirinDaveActually thats probably the best reason I can think of.
02:22KirinDaveThe ns thing is pretty much never an issue, but syntax highlighting is.
02:24rfgKirinDave: Turning it around: why would you use symbols over keywords?
02:24KirinDaverfg: Less symboly garbage.
02:24KirinDaverfg: And I didn't say "description:" seriously, btw.
02:25KirinDaverfg: I mean, why doesn't (loop ...) in CL use symbols? It could. It just doesn't. Because that'd just increase the line noise.
02:26rfgKirinDave: you can use symbols or keywords with (loop).
02:26KirinDaverfg: I know. I rarely see it done.
02:26KirinDaverfg: Because it looks ugly.
02:28danleiKirinDave: you can use the symbols in LOOP, because they are in the CL package
02:29KirinDavedanlei: Yes.
02:29danleiKirinDave: and thats precisely the reason some guys like pjb use keywords there, if they need the symbols for their own stuff
02:30KirinDavedanlei: In any event, like we've said... the namespace issue is not a real issue for defproject forms as used.
02:31rfgKirinDave: You could argue that you have less chance of blowing your foot off with keywords.
02:32danleiKirinDave: ok, then let me put it like this: why use keywords at all? after all, you can get along without them pretty good. symbols as keys, in macros ... I'd say the reasons are: one recognizes them, highlighting (as you said), because they don't have to be qualified, ... tradition, etc
02:32KirinDaverfg: Perhaps I'm in the minority opinion in #clojure that how macros looks is more important than these sorts of implementation details.
02:33danleiwhat about ns?
02:34rfgKirinDave: You are saying symbols are more aesthetically pleasing?
02:34danleiwhat about cl-who
02:34KirinDaverfg: Yes.
02:35rfgKirinDave: But you prefer keywords to symbols with (loop)?
02:35KirinDaverfg: I said that?
02:35danleisome guys do
02:35rfgKirinDave: I'm not sure, that's what I took from one of your previous statements. Was it a typo?
02:36KirinDaverfg: maybe. I'm not a fan of keywords for this sort of use in macros unless they're somehow significant elsewhere in the code during the use of the macro.
02:37danleiKirinDave: why?
02:37rfgKirinDave: Could you elaborate on that?
02:38KirinDaverfg: Well if say you're specifying keys into a map then I'd say it'd be bad to use symbols over keywords, if later you have to pull data from the map with a keyword and you say, "Where did this keyword come from, I used a symbol!"
02:41hiredmankeywords are self evaluating
02:41hiredman,(prn :x)
02:41clojurebot:x
02:41danleiI really don't understand what he's talking about
02:41hiredman,(read-string (prn-str :x))
02:41clojurebot:x
02:41hiredman,(read-string (prn-str 'x))
02:41clojurebotx
02:41danlei,({:a 1} :a)
02:41clojurebot1
02:41danlei,({'a 1} 'a)
02:41clojurebot1
02:41hiredman'x and x are different
02:41danlei,({:a 1} 'a)
02:41clojurebotnil
02:42KirinDaveNone of this matters for defproject forms.
02:42danleilet's take that last sentence
02:42danleihow did you mean that?
02:43danleiI'd say it'd be bad to use symbols over keywords, if later you have to pull data from the map with a keyword
02:43danleiI don't understand that
02:43KirinDaveFor example
02:44KirinDave(defsomething meep ...) => (... (alter *local-table* assoc :meep (fn () ...)) ...)
02:45KirinDaveThat'd be bad.
02:45danleiah, ok
02:45danleiyes, I agree
02:45KirinDaveI think everyone agrees, that'd suck.
02:45danleisure
02:46danleistill
02:46danleiin general, I don't see the the problem in using keywords for dsls like ns
02:46KirinDaveI don't see it as a problem, I just think it looks funny.
02:47KirinDaveIt's never really necessary.
02:47danleiI agree, but I do think its convenient
02:48danleiat the very least, and there we agree I think, because it sticks out visually
02:48danleiI mean: foo: or :foo ...
02:48KirinDaveYes, the syntax highlighting is a perk in some cases.
02:48KirinDaveBut in other cases I think it looks bad. I don't mean to belabor (loop ...)
02:49KirinDavebut when you're making dsl-lites I don't like it.
03:01seangroveSo I can't use (:import) to bring in a clojure script?
03:01seangroveI have a small logger in opengl_test.logger/log
03:02seangroveI'd like to be able to (:import [opengl_test logger]) and have log available in another namespace
03:02danleiseangrove: did you try use?
03:03seangroveLooks like that worked
03:03seangroveI think I tried (:use 'opengl_test.logger)
03:03seangroveBut that didn't work
03:03danleiseangrove: without quoting
03:05seangroveThanks danlei, looks good
03:05danleiseangrove: welcome
03:38LauJensenMorning
03:39rfgGood morning.
03:39rfg...and what a lovely morning it is.
03:39LauJensenIndeed
04:07maxhodakhow do you get a variable passed into a macro to be interpreted?
04:08maxhodakis there a fxn to resolve a symbol and then pass that in?
04:08rfgmaxhodak: by interpreted do you mean evaluated?
04:08maxhodaklike, (mymacro mysym)
04:08maxhodakbut i really want to do (mymacro "mystring")
04:09maxhodakwhere "mystring" is bound to mysym
04:09maxhodaki'm doing string interpolation in the macro and it's messing with me
04:11rfgRemember that macros don't evaluate their arguments and the value of mysym won't be available at macro-expansion time.
04:12maxhodakright
04:13rfgWithout really knowing what you are doing I think you want the macro to return code that does the string operations instead of doing them at expansion time.
04:14rfgCould you be more specific in what you are trying to accomplish?
04:15maxhodakrfg: i'm trying to dynamically import classes
04:16rfgCould you pastebin what you have so far and example use?
04:16maxhodakso basically i'm trying to do: (import ~(symbol (format "my.foo.%s.class.%s" baz quux))
04:16maxhodaksure
04:17maxhodakhttp://gist.github.com/338553
04:21psykoticmaxhodak: look at penumbra, i think it has a macro for automating some importing of gl* methods
04:21hoeckmaxhodak: ,(resolve (symbol (str "Str" "ing")))
04:22hoeck,(resolve (symbol (str "Str" "ing")))
04:22clojurebotjava.lang.String
04:23hoeckI'm using that in some of my macrocode, not shure if it helps in your case though
04:23maxhodakhoeck: i don't think so, because the macro is expanded before the code is evaluated
04:24maxhodak(and before the binding happens)
04:27hoeckI don't think your function run will work as you expect
04:27hoeckthe problem is that import is a macro itself, so at least it has to know the name at compiletime
04:28rfgmaxhodak: Ah I see. import is a macro that plays manipulates its arguments directly so you can't do this: http://clojure.pastebin.com/RT80jHdx
04:28hoeckand you cannot use a macro around it to somehow magically make it think it runs at compiletime
04:30hoeckcould you shed a light on the purpose of your run function?
04:30maxhodakhoeck: run is basically -main
04:31hoeckbecause I think that importing a class makes only sense if you want to load more code which actually uses that class
04:32maxhodakhoeck: the two importedd classes are immediately used; my next issue is putting together the statements that reference them a few lines down
04:33maxhodakbut once i figure out how to get the import to work i figure the rest will be clear
04:34maxhodaki don't believe that theres *no way* to do dynamic imports
04:35hoeckof course there is, after all you can use reflection, but then import is maybe just not what you want or need
04:38psykotichoeck: exactly. i already told him a reference: penumbra.
04:38hoeckto me it sounds like you want to switch implementations of something at runtime, and usually java libraries implement this by providing a common interface and something like a factory method
04:38psykoticlook at penumbra/src/penumbra/opengl/core.clj
04:39psykoticit has reflection methods that enumerate the methods of classes and then there is a gl-import macro that is used to create clojure wrappers for them
04:39psykoticetc
04:39maxhodakpsykotic: ah, ok; was looking for the file with the definitions
04:39hoeckbut it does not switch opengl implementations at runtime?
04:40psykoticno
04:40maxhodakoh, wow; it's a macro that expands to a macro
04:41psykoticnote that gl-import doesn't do the actual importing part
04:42psykoticlook at the containers defvar and the associated helper functions
04:42rfgAny sufficiently advanced macro is indistinguishable from a programmer.
04:43psykoticmaxhodak: and there is always eval :) (i kid!)
04:44maxhodakpsykotic: i'm considering it....
04:44bytecoderhas anyone here built an app which uses google appengine datastore? need a quick help.
06:36LauJensenrfg: good one!
06:37rfgLauJensen: Thanks :) Feel free to quote that, you know, like all the time.
06:37LauJensenHaha!
06:37LauJensenSure - And conviently forgetting to give due credit :)
07:11LauJensenI've taken Yegges advice on swapping caps-lock with control, man thats gonna take some getting used to
07:11Mecis there a print that returns what it was passed so you can do inline debugging?
07:11Chousukewrite a debug macro instead
07:12Mecthought so, just wanted to make sure there wasnt already one
07:12noidiLauJensen, it'll take a while but it's worth it
07:12LauJensenyea I'm getting the sense of that already
07:12Chousukeor (comp first (juxt identity print)) :P
07:12noidinot only in emacs but in almost every app
07:12Chousukefor the pointless programmers
07:13Mecwill that call the value twice?
07:13LauJensennoidi: oh there are other apps out now?
07:13Chousukenah, it's evaluated only once
07:13noidihehe
07:14Chousukethough there's a better way. that was just my idea for a point-free approach
07:14LauJensenChousuke: Its very clever :)
07:14Mecindeed, makes my head hurt unraveling it
07:14noidiLauJensen, also switching to a US keyboard layout helps _a lot_, assuming that the danish keyboard is as uncomfortable for programming as the finnish one
07:15ChousukeI still program using a finnish layout. :P
07:15noidinow _that_ takes some time to get used to, but imho it's even more worth the trouble than remapping control
07:15LauJensennoidi: The US has big advantages
07:15ChousukeI haven't been able to learn the english layout
07:15LauJensen(.replace "able" "willing")
07:16Chousukewell, yes. I tried once but failed
07:16Chousukeall programming languages are optimised for the US layout :(
07:16Chousukeeditors too
07:17noidiyup
07:17noidiafter the week or two of painful relearning, suddenly all the default hotkeys made sense :)
07:18Chousukevim is a good example, having \ as the leader key by default. that takes three keys to type on my macbook
07:18noidiwhen they no longer were behind some weird AltGr+Shift combos
07:25psykoticthe keyboard's country of origin if you are one of those grandmother programmers who look at the keyboard as they type :)
07:25psykotic*only matters if you are one ...
07:30Chousukeisn't the standard key count for US keyboards 104 or something?
07:31ChousukeFinnish ones have 105 and Japanese ones 109 I think (the space bar is very short)
07:31Mec#((println %) %)
07:31Mecthat seems too simple
07:32Chousukewon't work
07:32noidipsykotic, on the contrary, you can only switch between layouts painleslly if you haven't memorized any of them
07:32Chousukeit'll get an NPE
07:32Mecand it does
07:32Chousukeyou'll want #(do (println %) %)
07:32Chousukebut I still suggest making a debug macro instead :P
07:32Mecah thought there was implicit
07:33Chousukeyou can think of the # as a "make the following expression a function" :P
07:34Meci know, i thought functions had an implicit do
07:34psykoticchousuke: # is a general dispatch character a la common lisp. it has dispatchers for functions with anonymous arguments, set construction and regular expressions, etc.
07:34psykoticyou can even hack the dispatch table from within clojure itself, if you're feeling naughty.
07:37StartsWithKwhen binding *in* do i need to wrap my reader with LineNumberingPushbackReader?
07:39SynrGMec: i think the disconnect you're having is that when you say ((somefunction)) the thing after the first parenthesis isn't a function. it's an expression.
07:39SynrGwell, a list
07:39tomswI have a macro that provides syntactic sugar to using the Jacob library (COM / ActiveX interop). For example (<< obj Property1 Property2 (Method arg1 arg2)) is exquivalent to obj.Property1.Property2.Method(arg1, arg2) in C#
07:39LauJensenHow far are we in terms of removing transients with cells?
07:40LauJensentomsW: like .. from core ?
07:40tomswyes, more or less
07:41tomswI don't know a sensible way to deal with lookup up property or method names from an expression
07:41tomsweg (<< obj Property1 x) would look for a property named "x" whereas I might want it to look for the property whose name is x's value
07:42Raynes,(println "test")
07:42clojurebottest
07:42Raynes,(println "test\n")
07:42clojurebottest
07:42RaynesIndeed.
07:43Chousuketomsw: you could use ~
07:43Chousuketomsw: outside of `, ~x expands to (unquote x)
07:43Chousuketomsw: you could perhaps use that in your macro
07:44psykotic,(print "foo\n\nbar")
07:45clojurebotfoo bar
07:46tomswChousuke: that's very neat, I will experiment (I wonder if ` and , are as flexible in common lisp)
07:46Raynes,(do (print "hai") (print "thar") 3)
07:46clojurebot3
07:46clojurebothaithar
07:48psykotictomsw: yes, `foo and ,bar are just reader-macro-expanded to (backquote foo) and (unquote bar)
07:48psykotic(in common lisp)
07:48ChousukeClojure actually expands ` entirely at read-time
07:49ChousukeIt turns out that implementing it as a macro is not trivial
07:49ChousukeI tried. :P
07:50Chousukethough I think most of the non-triviality comes from autogensyms and making them work properly.
07:50tomswI don't know what autogensyms is
07:51tomsw:)
07:51Chousuke`foo#
07:51Chousuke,`foo#
07:51clojurebotfoo__7125__auto__
07:51Chousukethat
07:51RaynesUnique names.
07:51tomswthat's a very nice feature
07:52Chousuke,`(foo# foo# `foo# `~foo#)
07:52clojurebot(foo__7130__auto__ foo__7130__auto__ (quote sandbox/foo__7129__auto__) foo__7130__auto__)
07:52tomswthere was a neat way of doing it in CL, in "Let over Lambda", but it's nice how it's built in to Clojure
07:52Mec,(String. (into-array Byte/TYPE (map byte (range 256))
07:52clojurebotEOF while reading
07:52Mecwhat am i missing there?
07:52Chousukemaking them nest like that isn't exactly trivial
07:53Chousuketwo closing parens
07:53Mecbah
07:53Mec,(String. (into-array Byte/TYPE (map byte (range 256))))
07:53clojurebot"
07:53Chousukehuh
07:53Rayneshuh
07:53ChousukeI suppose Clojurebot doesn't like control characters :P
07:53Meci sware i was doing this fine last night
07:54Mecand now im getting a class cast exception
08:04Meci must be losing my mind
08:05psykotici both lose and hate the fact that you can C-o away from the minibuffer in emac
08:05psykotics
08:05rfgLauJensen: Invest in a set of foot pedals for Control/Alt etc.
08:05psykoticrfg: someone needs to make organ.el
08:05LauJensenhehe
08:06psykoticthat is actually a fun hack. use midi to drive emacs.
08:07Mecwow I restarted emacs and now its working again
08:08Mechow does that work?
08:08rfgemacs has some odd behaviour when you C-x C-b and select a buffer: it opens in a different frame than you did the shortcut. Why?!
08:09rfgAnd the list of buffers is in a different frame too.
08:09psykoticrfg: C-h k C-x C-b and all will be revealed.
08:10psykoticoh, you said different FRAME
08:10psykoticare you using aquamacs?
08:10rfgGenau. No I'm using Carbon Emacs
08:11psykotici know that aquamacs has stupid defaults for things like mapping buffers to frames
08:11psykotici haven't used carbon emacs but maybe it does something like that too?
08:11rfgPossibly, yeah.
08:11psykoticgoogle the emacswiki to find out
08:13rfgpsykotic: I typically have the slime-repl in one frame and code files in t'other.
08:13psykoticin that case, i suspect i know the problem.
08:14psykoticit probably switches to the frame in which the buffer was last open.
08:14rfgOkay, that would make a small bit of sense.
08:15rfgBut it's taken the concept of consistency, tied leather weights to its feet and thrown it in the river.
08:16psykoticthat is what you get for messing with frames
08:16psykoticwhy would you want to throw out emacs's wonderful window management?
08:17psykoticthe one case i can see it being justified is for something like speedbar that is omnipresent.
08:17rfgI'm going to give your "One Frame Paradigm" a shot.
08:18rfgpsykotic: Do you tend to C-x b or C-x C-b?
08:18psykoticaquamacs has an insane "frame per buffer" paradigm
08:18psykoticC-x b
08:18psykotici use ido-mode with that, which rebinds
08:18psykotictry M-x ido-mode and then C-x b
08:19rfgpsykotic: not a fan of aquamacs.
08:19psykoticyeah, i disagree with almost all of its attempts at making emacs not emacs and more macish
08:20rfgYeah, and I don't like its icon.
08:20psykoticdid you see the new vector art icon?
08:20rfgOnly cool icons are allowed in my dock.
08:20psykotici quite like it
08:21rfgLooks like I have an ancient version of it.
08:22rfgHmm, 1.9 or 2.0 preview?
08:23psykotici use the preview. it has a few bugs but i can live with it.
08:23psykoticactually, the bugs seemed to go okay with the latest update push.
08:23psykoticerr, go away
08:23rfgheh
08:24RaynesLicenser: ping
08:24psykoticbtw, one of my favorite things about aquamacs is that it lets you rebind the alt keys to act like alt rather than the usual "character map shift" function it usually serves in os x
08:24psykoticthat's a feature of the 2.0 preview
08:25psykoticalso, i selectively told aquamacs to rebind my right cmd as ctrl, while leaving the left one alone; i then use caps lock rebound as ctrl, so i still have a ctrl on each side of the keyb
08:25psykoticand i can still use the left cmd for cmd-space (quicksilver), etc
08:26rfgLeft command is meta?
08:26rfgOr alt?
08:26psykoticleft command is just command
08:26psykoticboth left alt and right alt are meta
08:26psykoticby leaving left command alone, it means i can still do my os x-ish things
08:27psykoticbtw i also disabled a bunch of the default os x key bindings
08:27clojurebotthe genuine sieve of eratosthenes is http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
08:27psykoticlike i believe alt + arrow keys usually changes spaces, which i never use
08:28psykoticthat makes it work smoother with emacs
08:28rfgHmm, Command as Meta is hardwired into me form Carbon Emacs.
08:28psykoticyeha
08:29psykoticthat's why i don't use carbon
08:29rfgAlt isn't that well placed on my MBP keyboard.
08:29psykotici have a mbp too
08:29psykoticthat's why i rebound right cmd as ctrl--there is no right ctrl key on mbp
08:30rfgYay, we are MBP buddies.
08:31rfgApple were kind enough to replace my mobo the other month for free.
08:31psykotici ran out of warranty right after my left fan decided to start dying
08:39rfgMine was out of warranty, but it was a known fault, so I didn't have to pay them £676.
09:00etateis there a point to using SQL based databases et al when you can just serialize / deserialize data structures yourself?
09:01etatei'm kind of confused
09:02Chousukethat's like asking "what's the point of using hash-maps when you have lists" :/
09:02etateto be more precise, if you have STM, the ability to do transaction logging, loading data from disk into memory, serialization / deserialization
09:03etateis there a good argument to use mySQL et al with these tools?
09:03ChousukeDatabases are an order of magnitude more efficient at storing and querying data than straightforward serialisation
09:03etatebut most data ends up living in memory anyway right?
09:03Chousukeyes
09:03Chousukebut not all of it at the same time
09:04etateyou'd have to have a pretty huge database to have to worry about that, i would imagine
09:04Chousukethere are databases with petabytes of data in them
09:04psykoticetate: when the data is what matters and the application is incidental, you use databases.
09:04esjindices
09:04Chousukea database in the gigabyte scale is not even uncommon
09:05etatepsykotic: could you give me an example of this?
09:05Chousukeetate: google
09:05etateso supposing you had this database which was a gigabyte, so thats a gig of memory, big deal
09:05psykoticaccounting systems of all sorts
09:05psykotica gigabyte is nothing
09:05Chousukeetate: what about if you have a terabyte of data?
09:06psykoticyou are also not considering the durability aspect
09:06Chousukeetate: which is also not too uncommon
09:06etatethen you have some kind of partitioning scheme i would imagine
09:06psykoticserialization plus in-memory ACI does not give you durability
09:06Chousukepsykotic: it can, but it would be horribly inefficient
09:07psykoticChousuke: well, if you reimplement a lot of database functionality.
09:07etatepsykotic: why would it be inefficient to access a hash map using STM?
09:07Chousukepsykotic: indeed.
09:07Chousukeetate: writing it to disk to achieve durability is
09:07Chousukeetate: you don't want your bank to do transactions only in memory
09:07etateChousuke: using a transaction log?
09:08etatei mean i just wrote this db naively and it doesn't write to disk until the database is closed
09:08Chousukeyes, so it's not durable.
09:08etateits durable because it has a transaction log...
09:08psykotica transaction log can work but you need to be careful, and you still need checkpointing unless you want to parse the transaction log from the beginning of time
09:08etateyeah i implemented snapshotting
09:09Chousukeetate: you're implementing a database :P
09:09etateChousuke: well if this is a database then i fail to see whats difficult about writing one lol
09:09Chousukeetate: it's difficult to do efficiently
09:09etateChousuke: cache oblivious data structures maybe?
09:09Chousukewhich is why you should not do it yourself. there are many efficient databases available :P
09:10Chousukeit's basically a solved problem
09:10etatesure but if its all in clojure its easier to do and use
09:10psykoticerr
09:10Chousukesure, but it won't be as efficient as using a real database
09:10psykoticthe time to wrap an existing high performance, highly tested, highly supported database is harder than to WRITE YOUR OWN?
09:10Chousukeit might be efficient enough for your needs though.
09:11psykotici agree that a simple database isn't very difficult. it's a week-long project for an undergraduate.
09:11etateChousuke: it is efficient enough for my needs, I just think that it would need a huge amount of data to notice any efficiency impact
09:11ChousukeI think you would notice it with data in the hundreds of megabytes
09:12Chousukewhich is nothing to real database systems :P
09:12etatetbh the data reaches less than 1mb
09:12etatewell when i get to the stage where i need 100mb i can always transfer data to some other system right? :)
09:13etatepsykotic: i think its easier than a week for an undergrad
09:13psykotici'm talking about a disk-based b-tree, query planner, buffer manager, etc
09:14psykotica rdbms
09:14etateoh i see
09:14psykoticit's like writing a simple operating system. not terribly difficult.
09:15psykoticyet that doesn't mean that writing a real operating system isn't difficult or time consuming.
09:15etateso you could use a fast prolog compiler and do the same kind of thing
09:16psykoticprolog systems do generally support fast in-memory indexes, yes
09:16psykoticin fact, if you've looked at couchdb, their approach of 'cached queries' as opposed to traditional indices is very close to the prolog style of indexing from the 80s
09:17etateinteresting
09:18etateso using the persistent data structures available its possible to write a db in clojure that scales to 100mb ?
09:18psykoticanyway, my greater point with the OS analogy is that when a database is fundamental infrastructure, you don't want to use a half-assed solution
09:18psykoticetate: almost anything will scale to 100 mb :)
09:18etatehmm, what i really don't like about SQL dbs is the fact that your data is set as in C, so VARCHAR(55) i mean wtf
09:19psykoticyou don't have to use a relational db
09:19etatewhat if you don't want arbitrary limits on your data
09:19psykoticthere are things like berkeley db
09:19psykoticwhich at their simplest are just persistent key-value stores
09:19etateyeah ive used BDB in a commercial project
09:20etateits pretty simplistic
09:20psykoticyes
09:20psykoticwhat you're doing sounds simplistic
09:20psykoticgood fit
09:20etate:D
09:21psykoticactually, berkeley db has grown some pretty non-simplistic features over the last 10 years
09:21psykoticincluding replication
09:21psykoticbut it's nice that you can embed it as a simple library and create and populate and query a database with ten lines of c code
09:21psykotici guess there might be something like it in the java world, or a JNI wrapper for it
09:21etateyeah, hmm i see there is a java binding
09:22etatesorry, a java edition
09:22esjI've been using mongodb through congomongo and its really working for me
09:23etateesj: i don't really understand document oriented databases, thats the only problem :p
09:23esjits a misnomer
09:24esjIn the simplest case just think of it as an indexed object store
09:24esjs/object/struct
09:24etateesj: hmm that sounds nice
09:25etateesj: when i checked out the congomongo bindings, the documentation looked a bit sparse
09:25esjextremely - its very fast, it has not predefined schema so its quick to get going
09:25esjthere isn't much to it all
09:25etateesj: how do the queries work?
09:26esj1 sec, I'm putting up a gist for you
09:26etatenice thanks :D
09:27esjhttp://gist.github.com/338668
09:27esjthat's code I'm actually using
09:27esjto wrap up some stuff
09:28esjas you can see its really very simple
09:28etateesj: checking it now
09:28esjmost of the mongo functions end in ! (which makes a great deal of sense)
09:29etateesj: wow nice code thank you for this insight!
09:30esjno sweat
09:30etatehmm i didn't realise it was this easy... i'll start using congomongo methinks
09:31esjdb-insert-series! is illustrative
09:31esjyou just bang the db with maps, its serialises then to JSON (actually its BSON, which is a binary JSON, I believe) and stores em
09:32etateand fetching data turns json into a map?
09:32etatesounds like it would be easy to fetch just JSON from the db
09:33esjthat's right, your stuff is automagically serialised and de-serialised
09:33esj(except for sets, which is causing me grief right now)
09:35etateesj: can you fetch the data as just JSON too? or is the serialization step implicit?
09:36esji really dunno, I'm sure if you reach into somniums code you could find out though ;)
09:36etateesj: yeah i'm installing it now :)
09:36esjenjoy.
11:56psykoticwhat's the rationale for only having vectors implement the MapEntry interface, not lists?
11:57psykoticit means that idioms like (into {...} (partition 2 keys-and-vals)) don't work unless you wrap the partition in a map vec call
12:00chouserI don't know the rationale, but you can do (apply assoc {...} keys-and-vals)
12:01psykoticthat's nicer at least, thanks
12:13Crowb4rmorning
12:20raekI need some sort of database in one of my projects. what libraries do you recommend looking into?
12:20raekI'm thinking about something more structured that refs of sets of maps and less rigid than SQL
12:20vegaisqlite?
12:20vegaitokyodb
12:20raekI'm considering a schema-less db
12:21The-Kennymongodb is very cool, couchdb too
12:21raekis congomongo clojure bindings for mongodb?
12:22The-Kennyraek: yes
12:23raekcongomongo looks very interesting...
12:25RaynesLicenser: ping.
12:29LauJensenAny fast way to check if 2 transients will be the same persistent structure, w/o persisting them?
14:08LauJensenno takers on the transient question?
14:08LauJensenOr is it about that time now, where I dont use transients but use cells instead?
14:11dnolenLauJensen: I thought cells were still considered speculative work.
14:11LauJensenperhaps, but looks more interesting than transients :)
14:17arohnerwhy can't maven projects tell you what the valid 'mvn foo' commands are for that project?
14:17arohnerlike rake --tasks
14:20LauJensenarohner: I'm afraid Clojure-land is not where you're most likely to get Maven help
14:21arohnerLauJensen: I was just grumbling. I'm trying to interop with a maven project
14:21RaynesLicenser: In case you get this: I sent an email a few hours ago with a question. I sent it on my phone, so I'm not sure if it made it or not. Just letting ya know. <3
14:22arohnerI'm curious, but not enough to go find the real answer
14:22arohner:-)
14:22LauJensenarohner: Isnt there a Maven community on IRC somewhere?
14:22Chousukehmh
16:05seangroveHow can I get a list of methods for a java class?
16:05seangroveI can't seem to get .getMethods() to work :P
16:06seangroveAh, I think I got it
16:06seangroveJust can't use it with a proxy
16:12notallamahey guys
16:13LauJensenHey
16:17martenanyone here using swank-clojure embedded?
16:17marteni can connect to it fine
16:18martenbut as soon as i disconnect, the server stops?
16:18martenany way to keep the swank server up, or restart it after it stops when the client disconnects?
16:20dnolenmarten: do you mean disconnect from emacs?
16:20The-Kennymarten: What means "embedded"?
16:21martenbasically, during initialization of my app, i do a (swank/start-repl)
16:22The-Kennyah, and the swank-server stops after the disconnect from emacs?
16:22martenyes, exactly
16:22The-KennyYou have to supply some argument to start-repl or start-server or so. like :multiple-connect true
16:22martenwhich is frustrating, because that means i have to restart my app :)
16:54woobyanyone know off hand the name of that jogl wrapper for clj?
16:55LauJensenpenumbra?
16:55LauJensen@wooby
17:00woobyLauJensen, thanks! that's it
17:01LauJensennp
17:01LauJensenxb
17:01LauJensenoops
17:07martenThe-Kenny: hmm, apparently after disconnecting, the socket hangs in CLOSE_WAIT state...
17:07martenand the :dont-close true option doesn't help this
17:08The-Kennymarten: huh, that's strange
17:09dcnstrct(.replaceAll "foo" "o") <--- No matching method found: replaceAll for class java.lang.String
17:09dcnstrctI don't understand why this doesn't work
17:09dcnstrcthttp://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)
17:09LauJensendcnstrct: What are you looking to replace? you left out an arg
17:09LauJensenYou said replace in "str1" "o" with ?
17:10LauJensen,(.replaceAll "aaa" "a" "b")
17:10clojurebot"bbb"
17:10dcnstrctdoh! so obvious..
17:10dcnstrctI guess that "no matching method found" made me think it wasn't finding the method.. when really it was just a case of wrong number of args
17:10dcnstrctthnx
17:10LauJensennp
17:11LauJensenAnd for what its worth, I think the error should indicate that the name exists but it has a different signature
17:29martenaha, swank.swank/start-repl (which the README recommends) doesn't pass on the options to start-server
18:07boojum,(contains? (transient [1 2 3]) 2)
18:07clojurebotfalse
18:11wooby,(contains? (transient {1 :a 2 :b}) 2)
18:11clojurebotfalse
18:11wooby,(contains? (persistent! (transient {1 :a 2 :b})) 2)
18:11clojurebottrue
18:12woobyinteresting :)
18:12LauJensenYea, I was asking a question on a similar note earlier
18:12LauJensenrhickey: Is there anyway to test if 2 transients are equal in their current content ?
18:14technomancyLauJensen: I don't think that's what transients are for
18:15LauJensentechnomancy: They're for fast local mutation right? So sometimes you need a little status on that mutation :)
18:15boojum,(clojure-version)
18:15clojurebot"1.1.0-master-SNAPSHOT"
20:07notallamasay i have a protocol A, and a datatype B. how can i tell if an instance of B extends A?
20:07notallamai can't seem to figure out how to get 'extends?' or 'isa?' to return true for that.
20:07notallamaB is made with deftype
20:09notallamanevermind, found the 'satisfies?' function.
20:18stacktraceris there a way to declare a method in the :methods part of a :gen-class that returns an instance of the class being gen-classed?
20:19stacktracer(static factory method, for Java interop reasons)
20:19hiredmangen-interface + gen-class
20:20stacktracerhiredman: ah, thanks
20:23RaynesWhat is the best way to do default-argument-style stuff?
20:29RaynesI should point out that I need default keyword arguments. I suppose the best way would be to use map destructuring with :or, but I guess maps shouldn't be used for optional arguments. :(
20:33RaynesShould I use defnk?
20:33RaynesI guess I should.
20:57RaynesLicenser: You around?
21:00vvshhi everybody, i thinking to try out enlive for clojure, so i follow the tutorial, but cant' get REPL working , can someone help me ? ( i got this error message http://pastebin.com/pv89fwbJ)
21:00RaynesMethinks Licenser didn't test his sandbox's timeout mech with anything but Thread/sleep. It suffers from the same problem that chouser and friends helped me with yesterday. I think I'll take the liberty to hack it.
21:01hiredmanvvsh: means you are missing clojure from the classpath
21:02vvshhiredman: sorry for the noob question(i never use java before), how can i add clojure to my classpath?
21:02vvshi thought lein will take care of that
21:03hiredmando you have clojure as a dependency in your project.clj?
21:05vvshno, i can't see clojure on the dependancies list
21:05vvshi suppose i need to add it in the project.clj, but what are available versions?
21:06hiredmanI would just find some other project.clj (on github? google?) and copy and paste
21:09vvshsounds good, i just fond out even without clojure on dependency list, i got clojure-1.1.0-master-20091231.150150-10.jar and clojure-contrib-1.0-20091212.214557-33.jar under my lib directory, are these two clojure jars ?
21:16vvshi tried to put clojure in project.clj dependency list, but still doesn't work
22:22dcnstrctlein uberjar
22:22dcnstrcterrr
22:30polypus~ping
22:30clojurebotPONG!
23:02alexykI need to parallelize processing of a list of length N over P processors. I need the starting point of each chunk. What's the best way to get such a list of the starting indices?
23:12Mecis there a dissoc-in?
23:51bmasonhow do I determine what version of emacs is installed?
23:51mikem_M-x version?
23:51bmasonah thanks!