#clojure logs

2010-10-10

00:15sproustThere's nothing like doing some CL to remind you how cool Clojure is.
00:15amalloysproust: augh, now i'm going to have nightmares
00:17TeXnomancy(cl-awesome-p) ;; => nil
00:17amalloyto be fair, CL is better than a lot of things. our ancestors had to make do somehow until clojure came along
00:18sproustI have to admit though, I'm a sucker for its zippyness, and being able to compile. Java drags me down a bit. I wish for Clojure-on-top-C.
00:20TeXnomancy"being able to compile" o_O
00:20TeXnomancyoh, you mean the ability to produce native executables?
00:20sproustYes.
00:21sproustJava startup time makes Clojure prohibitive for a large number of "small" applications, IMHO.
00:22sproustI really like to be able to disassemble in CL, and make optimizations, be close to the metal.
00:30freakazoidIf you want to be close to the metal I don't think you want a JVM language.
00:31freakazoidThere are a ton of lisps that compile to C or assembly language or otherwise are designed for performance
00:31freakazoidsproust: I'd recommend Racket if you want something with its own VM
00:38kryftWhat's so terrible about CL? (I've never used it - Clojure is my first lisp.)
00:39kryftWell, I have had some scheme exposure, but I've never really used it.
00:39TeXnomancykryft: it just hasn't moved forward since the 80s
00:42kryftTeXnomancy: In terms of the libraries?
00:44scottjCommon Lisp: (concatenate 'string "foo" (write-to-string 1)) Blub: "foo" + 1
00:44TeXnomancypoor libraries, bizarre naming conventions, poor syntactic support for data structures, and overly-complicated OOP are the things I remember from trying to use it
00:47greghCL is like a programming language construction kit
00:47TeXnomancythey actually expect you to use alists instead of hash-tables for simple code and then rewrite your code to use hash-tables once your discover your perf bottlenecks... rather than just providing convenient syntax for hash-table literals so you can do it right the first time through.
00:48kryftAh. I'm glad I waited until clojure came along. :)
00:50kryftI've been wanting to learn a lisp for quite some time, but scheme seemed too minimalist for practical purposes, and Common Lisp... Well. Apparently my intuition was correct.
00:50scottjCL does have many great features we're ignoring :)
00:52TeXnomancyconditions is the only thing I can think of
00:53freakazoidkryft: well, Scheme is a big improvement on CL in terms of cleanliness, and Racket is pretty awesome, but Clojure has the benefit (to some) of running on the JVM and focusing more on immutable datastructures and good concurrency support
00:56greghoh yeah, and in CL some of the pieces are metric and some are imperial :)
00:56freakazoidhehe
00:58sproustfreakazoid: Racket is neat indeed, nicely packaged now, looks like; but I'm a bit invested in CL. I'd like to learn it.
00:59kryftfreakazoid: Ah, I hadn't heard about Racket. :)
01:00sproustkryft: just like there is nothing other than culture from preventing LISPs from taking over the dynamic language space, there is nothing preventing people to make a compileable LISP with much of the nice features that Clojure has.
01:01freakazoidI think lispers are the big thing standing in the way of lisp's success
01:02freakazoidI get the impression most clojure users are relatively new to the whole lisp thing
01:03sproustfreakazoid: be hopeful; there is a new generation of developers bred on dyn.lang like Perl/Ruby/Python and IMHO a Lisp is a natural next step. New blood on the horizon, this could be a big change in adoption. Any thoughts?
01:04freakazoidI am hopeful and I totally agree with you. Clojure is going to bring lisp into the mainstream
01:04kryftI guess I could be seen as part of that new generation. :) I've had a taste of functional programming using Python, and now I want the real thing. ;)
01:05freakazoidI assume by "functional programming" you are just referring to functions as first-class objects. There is a lot more to functional programming than that.
01:05kryftsproust: To me, running on top of the JVM is an advantage.
01:05sproustkryft: Exactly! Anyway, that's my hope.
01:05freakazoidPython makes waaay too much use of mutable datastructures
01:05freakazoidthe traditional form of OOP depends on it.
01:06freakazoidClojure agents make a lot more sense.
01:06sproustkryft: yeah, I suppose it depends on much Java exposure you've have; I can't decide for myself whether it's a gain or a liability.
01:06freakazoidI am not a Java user and I consider it an advantage just because of ease of deployment
01:06sproustfreakazoid: I don't understand why agents couldn't just be part of a library. It's just a thread pool with some synchronization primitives, no?
01:06freakazoidand all the preexisting libraries you get
01:06freakazoidand really good interop with all sorts of other languages.
01:06kryftsproust: I've had very little Java exposure myself, but I want the libraries.
01:07freakazoidI'm sooo tired of all the shitty FFIs out there
01:07kryftfreakazoid: You assume incorrectly. :)
01:07sproustfreakazoid: Yes, but you can write any scripts, startup time is way too slow.
01:07freakazoidkryft: then I don't know what you mean. Id on't think most people would consider Python even remotely a fucntional programming language.
01:07freakazoidsproust: I've noticed that, and it kind of bugs me. I'm pretty sure it's possible to make java stuff start much faster
01:08freakazoidsproust: it's not that - default behavior is very important
01:08sproustI still need to check out nailgun, it's meant to do that, runs your code in a waiting VM.
01:08freakazoidsproust: the "right" way should be the most convenient way
01:08freakazoidI don't think keeping the VM running is the answer
01:08sproustYep.
01:09freakazoidI've definitely heard of java apps starting much faster
01:09kryftfreakazoid: To me, functional programming is a paradigm. It's quite possible to write small programs in python that are pretty functional.
01:09freakazoidkryft: ok, so you've done functional programming in python
01:10freakazoidit lacks any functional datastructures, though
01:10freakazoidthere's some good functional stuff in numpy though
01:10kryftfreakazoid: Yes; that's why I said that I've had a taste of functional programming, and now I want the real thing. :)
01:10TeXnomancydidn't they try to remove reduce in python 3?
01:10freakazoidin that you can do all sorts of things to arrays without ever mutating them
01:10TeXnomancywhether it's possible to do FP in python or not, that certainly signals to me that the community does not approve of it
01:11freakazoidTeXnomancy: if they did I'm guessing they would have replaced it with something else - list comprehensions are preferred to map, I think
01:11sproustTeXnomancy: yes.
01:12sproustPython list comprehensions give you map and filter, not reduce.
01:12freakazoidTeXnomancy: they just moved it to functools
01:12freakazoidthey were just removing some random stuff from the global namespace.
01:13freakazoidsproust: that's why I said preferred to map and not to reduce ;-)
01:13freakazoidbut it turns out they just moved it
01:13freakazoidreducing the number of global names
01:13kryftfreakazoid: My 'functional' python programs were mostly list manipulations, and python does at least have lists. ;)
01:13sproustPython 3 is pretty neat actually, if people would port and get on with it. A lot of stuff was cleaned up.
01:14sproustfreakazoid: re. functional Python: the iterator concept is Python is analogous to Clojure's use of Seqs.
01:14freakazoidkryft: yeah, though they're actually extensible vectors so copying one just to change one element is pretty inefficient
01:15kryftfreakazoid: Ok; I never really used Python for anything where efficiency would matter. :)
01:15sproustfreakazoid: I've been able to easily write some text processing programs in Python as networks of iterators (generators). They "feel" very functional (though the syntax would be more adequate in a LISP).
01:15freakazoidI've done some pretty heavy duty processing in Python
01:15freakazoidlots of image processing using numpy and scipy
01:15freakazoidI need to start playing with Incanter
01:16freakazoidsproust: yeah, Python is getting very good with that sort of stuff
01:16sproustfreakazoid: re. vectors/performance: the Pythonistas generally believe there is no use case for lists (!).
01:16freakazoidand it's syntactically convenient to do a lot of things right
01:16freakazoidBUT it's still syntactically most convenient (and most efficient) to mutate in place in most cases
01:17freakazoidsproust: If you believe mutating data in place is the way to go, they're probably right.
01:18freakazoidThough even if you do, hash tables with linked lists for collision resolution are extremely common
01:18freakazoidbecause MTF is quite common
01:18freakazoidand very efficient
01:18kryftfreakazoid: In the past I've used Python or Matlab when efficiency doesn't matter and C++ when it does. I'm hoping to use Clojure for everything. :)
01:18freakazoidWell, you may have to drop to Java for some things, then, since Clojure is not hugely more efficient than Python
01:19freakazoidAt least, according to the programming language shootout
01:20freakazoidmaybe about 2.5x as fast on a quad core machne
01:21kryftfreakazoid: Others (including a certain Rich Hickey :) have said that you can get performance pretty close to Java if you know what you're doing.
01:21freakazoidThat would be pretty awesome.
01:21freakazoidI wouldn't think your code would look very good, thoguh
01:22Adamantit's like trying to get C speed out of a language
01:22kryftfreakazoid: [I am told that] the programming language shootout isn't very representative because most of the programs have such short runtimes.
01:22Adamantyour code starts to look like C in any language
01:23freakazoidkryft: yeah, could be.
01:23greghwhich is really just high level assembly
01:23amalloykryft: and also you have to use the same algorithm, even when it doesn't make sense in your language
01:23freakazoidi dunno, Haskell manages to get pretty fast and I don't think your code is gonna look much like C in Haskell
01:24kryftYup.
01:24kryftMind you, it doesn't have to be exactly as fast as C, as long as the overhead isn't terrible.
01:25kryft(For my purposes)
01:25scottjI was just watching a haskell conference talk where the speaker mentioned how horribly un-haskell the benchmark competition code was as if everyone already knew it
01:27kryftfreakazoid: Anyway, my first Clojure project will be to reimplement an algorithm that I wrote in C++, so we'll see. :P
01:27TeXnomancythe people who run the alioth shootout either don't understand how JIT warmups work, or they want to make runtimes that rely on JIT warmup look bad
01:27Adamantfreakazoid: it does
01:28Adamantfreakazoid: you can write Haskell-accented C in Haskell
01:28Adamantit's been done
01:28freakazoidscottj: oh, that's too bad.
01:28Adamantwell, "C"
01:28Adamantfreakazoid: it's all in a mutable-state monad
01:29Adamantwhich is basically C then
01:29Adamantsorta
01:29freakazoidStupid von neumann bottleneck.
01:30scottjTeXnomancy: Java does realy well in the shootout.
01:31Adamantyeah, Java has come a long way since they've thrown so many compiler gurus at it
01:31Adamantit is optimized as heck these days.
01:31freakazoidI got excited about this obscure language called "ATS" that's right below C but then I found out it just generates C and it's a quite verbose language.
01:31kryftfreakazoid: "Python is an amazing language for getting larger projects done right." Is this a different Sean Lynch? ;)
01:32freakazoidyeah, I think these days you should really have to justify writing your own VM.
01:32freakazoidthere's no reason whatsoever for Python's or Parrot. Ruby's at least has microthreads and call/cc
01:32freakazoidkryft: did I say that?
01:33freakazoidI might have
01:33greghwell python's existed before jvm, so there's the excuse of legacy
01:33freakazoidgregh: that's true.
01:33kryftfreakazoid: I take it your homepage hasn't been updated in a while? :)
01:33Adamantfreakazoid: ATS is a interesting language
01:33clojurebotmake a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
01:33freakazoidkryft: http://literati.org/~seanl/ is my home page
01:33Adamantthat guy is full of poop
01:33Adamantthe scienceblogs guy
01:34freakazoidC *can be* efficient. *your C* is buggy, unmaintainable, and still slow.
01:34kryftfreakazoid: Ok, so probably it was a different Sean Lynch then. =)
01:34freakazoidthere are a lot of us.
01:34Adamantlike the Erics.
01:35freakazoidi used to be a pretty big Python fan.
01:35freakazoidIt has a lot of the same advantages as clojure without having to have been hosted on the jvm to get them
01:35freakazoidi.e. large, vibrant community, huge number of libraries
01:35freakazoidin spite of having a pretty shitty API
01:35freakazoidwell, now there's ctypes
01:35freakazoidwhich rocks
01:36Adamantfreakazoid: Python is OK
01:36freakazoidwith multicore and more distributed processing, I suspect Python's popularity will wane as languages like Clojure and Erlang pick up the clack
01:36freakazoidslack
01:36kryftAdamant: Full of poop how?
01:37Adamantkryft: I disagree with him on a lot of things and he's been wrong about at least one thing he's ranted on
01:37Adamantalthough I'd have to go back through his blog and jog my memory as to which
01:37kryftAdamant: You disagree with him in general, or you disagree with something in that article_
01:37kryftAdamant: ?
01:38Adamantkryft: I haven't read the article, because I think he's full of poop and don't bother doing so at this point.
01:38Adamantit's a general advisory.
01:39freakazoidHe's claiming Fortran is better than C for writing efficient numerical code?
01:39Adamantno, that's true.
01:39Adamantusually.
01:40AdamantFortress would be nicer and probably just as fast, but the current implementation is an interpreter, so no.
01:40freakazoidinteresting
01:41freakazoidI wonder if Rust is going to go anywhere or if it will just die an early death
01:41Adamantfreakazoid: would be nice if it went somewhere
01:41freakazoidyeah, it looks pretty neat
01:41Adamantsince BitC hasn't really panned out
01:42freakazoidbut it's not good enough to be slightly better than a bunch of other languages
01:42freakazoidthat's the beauty of, say, clojure
01:42freakazoidit gets to benefit from a bunch of existing work and an existing community
01:43freakazoidRuby'd probably never have gone anywhere if it weren't for Rails
01:43freakazoidI think most of the original Python users are perl refugees and scientists who couldn't stand lispers and got tired of fortran
01:44freakazoidI'm actually a perl refugee by way of tcl
01:45AdamantRuby is nice
01:45freakazoidI liked ruby a lot when it came out but it has too many perlisms
01:45Adamantfor what it is
01:45Adamantfreakazoid: there were a lot of Lispers that wanted to use Lisp but couldn't justify it
01:45Adamantthat went to Python
01:46freakazoidif you can't justify lisp, why can you justify python?
01:46TeXnomancypython can do sockets?
01:46Adamantif you're doing commercial work in the 2000-era?
01:46Adamantthat's how Google got hooked on Python
01:46freakazoidI don't know that much abotu lisp
01:46freakazoidjust scheme
01:47TeXnomancyGoogle started using Python because you couldn't set the User-Agent header when doing HTTP requests in Java in the nineties
01:47freakazoidhaha
01:47freakazoidwow
01:47Adamantthe situation for Common Lisp is much better in 2010 than it was in 2000 or even 2005
01:47TeXnomancyfreakazoid: true story: http://groups.google.com/group/comp.lang.java/browse_thread/thread/6923c024ed392c85/88fa10845061c8ba
01:48freakazoidAdamant: even so, whether or not it's part of CL it's gotta be part of every real-world implementation
01:48Adamant?
01:49Adamantfreakazoid: anyway the current tech lead at Google is a ex-Lisper
01:49freakazoidAdamant: sockets
01:49Adamantfreakazoid: oh yeah
01:49freakazoidbrb, I'm changing themes to see if it'll improve performance
01:50freakazoidalso possibly closing all my tabs will increase my performance
01:50freakazoidMuch better
01:50freakazoidMight just have been too much scrollback
01:50freakazoidI'm diggin this theme though
01:50freakazoidvery clean.
01:52freakazoidHeh, so Larry got into Python at the same time I did
02:00Adamantfreakazoid: too much of the brown acid?
02:00Adamant:P
02:01freakazoidheh
02:01freakazoidno, just hadn't heard anything since I came back into the channel
02:01Adamantwell, my joke solved that
02:02freakazoidIndeed
04:57yayitsweiwhat's a good way to split run-lengths, e.g. [1 1 1 2 2 3 3 3] => [[111] [2 2] [3 3 3]]
04:58_ulisesmorning all
04:58yayitswei_ulises: morning
04:59_ulisesmorning yayitswei
05:04bytesourceHi all! I am reading the Enlive tutorial by David Nolen. I have got a little problem. Whenever I make changes to the code and then reloade deftemplate or routes nothing changes on the website. Does anybody know how to make these changes happen?
05:05hoeckyayitswei: I would use reduce: http://gist.github.com/619097
05:05yayitsweibytesource: which repl are you using?
05:06bytesourceI am using the Emacs REPL.
05:06yayitsweihoeck: ah thanks! taking a couple minutes to study it
05:07yayitsweibytesource: try pressing C-c C-k to recompile?
05:08bytesourceOK, I'll try
05:11jarpiain,(letfn [(rl [xs] (lazy-seq (when (seq xs) (let [[h t] (split-with (partial = (first xs)) (rest xs))] (cons h (rl t))))))] (rl [1 1 1 2 2 3 3 3]))
05:11clojurebot((1 1) (2) (3 3))
05:11bytesourceyayitswei: That seems to work!
05:12jarpiain,(letfn [(rl [xs] (lazy-seq (when (seq xs) (let [[h t] (split-with (partial = (first xs)) (rest xs))] (cons (cons (first xs) h) (rl t))))))] (rl [1 1 1 2 2 3 3 3]))
05:12clojurebot((1 1 1) (2 2) (3 3 3))
05:14yayitsweibytesource: perfect. reloading the templates and routes should work too though, maybe you weren't actually evaluating them?
05:15yayitsweijarpiain: awesome thanks
05:18bytesourceyayitswei: After making changes, e.g. adding a selector, I pressed C-x C-3 both for deftemplate and routes.
05:18bytesourceSorry, C-x C-e
05:32LauJensenMorning guys
05:45esjhey Lau
05:45_ulisesmorning LauJensen
05:52_uliseshow good a style is to have a (let [] ...) with a fair bit of bindings that has a single expression in its body that uses them all (or most) as the result of the fn?
05:52_ulisese.g. (let [x 10 x-times-2 (* 2 x) y 5 y+x (+ y x)] (* 10 y+x))
05:52_ulises(I know it's a silly example)
05:53AWizzArd_ulises: this can be very clear in some cases. Decide on a case-by-case basis.
05:53_ulisesis it better to break the function into a set of smaller functions that perform the steps in the bindings?
05:54_ulisesright, my question was because it feels very imperative, but it usually results in much clearer functions (especially when you have lots of maps, etc.)
05:54AWizzArd_ulises: where are those side effects that give you this feeling? :)
05:54_ulisesoh, it's not the side effects but the sequence of steps
05:54_ulisesin my mind sequence of steps = imperative
05:55AWizzArdWhat you wrote is declarative. You are not even programming, you just say how you name things.
05:55_uliseswhereas chain of applications = more functional
05:55_ulisestrue
05:55_ulisesI think it may also be am issue of trying to do too much inside an fn too :/
05:55AWizzArdFor those small math expressions I personally would find this too verbose, but if you mean the general principle and not this concrete example, then this can be totally fine.
05:56_ulisesoh, yes, this example is very small
05:56AWizzArdYou communicate with the readers of your code, and it is nice to let them easily break down into pieces that humans can consume.
05:56AWizzArdThe compiler can read thousands of those per second, even if brutally deep nesting :-)
05:56AWizzArdif ==> with
05:56_ulisesin general I have things like [some-result (map f (a seq from params)) extra-stuff (map g (other-seq)) zipped-results (partition 2 (interleave some-result extra-stuff))]
05:57_ulisesright
05:57AWizzArd_ulises: it can also be fine to say: (let [x (foo 1), x (bar x)] ...)
05:58_ulisestake this for instance: http://pastebin.com/E1hGVGxG
05:59AWizzArd_ulises: yes, I would be thankful of being able to read it with the single elements broken down into their own vars. It is totally idiomatic to use a let for readability.
05:59_ulisesgreat then :)
06:00AWizzArdIf you repeat a single expression, then it is even important to use let. But also for expressions that appear only once it can be great, if those expressions don't happen to be something like “5”.
06:00_ulisesoh, indeed
06:00_ulisesthe example I provided here was far from good
06:01_ulisesI was actually talking about the idea of breaking things down inside the let bindings
06:01_ulisesfor some reason it felt silly to do it that way
06:05_ulises,(defn f [{v :foo}] v)
06:05clojurebotDENIED
06:05_ulisesugh
06:05_ulisesin any case, it would seem sensible (at least to me) to allow the reverse to be valid as well: (defn f [{:foo v}] v)
06:05_ulises(just a comment)
06:32snaundis there any good documentation / example available about how to use the functions that (defentity ...) from appengine-clj's appengine.datastore creates ?
06:42raek_ulises: "the reverse" is reserved for things like :as, :or, :keys, :strs and :syms
06:45_ulisesraek: oh, I didn't know, thanks
06:46raekif the key is a symbol, then it is a binding thingy. if it is a keyword, then it is some kind of option
06:46raekthe options would look very strange if they were reversed
06:49raek,(let [{x :x, :keys [a b], :strs [c d], :syms [e f], :or {x 0}, :as m} {:a 1, :b 2, "c" 3, "d" 4, 'e 5, 'f 6}] [x a b c d e f])
06:49clojurebot[0 1 2 3 4 5 6]
06:52_uliseshum
06:53_ulisesright.
07:34fbru02hey guys stupid question time how can i convert a string into a token??
07:36AWizzArdfbru02: depending on what a “token” is there will be a converter function or a constuctor.
07:36AWizzArd+r
07:36AWizzArdAre you possibly talking of symbols?
07:36AWizzArd,(symbol "fbru")
07:36clojurebotfbru
07:37fbru02AWizzArd: I was thinking abut tokens for this : :token :fbru02
07:37AWizzArd,(keyword "fbru")
07:37clojurebot:fbru
07:38AWizzArdThose are (instances of the class) Keywords
07:38fbru02AWizzArd: thanks a lot !!
07:57bytesourceI have a question about the folder structure using Enlive. The source of deftemplate is "templates/coffee/subpage.html". I have no problem with this template, however, the css file (href="coffee.css") that is in the same folder as the html file cannot be found.
08:00raekyou use the html in deftemplate and serve the other file with ring?
08:00raekdeftemplate looks for files on the classpath
08:01raekwhere the ring wrap-file middleware looks for the files can be configured
08:04raek(wrap-file ... "resources/templates")
08:04bytesourceI am not quite sure. I just started with the Enlive tutorial and wanted to test my new knowledge.
08:04bytesourceThat looks interesting. I'll take a look...
08:05raekah
08:05raeksee http://github.com/swannodette/enlive-tutorial/blob/master/src/tutorial/utils.clj#L42 and http://github.com/swannodette/enlive-tutorial/blob/master/src/tutorial/utils.clj#L9
08:06bytesourceThanks!
08:07raekI usually keep my html templates in resources/
08:07raeklein makes that available on the classpath just like src/
08:08bytesourceThats good to know! I only knew about the src and classes folder. Is it OK to just add the resources folder or do I have to adjust project.clj, too?
08:09raekno, it already done
08:09raek(you can confirm these things by running "lein classpath")
08:14bytesourceYes, you are right, the 'resources' folder is already on the classpath: /home/sovonex/Clojure/enlive-tutorial/resources
08:23bytesourceJust to make sure I understood correctly: My html and css files are now located at resources/templates/coffee/ , the corresponding deftemplate is located at scr/tutorial/menu.clj. *webdir* is set to"/src/tutorial/" by default. Now when I set the source of deftemplate to "templates/coffee/subpage.html" I get an error.
08:24raekI wonder if you have to restart clojure if the resources dir did not exist before
08:25bytesourceI did 'lein deps' but this did not work.
08:25bytesourceOK, I'll restart Clojure...
08:25raekI vagely recal having some problem with that
08:28bytesourceraek: Great! Now my html file gets found!
08:30bytesourceraek: However, one problem remains: The css file that is in the same folder as the html file and referenced in the html file as href="coffee.css" still does not get loaded.
08:41LauJensenbytesource: gets loaded when? are you mixing it into the html or serving it on some web interface?
08:44raekbytesource: can you access it directly with the browser?
08:44bytesourceI am sorry, I don't quite understand your question. I have three files: subpage.html and coffee.css that are both located at resources/templates/coffee/. Then there is menu.clj which is located at src/tutorial
08:44raekhttp://localhost/coffee/coffe.css
08:45bytesourceraek: No, I cannot directly access coffee.css in the browser
08:45raekhrm, add port number to that example
08:45bytesourceI already did that
08:45raekwhat was *webdir* set to?
08:45bytesourcehttp://localhost:8080/coffee.css
08:46bytesource*webdir* is set to /src/tutorial/
08:47bytesourceThis is where I get confused. There is the classpath and then there is also *webdir*
08:48mtopolnik,(time (dotimes [i 1000000] (keyword "a")))
08:48clojurebot"Elapsed time: 1007.993 msecs"
08:48mtopolnik,(time (dotimes [i 1000000] (symbol "a")))
08:48clojurebot"Elapsed time: 667.325 msecs"
08:51bytesourceraek:, LauJensen: Tomorrow I'll take a closer look at this problem. Thanks a lot for your help!
08:52LauJensenbytesource: np, if you want I can find a link to one of my blogposts where I demo this type of thing
08:53bytesourceLauJensen: That would be great!
08:53LauJensensec
08:54LauJensenbytesource: 1) http://bestinclass.dk/index.clj/2009/12/dynamic-interactive-webdevelopment.html 2) http://bestinclass.dk/index.clj/2010/02/reddit-clone-in-10-minutes-and-91-lines-of-clojure.html 3) http://bestinclass.dk/index.clj/2010/02/reddit-clone-with-user-registration.html and optional) http://bestinclass.dk/index.clj/2010/06/best-in-class--now-open-sourced.html
08:55bytesourceThis is fantastic! Thank you very much!
08:55LauJensennp :)
08:55LauJensenFeel free to shoot back if anything is unclear
08:55raekbytesource: *webdir* should be set to "/resources/templates/" in your case
08:55LauJensenIn the first 3 posts, I think Im using Compojure, but nowadays I mostly use Moustache
08:56raekMoustache <3
08:56raek*webdir* is where static files are served from
08:57bytesourceI haven't head so much about Moustache and therefore thought everybody is using Compojure anyway.
08:57raekmaybe resources/static/ would be a good place to put static files. that way you don't accidentally serve the template files
08:57bytesourcereak: That sounds good!
08:57raekhttp://groups.google.com/group/clojure/msg/64e8ed91791d81d2
08:58raekJames Reeves (author of Compojure) summarizes the clojure web ecosystem
08:58LauJensenbytesource: moustache is very nice to work with. Once you learn the basic syntax of Enlive and Moustache, its easy to work with
08:58bytesourceThanks for this link. I will take a look at it later. Right now I cannot open it because Google Groups is blocked here.
08:59raekhttp://pastie.org/1211070
08:59bytesourceLauJensen: Then I guess I should take a closer look at Moustache, too :-)
08:59raekonly 16 lines
08:59LauJensenbytesource: I'd recommend it. The entire site bestinclass.dk is run on nothing but Moustache and Enlive, and it took a very short time to build
09:00mtopolnik,(dotimes [i 3]
09:00mtopolnik (time (dotimes [i 1000000] (keyword "a")))
09:00mtopolnik (time (dotimes [i 1000000] (symbol "a"))))
09:00clojurebotEOF while reading
09:01bytesourceraek: I cannot open this site, either. But that's no problem. I'll use a VPN than every site is accessible.
09:01LauJensenmtopolnik: You can query the bot and give it commands in private if you like
09:01mtopolniksorry...
09:01mtopolnikhow do i do that?
09:01LauJensentype /query clojurebot
09:02mtopolnikThanks
09:02LauJensennp
10:23AWizzArdHi rhickey, good morning.
10:33AWizzArdfast question, someone may know it: do swing text components (JEditorPane, JTextPane) support Drag&Drop on specific words?
10:37LauJensenAWizzArd: IIRC you implement your own D&D handlers. Wouldnt be tricky to get the selected word
10:39AWizzArdsounds good
10:41AWizzArdLauJensen: btw, when you want to display styled texts (different fonts/colors/backgrounds, italic, bold, etc), would you then do it via the RichText capabilities of Swing, or put a html string into the component.
10:41AWizzArdI was actually thinking about using one of those html generator macros :)
10:41LauJensenAWizzArd: I used html to keep it simple
10:41AWizzArdYes, sounds less complicated to me too.
10:42LauJensenEasy to work with, easy to debug, read, etc
10:42AWizzArdWith a html macro one could write down the styled text as a tree and have the chatty html stuff being generated.
10:45LauJensenAWizzArd: Would also be trivial to implement some kind of markup *word* = <b>word</b>, **word** </italic></b>world... etc etc
10:46AWizzArdyes true
10:46AWizzArdOur own "wiki style markup"
10:46AWizzArdgood idea too
10:46LauJensenthanks :)
11:02jaleyhi guys - leiningen question... if I add java source to my project, e.g. under src/myproject/java/... whill leiningen "just do it", or is something more scary required?
11:03TeXnomancyjaley: it will just work in 1.4.0 (which hasn't been released yet). for now try the lein-javac plugin. I don't think it's scary, but I've never used it myself.
11:05jaleyTeXnomancy: ah ok thanks. I'm trying to figure how to get the client stubs generated by Axis from a WSDL into my clojure project. ideally i'd like leiningen to run the code generator first too, but this is sounding like adding ant/maven tasks? :/
11:13raekjaley: making a leiningen plugin is really simple, iirc. something like making a function called my-plugin in the namespace leiningen.my-plugin and putting the code in the right place
11:13raekhttp://github.com/technomancy/leiningen/blob/master/PLUGINS.md
11:13micryptHi, quick question: When does one use "defn-"?
11:14jaleyraek: cool, thanks!
11:14jaleymicrypt: for function you don't want to be visible outside the namespace you define it in
11:15micryptjaley: Oh, thanks. Google kept correcting my search query to "defn". :)
11:20TeXnomancyyou don't need to write a plugin for compiling java; just declare a dev-dependency on the existing lein-javac
11:26jaleyTeXnomancy: ah ok. it also looks like I might be able to use a hook to run the code generator tool before compiling
11:31TeXnomancyyeah, sounds right
11:34jaleyTeXnomancy: awesome. leiningen has prevented java tools from ruining my day again!
11:37raekHow do the models of Leiningen and Cake differ? I've heard that Cake has a "dependency based task model", but what model does Leiningen have?
11:39LauJensenraek: plugin model
12:04TeXnomancyraek: in leiningen tasks are just functions
12:05TeXnomancyso you get composability, familiarity, memoization, and all the things you're used to with functions
12:10jaleyhow can i create a String[] from clojure? to-array will create an Object[].. is there a way to cast? or is this the wrong way to do it?
12:12jaleyoh it's cool, into-array seems to do it
12:12AWizzArdyes
12:26gilbertleunghi
12:47jaleywith hooks for leiningen... is it at all necessary/recommended/sensible to create them in the leiningen namespace (as with plugins)? or would they be better in my own project namespace?
12:52TeXnomancyjaley: it should be under the leiningen.mytask namespace
12:52TeXnomancyI think the plugin guide is explains it; you can see other plugins for examples
12:53jaleyTeXnomancy: yes it does, specifically for plugins - i guess my question really is, "are hooks the same?"
12:55jaleyTeXnomancy: actually... thinking about it. having a seperate task for this makes more sense anyway. so i'll go with a plug-in
13:29jaleydoes a leiningen plugin *have* to be a seperate project? is it not possible to create a local task for a particular project?
13:30raekrobert.hooke question: "Then users can place files that call add-hook under a specific namespace prefix (my.program.hooks.*) which they can rely on getting loaded at startup." How do I make my project load all such files?
13:30raekjaley: I don't think they need to be spearate projects
13:30raek"So writing a Leiningen plugin is pretty straightforward; as long as it's available on the classpath, Leiningen will be able to use it."
13:31raekthis would include hooks placed in src/, I think. at least I have seen that be done.
13:31jaleyraek: that's what i thought... but i'm having trouble getting it to pick up my task
13:32raekoh, one must also add the :hooks [the.ns.with.the.hooks] to project.clj...
13:32jaleyraek: for plugins? i thought that was just hooks
13:32raek* :hooks [[the.ns.with.the.hooks]]
13:32raekah
13:33raekalso, disregard the correction...
13:33raekis your plugin in the correct namespace?
13:33jaley;; (ns leiningen.axis-wsdl)
13:34raekand there is a (defn axis-wsdl ...)?
13:34jaleyraek: yeah
13:34raekand the file is in src/leiningen/axis_wsdl.clj ?
13:35jaleyraek: it's in src/clj/leiningen/axis-wsdl.clj, with src-path set to src/clj. should the file be named with the underscore instead?
13:35raekyes
13:35jaleyraek: i'll give that a go then. do you know the reasoning behind that, out of interest?
13:35raekthis has to do with valid java class names
13:37raeksrc/leiningen/axis_wsdl.clj can be AOT compiled into classes/leiningen/axis_wsdl__init.class
13:37raekand the class name has to match the file name
13:39raeksorry for mixing up hooks and plugins... now I need to eat
13:39jaleyraek: cool - thanks for the help
13:43uninvertedWhat's the simplest way to create a directory in clojure?
13:48dnolenuninverted: (require '[clojure.java.io :as io]) (.mkdir (io/file "/some/path"))
13:52uninverteddnolen: Thanks
14:03freakazoidI'd like to use the BitTorrent mainline DHT from Clojure. Anyone know of a java or clojure library that will let me do this?
14:03freakazoidlooks like Snark is gone and never supported the DHT in the first place.
14:03freakazoidAnd I don't think Azureus suppors the mainline DHT
14:11freakazoidHmm, maybe I should use JXTA instead
14:43jaleyhmmmm.. lein repl, (use 'leiningen.mytask) -> nil ; seems to work fine. but lein mytask tells me that's not a valid task, and lein help mytask gives me a FileNotFound exception. any suggestions?
14:48DanielGlauser /msg NickServ identify 1l2gbOGH
15:29LauJensen /query hugod ping?
15:30hugodLauJensen: hi
16:04petrillizeromq
16:11petrilliHas anyone ever gotten ZeroMQ and Clojure working on Mac OS X?
16:20jaleyargh... so it seems leiningen only detects plugins in src/leiningen - ignoring :source-path from the project.clj file. anyone know if this is intentional?
16:21LauJensenjaley: I think it is, maybe you should try cake
16:21TeXnomancyjaley: the classpath for leiningen is fixed at boot; you can't change it at runtime
16:22TeXnomancyso once you've read project.clj, it's too late
16:22TeXnomancyyou can only change the classpath of your project
16:22LauJensenwell, you can acccess both leins cp and your projects cp
16:24jaleyTeXnomancy: ok it's cool. my project had a src/clj and a src/java, so I assumed the cp for leiningen would be the same as specified in my project.clj. this works fine though
16:24TeXnomancyjaley: a few things have to be hard-coded in due to the inflexibility of the JVM
16:24TeXnomancysad but true
16:24LauJensenTeXnomancy: Which inflexibility?
16:25TeXnomancyI guess it comes down to the deprecatedness of add-classpath
16:26LauJensenGuess so. Still works though. But Ive never had a build task which needed more than the actual projects cp
16:27ihodeswow, a few hour respite from school-work and i've finished up the draft of the first half of my Clojure IO essay/tutorial/howto
16:27TeXnomancyyeah, and I've never seen the point of changing :source-path either, so there you have it.
16:28ihodesLaTeX is the cause of much of my lost time. i see NO HUMOR in your name, Technomancy
16:28ihodes;)
16:28LauJensenihodes: I think TeXnomancy != technomancy
16:29ihodeshaha alright
16:29ihodesLauJenson: then i doubly object!
16:30LauJensenhehe. I gotcha. TeXnomancy your nick is a little bit unfortunte to be honest, would you consider using 'clabango!' instead please?
16:54TeXnomancy~suddenly
16:54clojurebotCLABANGO!
17:07NikelandjeloIs there a way to "clean" memory for function, which was memoized?
17:08NikelandjeloTo reset it
17:11LauJensenNikelandjelo: Just re-memoize it ?
17:17NikelandjeloLaujensen: Actually, I have a bit different problem: my function is recursive, so it should be defined as (def my-fun (memoize (fn [] ... ) ) ) .But it also depends on some outer vars. This vars change sometimes, but already memorized something. I think I should pass this outer vars as parameters to function.
17:19nex_does it make sense to you that when using the functions from clojure.set, and any of the atributes is not a set, then it could be considered a set with only that object? for example (clojure.set/intersection 5 #{3 4 5}) => #{5}
17:22jaleysounds a bit dangerous... i've done that a few times by mistake, and treating it as a set would've masked a bug
17:27nex_jaley: true, it might not be too convenient in practice
17:27jaley(Runtime/getRuntime)
17:27jaleyarse, sorry
17:28amalloyNikelandjelo: yes, it is in general very dangerous to depend on global variables. that makes a function impure, and a lot of the things that operate on functions (eg memoize) depend on purity
18:49alpheusNikelandjelo: If you need access to the cache used my memoize, see http://www.paullegato.com/blog/memoize-reset-clojure/ -- the caveats others mentioned apply, of course
18:50alpheuss/used my/used by/
18:50sexpbot<alpheus> Nikelandjelo: If you need access to the cache used by memoize, see http://www.paullegato.com/blog/memoize-reset-clojure/ -- the caveats others mentioned apply, of course
18:51alpheusthat's a cute bot feature
18:57amalloyalpheus: personally i'd rather it didn't do that; it's not hard to do the substitution in your head, and it takes up screen real estate
18:58amalloysexpbot: i wonder, are you as chatty as clojurebot?
18:58amalloyclojurebot: see, sexpbot just isn't as smart as you are
18:58clojurebotsexpbot is there is another
19:00amalloyclojurebot: sexpbot is an impostor
19:00clojurebotAck. Ack.
19:08freakazoid"sexp" in scheme should be "sex?"
19:09coldheadclose as most programmers get to it amirite
19:09coldhead:(
19:11airolsonno, you're not :P
19:14coldheadsorry, i was wryly self-deprecating. as a matter of fact i am having sex right now
19:16freakazoidyeah, not me eihter.
19:16freakazoidI get a ton of sex in second life.
19:17amalloyfreakazoid: now you're just encouraging him
19:19freakazoidWhat, are you saying SL sex isn't real sex?
19:21kutkuSL sex? hahaha
19:26amalloyso i've noticed that using destructuring in function arglists causes (doc f) and slime's prompting for (f <point>) to look ugly. i can add {arglists} metadata to my functions to present a cleaner look, but is there a way to have it automatically use :as my declarations in the arglist?
19:27amalloyeg (defn myfunc [{name :fname last :lname :as person}]) automatically get the simple arglist of [person]?
20:00amalloyhttp://gist.github.com/619722 is a version of max-key that doesn't apply the key more often than is necessary; anyone think this should get into contrib?
20:20defnwhat's the best way to talk to mongo with clojure?
20:21defnthe wrapper i found seems awfully dated (2009)
20:36dakronedefn: http://github.com/somnium/congomongo perhaps?
20:36Raynesdefn: I use congomongo.
20:36Raynesdefn: It's definitely not dated.
20:36duck1123+1 for congomongo
20:39notsonerdysunnywhat happens when I do "cake swank" ..? I was expecting that all the ".clj" files in the project will be in loaded when I start a swank-clojure in that project. but it seems like I have to load them explicitly via" C-c C-k " .. can anybody help?
20:39Raynesnotsonerdysunny: cake swank only puts them on the classpath.
20:39RaynesYou still have to load files that you want to use.
20:39Raynesnotsonerdysunny: Also, we have a #cake.clj channel. :>
20:40RaynesIn case you have more questions.
20:40notsonerdysunnyRaynes: is it possible to make it load all the clj files when I start the swank server
20:46dbleylhello - looking for a way to call a final protected method of a base class extended with gen-class.
20:47dbleylseen several posts, but nothing recent.
20:55RaynesI believe wall-hack-method does what you want. It's in contrib somewhere. Not sure where.
20:57dbleylThanks, I'm checking it out now...
21:00Raynesdbleyl: Looks like it's in c.c.java-utils
21:01amalloyM-q in paredit mode behaves strangely for me if my function has a metadata map. does this happen to anyone else?
21:18bhenrywhich java should i install for clojure in ubuntu?
21:19Raynesbhenry: openjdk is fine.
21:19dbleylRaynes: thanks - I'm running 1.3 master, and it's looks like those methods have been moved.
21:19Raynesbhenry: It's in the Ubuntu software repositories, so you can grab it from synaptic.
21:19Raynesdbleyl: Oh. Didn't know that.
21:20bhenrythe first line in this guide http://riddell.us/ClojureOnUbuntu.html didn't work for me on ubuntu server 10.10
21:20bhenrypackage has no installation candidate
21:20RaynesOne moment.
21:21Raynesbhenry: Try sudo apt-get install openjdk-6-jdk
21:21clojurebotslime-installer is http://github.com/technomancy/clojure-mode/blob/0f28b61de90ce8a09d75bf1668ef3f1c200f9c52/clojure-mode.el#L560
21:21dbleylRaynes: looks like it's in c.c.reflect and is called call-method now.
21:22Raynesdbleyl: Oh, neat.
21:22bhenryRaynes: thanks
21:23Raynesbhenry: The package that it was trying to install appears to exist int he Lucid Lynx repositories. Might have been removed in 10.10
21:24Raynesbhenry: That guide looks kind of old. The official github repos for Clojure and contrib are github.com/clojure/clojure and github.com/clojure/clojure-contrib respectively.
21:25RaynesWe also have things like cljr and cake for starting REPL and running individual files, which pretty much kills the point of rolling your own clj script in most cases.
21:26bhenryi searched for "install java for clojure on ubuntu" and that was the first hit. i do everything with lein and don't actually ever install clojure
21:27RaynesOh. I just assumed... ;)
21:29bhenryyeah i just needed the java package. i'm playing with ubuntu server for the first time. i want to familiarize myself with running apps on virtual machines.
21:38dbleyl:Raynes call-method did exactly what I needed. Thanks a bunch.
21:38dbleylbye.
22:19freakazoidoh look at that, I don't actually need clojure installed. Just lein
23:05TaigerRobocotI need to convert 1 Java method to clojure, anybody could help me?
23:20BahmanHi all!
23:25freakazoidI don't know java :(
23:26freakazoidHey Bahman likes both erlang and clojure too
23:26BahmanYo freakazoid!
23:28freakazoidhttp://programming-puzzler.blogspot.com/2010/08/racket-vs-clojure.html complains about the fact that an agent's mailbox can consume all resources - but the same is true of Erlang, so clearly it's something that can be dealt with.
23:29freakazoidAnd the complaint about STM (that long-running transactions might never finish) seems like it also exists in RDBMSes and in Haskell's STM
23:31freakazoidI guess much of that's already addressed in the comments
23:36ossarehTaigerRobocot: can you expand on your request a bit?
23:41TaigerRobocotpublic static int testarQuadradoPerfeito(int aux, int num, int numero) { if (aux > numero) { return 0; } else { if (aux == numero) { System.out.println(numero + " is a perfect square."); return numero; } else { aux = aux + num; return num + testarQuadradoPerfeito(aux, num + 2, numero); } } } }
23:42ossareherg, could you put it on pastebin please?
23:42TaigerRobocotyeah
23:44TaigerRobocotossareh: I created this code in java and I need to convert to clojure because I am making a university homework. Clojure is dificult - Link: http://pastebin.com/g7MnnTMW
23:45TaigerRobocotI am calculating if a number is a square perfect without use Math library
23:55amalloyTaigerRobocot: you probably want to look into the (cond) function in clojure - it's the lispy way of doing if/elseif/else
23:57amalloyso a sketch of your code (not doing homework for you!) might be (cond (some-condition) 0, (condition-2) (recur some-val), :else false))