#clojure logs

2011-05-29

02:17sid3khi all. I'm having trouble to run this example code: https://github.com/zkim/xmpp-clj
02:18amalloysid3k: the instructions in that readme look really old
02:18sid3kI compiled the module but still can't managed to execute the client
02:19sid3kamalloy: is there any better xmpp library for clojure, with documentation?
02:20sid3kwhat should I put on the main function to run the client?
02:20amalloysid3k: what i mean is, they're asking you to use clojure 1.1 (a year out of date), and a version of lein-swank that's got to be older than god
02:20sid3kamalloy: yeah but still I wonder, how can I run the example app?
02:21sid3kis it necessary to call my-bot?
02:21sid3kmy-boot doesn't seem like callable
02:21amalloy*shrug* i've never used the xmpp project. i doubt it's callable
02:22sid3kyeah, me too
02:22amalloydid you give it a username/password pair that you can successfully log in with yourself?
02:23sid3kamalloy: of course
02:23sid3kthen I wrote this code: (defn -main [& args]
02:23sid3k (println "Hello World")
02:23sid3k (xmpp/start-bot connect-info reload-helper))
02:24sid3kwhen I run this module, it puts hello world and exits
02:25sid3kthis channel was so breezy 6 months ago, what happened to this community?
02:25amalloywell you showed up at 2:30am east-coast time :P
02:26sid3kgood point
02:27sid3kand it's saturday, I wouldn't want to be a part of community studying programming in saturday night
02:28amalloyanyway, i don't know how the xmpp lib works. maybe it does something crazy like not register any non-daemon threads, in which case exiting (main) would make the jvm terminate
02:29amalloybut if the clojure wrapper is a year old and isn't working, i'd probably look into how the java library itself works
02:29sid3khmm
02:29sid3karright
02:31amalloysid3k: if you're not married to xmpp, you can fork sexpbot here and write an irc bot instead
02:32amalloysexpbot: what do you think of irclj?
02:32sexpbotIt's AWWWW RIGHT!
02:32seancorfieldsid3k: in addition to being late at night, it's memorial day weekend in the US and most people are away on vacation for three days :)
02:32seancorfieldexcept folks like me and amalloy :)
02:32amalloyseancorfield: by the way, i've confirmed that i'm moving down to LA to work with lancepantz and ninjudd
02:33seancorfieldi guess i'd ask what you plan to do with xmpp?
02:33seancorfieldamalloy: sorry to hear you'll have to put up with LA...
02:33seancorfieldbut working with those guys should be fun
02:33seancorfieldand you can always drive back up for weekends (which is what my wife used to do when she lived in marina del rey)
02:34sid3kseancorfield: I'm planning to make a jabber client for my chess app, multiplayerchess.com
02:34sid3ks/jabber/gmail
02:34sexpbot<sid3k> seancorfield: I'm planning to make a gmail client for my chess app, multiplayerchess.com
02:34seancorfielda gtalk client, you mean?
02:34sid3kyeah, I didn't want to replace it again :)
02:35sid3khmm, jabber might be the true one
02:35amalloysid3k: gtalk is just jabber
02:35seancorfieldyou might want to just take the basic java library and write your own wrapper... i haven't looked at xmpp-clj but it sounds like it isn't maintained any more and you might be able to write a better wrapper for your needs anyway...
02:36sid3kI also want to restrucutre its backend soon. Now it sounds better to design the whole system based on xmpp
02:37sid3kseancorfield: yeah, make sense
02:41seancorfieldsid3k: do you get lots of errors like this at startup: Error! A startup class specified in smack-config.xml could not be loaded: org.jivesoftware.smackx.ServiceDiscoveryManager
02:41sid3kseancorfield: yep
02:44seancorfieldi just tried it from the repl and despite the errors, it worked fine
02:44seancorfieldmy bot responded: Hi mailto:seancorfield@gmail.com, you sent me 'test'
02:46sid3kI haven't tried it on repl yet. How would you code it if you wanted it to run as an app?
02:46sid3kwas my -main func wrong?
02:46seancorfielddunno
02:47seancorfieldi'm just saying it worked fine from the repl...
02:47sid3karright
02:47sid3kthx
02:48seancorfieldi guess you'd need some sort of loop that mostly just slept?
02:48sid3khmm
02:48seancorfieldand then in handle-message issue a stop-bot call if you get a shutdown message?
02:48amalloyseancorfield: that implies that the xmpp library does the insane thing i mentioned earlier, doesn't it?
02:48seancorfieldit does seem a bit silly that starting a bot doesn't create a long lived process
02:49seancorfieldbut i haven't looked at the code or the xmpp library
02:50amalloyseancorfield: i looked at the clj wrapper and it doesn't do anything obviously persistent, just asks the java lib to do stuff
02:51seancorfieldyeah, i concur having just read the source
02:54seancorfieldthe examples i can find all assume a long running java app
02:54seancorfieldso, i guess the answer is main must loop / sleep until something tells the bot to shutdown
02:55seancorfieldand on that merry note, it's midnight, my wine glass is empty and i'm off to bed!
02:55sid3kit works but still I couldn't understand how it works on the repl
02:55seancorfieldwell the repl is a long running process so it (the bot) stays running while the repl runs
02:55seancorfieldanyways... 'nite
02:56amalloysid3k: because the repl is still running after you call main, the process doesn't terminate
02:57sid3kthen the documentation lacks the example of app usage
02:57sid3knumber one reason for abandoning a library
02:58amalloyif that's the best reason you can find to abandon a library, you should mail the author some flowers
03:00sid3kamalloy: hmm
03:00sid3kbtw I've found an example, in the src directory
03:03seancorfield_And yes I have gone to bed but I figured I'd log back in from my phone and see how the XMPP chat is going :)
03:04amalloyhah
03:04amalloyseancorfield_: you need to see someone about your clojure addiction
03:04sid3k:)
03:04seancorfield_Btw we did not go to production with clojure this week :(
03:04seancorfield_We found sone bugs in the app that need fixing first
03:05amalloyseancorfield_: just call it a public, opt-out alpha
03:06seancorfield_But that gave me time to replace our old logging module with log4j, clojure.tools.logging and a custom DB appender written in clojure :)
03:07seancorfield_If business delay the production launch beyond this week, I'll add in congomongo and start logging to mongodb in the cloud! :) :)
03:09seancorfield_So when do you move to LA? Where will you be based?
03:10amalloyseancorfield_: next week
03:10amalloyhave a one-month rental arranged while i look for something permanent
03:11seancorfield_Yeah? What part of LA?
03:11amalloyhoping to find a nice place in santa monica, but i'll be looking around
03:11amalloysince the office is in west hollywood
03:12seancorfield_My wife lived on a houseboat in marina del rey. That's near Santa Monica I think?
03:13seancorfield_Does the company have any telecommuting employees? What do they actually do?
03:13amalloywww.geni.com
03:13amalloyyeah, marina del rey is nearby
03:14seancorfield_genealogy ... an interesting area ... all clojure?
03:15amalloyseancorfield_: that's what they're hiring me for. i understand they're porting a lot of ruby to clojure as well as writing some stuff from scratch
03:16seancorfield_Cool. Sounds like a fun project. Next time my place has a company meeting maybe I'll swing by and see more of what you guys are up to!
03:17amalloyneat
03:17seancorfield_World Singles is completely distributed but most of the core live in or just south of LA.
03:18sid3klein is the coolest thing about clojure, except clojure itself
03:19amalloysid3k: there's also cake
03:19seancorfield_What IDE do you use sid3k?
03:19sid3kemacs
03:20sid3kI didn't hear cake before, going to check that out
03:20amalloysid3k: it's similar to lein
03:20sid3kis it as common as lein? it seems many projects support lein
03:20seancorfield_Hardcore :) I do so much Java-related stuff I live and die in Eclipse with CCW.
03:21seancorfield_Cake has some neat features but I think lein is way more prevalent.
03:22amalloysid3k: lein is more popular, largely because it's more established. they're mostly interchangeable, really; they use the same project.clj format but have different plugins
03:23sid3kamalloy: which one do you prefer?
03:23amalloymeh
03:23sid3kboth?
03:24amalloyi mostly use lein at the moment, but i have many months of happy cake usage
03:24amalloyand i'm going to work for the cake guys soon
03:24sid3ksounds great
03:25amalloymy understanding is that cake is easier to write plugins for, and has a persistent jvm to reduce startup times for each cake command
03:25seancorfield_Yeah
03:25amalloycurrently i work with long-running apps so i don't need that much, and sometimes it gets annoying to have to keep killing jvm processes, so i use lein
03:26seancorfield_But lein plugins are really easy to write too and there's a lot more of them
03:27seancorfield_For persistent JVM stuff, there's also jark
03:27amalloythe clojure web-development libraries are really nice btw, sid3k. i love how easy it is to write some ring middleware
03:29seancorfield_I'm not convinced they're good for really HTML heavy web apps. They're good enough for rest apis and small sites.
03:30seancorfield_But maybe I just need to spend more time with enlive (haven't liked what I've seen so far)
03:30sid3kthen it's better for me. I generally seperate frontend and serve the html stuff with just a static web server
03:30amalloyseancorfield_: yeah, i haven't really had to write huge html stuff. but coming from a no-frameworks-here php, moving to kinda-small-frameworks clojure still feels nice
03:30seancorfield_World Singles sites are HTML heavy but very dynamic
03:31seancorfield_So we use CFML for View-Controller and clojure for Model. Or at least we're going that way
03:36seancorfield_I've been using web frameworks for nearly a decade in CFML since my time at Macromedia. I've been lead developer on three of the most popular ones (in CFML).
03:37seancorfield_But I've definitely moved from large to small and I prefer multiple, composable microframeworks these days.
03:37amalloyseancorfield_: yes, ring is a fantastic webserver. i'm not in a position to judge re hiccup, moustache, enlive
03:39klangsorry to inject: isn't ring, hiccup, moustache and enlive supposed to be used in conjunction? (that's the feeling I get when I look at web programming in Clojure every 3 months ..)
03:41seancorfield_Ring is the foundation. The rest are optional but are often used together I believe.
03:42amalloyklang: ring is the webserver. hiccup and moustache (and enlive, i think?) are libraries for generating html responses to feed to the webserver
03:43Raynesamalloy: Ring isn't the web server. Jetty is the web server.
03:43seancorfield_Ring and enlive are now part of the new contrib libraries for 1.3.0
03:44seancorfield_Raynes, ring has a jetty-adapter, does it have support for tomcat?
03:44amalloyseancorfield_: i think so
03:44Raynesseancorfield_: I find it adorable that you assume I would actually know a lot about Ring just because I knew that one small fact. :)
03:44klangamalloy: yeah, I got that idea, more or less.
03:44amalloy$google clojure ring tomcat
03:44sexpbotFirst out of 309 results is: Jeroen Vloothuis: Deploying a Clojure web-application as a WAR file
03:44sexpbothttp://jeroenvloothuis.blogspot.com/2010/07/deploying-clojure-web-application.html
03:45amalloyRaynes: the fact you know is dubious anyway
03:46seancorfield_That blog post shows how immature clojure is for webapps right now
03:46amalloyring is clojure's interface to the webserver. you could as easily say that jetty isn't a webserver either, just an interface to the next-lower layer
03:47amalloyi guess ring is the http server, and jetty is the webserver? that's not totally false
03:47amalloyseancorfield_: it's also a year old
03:47seancorfield_lein-ring is much cleaner but I worry that ring is tied to jetty?
03:48klangseancorfield_: things move fast (I am starting over on web dev in clojure every time I look at it ..)
03:48seancorfield_Yeah it can be hard to keep track of it all
03:49seancorfield_We'll stick with a mix of CFML and clojure for the foreseeable future I expect
03:53seancorfield_The anti-histamines are kicking in (we spent the afternoon wine tasting and those sulphites have us both congested) so I'm getting dozy. Time to sign off and get some sleep.
04:09bprl
06:03tufflaxDoes anyone know how do make vimclojure detect java interop stuff (like .method and Class/thing)? I have the regexps but I can't get it to work. I don't fully understan the syntax file :p
06:51kzarI'm missing something here, any ideas? http://paste.lisp.org/display/122349
06:54raekkzar: from the docs for case: "The test-constants are not evaluated. They must be compile-time literals, and need not be quoted."
06:55raekso you end up having the _symbol_ com.google.gdata.data.calendar.CalendarEntry as the first test constant
06:58kzarraek: Hmm so com.google.gdata.data.calendar.CalendarEntry in the clause isn't evaluated but is that not already the literal symbol?
06:58kzarraek: The expression's evaluated right?
07:05raekyes
07:07raekerhm. I meant this: a case form looks like this: (case expr constant1 result1 constant2 result2 ...). here, expr is evaluated, but the constants are not
07:07raekkzar: your example fails because symbols and classes are not the same (put they print the same)
07:08raek,(class 'java.lang.Integer)
07:08clojurebotclojure.lang.Symbol
07:08raek,(class java.lang.Integer)
07:08clojurebotjava.lang.Class
07:08raeka symbol evaluates to a class if it contains dots
07:08kzarraek: Yea it just clicked heh
07:08raekkzar: you can work around it with a macro: https://gist.github.com/997652
07:13raekupdated the gist so that it accepts (case expr (constant11 constant 12) result1 ...) style forms too
07:28kzarraek: Heh it's little things like this that always catch me out, I'm just having a go at doing it myself
07:28kzarraek: Thanks for explaining it
07:45kzarraek: (resolve 'com.google.gdata.data.calendar.CalendarEntry) turns symbol to class, is there a way to do the opposite?
07:45kzarraek: (I figured instead of resolving the conditions I could make the expression a symbol)
07:52raekkzar: yeah, that sounds a lot simpler.. (defn class->symbol [class] (symbol (.getName class)))
07:54kzarraek: Ah nice, I was trying to stop the symbol from being resolved into a class but then I realised the (class) function actually returns the class not a symbol to be resolved
08:57bOR_is there something obvious I am missing when aset in clojure 1.3-alpha8 won't work for shorts. aset-shorts does work, but way slower than I'd expect. There is also the odd difference in speed between aset ^ints and aset-int of about 15-fold.
08:57bOR_(doing matrix summation)
08:59bOR_I've looked at the source of amap (which was the first thing to give me problems with shorts), and from there came to writing the amap function out, and using aset-shorts rather than aset to get shorts working), but I'm stuck at looking at the source of aset
08:59bOR_which is where my clojure-fu breaks down :-).
09:00bOR_related (now that I have the floor anyway), should I still be messing with java arrays in clojure 1.3, or would a vector of primitives be as fast?
09:03bpris there a more concise way to parse and integer than java.lang.Integer/parseInt ?
09:05bprshort of using memfn of course
09:06midsbpr: you could use read-string
09:07mids,(+ (read-string "3") 2)
09:07clojurebot5
09:08mids(it isnt safe though to use on input you dont control)
09:08bOR_,(aset (into-array Short/TYPE [1 2 3]) (short 1) (short 1))
09:08clojurebotjava.lang.IllegalArgumentException: argument type mismatch
09:08bprah, lol nice
09:08bOR_hmm.
09:08bprwell, i got the int string from a (re-find #"\s(\d+\)\s" string) so it's sanitised
09:10bprlol, i put an extra "\" ... too much emacs in my fingers lol
09:17midsbpr: I dont really see what is wrong with (Integer/parseInt s) though. if you use it a low, maybe create a shorthand parse-int function for it?
10:50markskilbeckHi, all. Has anybody managed to set up penumbra on Windows?
10:51markskilbeckThe typical process of "lein deps ... etc" doesn't seem to work for me.
11:15KneferilisHello, how fantom compares to clojure?
11:20imadeKneferilis: I just took a quick peak at fantom, seems interesting, definitely a better java, maybe you can tell more what impression you have about it?
11:22Kneferilisimade: I haven't used it yet really.
11:22imadeI haven't used clojure for long, maybe a month, so far the things I like: uniform syntax, dynamic typing (talk to the problem not to the compiler), easy to compose functions
11:23imadethere's more I guess, just need to discover clojure further
11:26Kneferilisclojure seems a very interesting language really
11:27imadeand I would say that easy to get started also, the syntax rules are so simple
11:27markskilbeckimade++
11:28KneferilisI just wanted to inlcude clojure in my plaform, but clojure for .net has libraries that conflict with ironpython and ironruby which my platform also supports
11:28Kneferilishttp://sourceforge.net/projects/mlip
11:34Kneferilisbesides I don't think that ClojureCLR (Clojure for .NET) supports Clojars, Clojure libraries for Java
11:35KneferilisI tried to include Clojure for Java in my platform, but it would keep trying to emit Java Bytes codes, if it was interpreted I could include it in my platform
11:45lnostdalwhy is it emitting java byte code a problem?
11:46Kneferiliswell, IKVM doesn't seem to accept the java byte code, I have IKVM in a .NET application
11:46KneferilisIKVM is Java for .NET
12:08lnostdaloh
15:10technomancyI've run Clojure code on IKVM very briefly. seemed to work OK.
15:12tufflaxI'm trying to make a chat server but I run it in a future to not block the repl, but something goes bad but I don't see the stack trace. Any ideas of how I can get to see the stack trace while still using a future?
15:17tomojtufflax: what are you using for the io?
15:17tomojoh, hmm
15:17tufflaxDoes it matter? :p
15:19tomojfuture seems to save the exception to throw on deref
15:19tomojif it's thrown by the thread that runs the future body
15:19tufflaxoh yes, nice. thank you
15:38raektufflax: while still using a future, you can either make the future thread catch the exception and then convey it to you somehow, or you can inspect the future object in the repl thread with future-done? (to not block if the thread is working) and deref
15:38raekthe first approach could be (try ... (catch Throwable e (.printStackTrace e))), i.e. print the stacktrace to stdout
15:39tufflaxok, thank you
15:39raekto get that behaviour, you can use a bare Thread instread of an ExecutionService (what 'future' uses)
15:41raekfuture is made for executing tasks in parallel on threads that belong to a thread pool, so that's why the error handling works this way
15:41tufflaxI noticed that the deref approach doesn't give me a stack trace, just shows what exception it was
15:42raektufflax: the original exception is contained in the cause of the exception
15:43tufflaxhmm can i get a hold of it somehow?
15:43raektufflax: what repl are you using and in what IDE?
15:43tufflaxvim with vimclojure
15:43raekwhen I develop in emacs, it shows me the whole stacktrace chain with all causes
15:43tufflaxhm
15:44raektufflax: if you only get the name of the exception, then you probably have the default clojure repl
15:44tufflaxok
15:44raektufflax: in that case, you print the stacktrace as usual with (.printStackTrace *e)
15:44raekI think that should print the causes too
15:45tufflaxoh, yes *e
15:45raekin any case, you can get the caus of an exception by calling .getCause on it
15:45tufflaxok
15:46tufflaxhmm, that wasn't very informative...
15:46tufflaxgetCause that is
15:47raekit will just return another exception object, which you can call .printStackTrace on
15:47tufflaxoh
15:48raekiirc, that should have the same effect as calling .printStackTrace on the original object, except that one "Caused by" section will be missing
15:48raek(well, the section before the first "Caused by" line)
15:51thorwilhow do i get a <!DOCTYPE html> out of a hiccup defhtml?
15:53amalloythorwil: (doctype :html5)
15:53thorwilUnable to resolve symbol: doctype in this contex
15:53amalloyit's in page-helpers
15:54amalloyi note with some amusement while looking for this that the hiccup jar includes .form-helpers.clj.swp
15:55thorwilah, dang! thank you!
16:00tufflaxthank you raek, now it's off to #java to ask about using sockets with nio channels and select and all that, apparently i did something wrong :p
16:04amalloytufflax: ##java
16:05tufflaxyes, /j java takes me to the right place, but thanks :)
16:06raekanyone know what the extra # means?
16:06bpri think the server appends a # when the previous channel gets too full
16:06bpr ... could be wrong (that's from some distant memory)
16:07bprwell, it creates a new channel with a # appended to the name, is what i meant if it wasn't clear
16:07bprprepended*
16:08amalloyit's to do with how canonical/authoritative the channel owners are re the name. you can find it in the freenode daq
16:11amalloyhttp://freenode.net/policy.shtml#channelownership
16:14amalloyraek: ^
16:22gfrlogI can't remember the last time I was glad that (:foo {}) didn't throw an exception
16:22gfrlogusually I end up diagnosing some consequential problem seven functions later
17:32TimMcgfrlog: Yay for nil-propagation... :-/
17:33TimMcOf course, it's not as bad as languages where what would normally be a NullPointerException comes out as evaluation-to-null.
17:33gfrlogyeah. I'm sure it's consistent with a lot of other functions...it's just what makes dynamic typing and such tiring...
17:33gfrlogwhat languages are those?
17:37kzarAnyone use couchdb from clojure here? Is clutch any good?
17:37gfrlogkzar: I have used it a small bit. I don't remember having trouble.
17:48kzarthanks I'll give it a shot
19:30bprI'm tring to play with swank-clj, and when i execute lein swank-clj I get this exception: Exception in thread "main" java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine (jdi.clj:1)
19:30bprdoes anyone know anything about that?
19:32bprthis is the jvm i'm running: https://gist.github.com/998244
20:29bendlashi
20:47gfrlogbendlas: hello