#clojure logs

2010-08-26

00:54ihodesanyone home? got a q re: a simple function
00:54mebaran151I could try to help
00:55ihodesalright, so there's this post by cgrand, and it's about finding the fibo nums. (here: http://clj-me.cgrand.net/2010/06/04/primitive-support-for-fns/) and he's saying a supefast version is taking ~800ms on his new laptop. this version is many lines of code...
00:55ihodes,(def fibs (map second (iterate (fn [[x y]] [y (+ x y)]) [0 1])))
00:55clojurebotDENIED
00:56mebaran151ihodes: don't def
00:56ihodes(take 39 (map second (iterate (fn [[x y]] [y (+ x y)]) [0 1])))),
00:56ihodes,(take 39 (map second (iterate (fn [[x y]] [y (+ x y)]) [0 1]))))
00:56clojurebot(1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986)
00:56ihodesthat takes 0.059ms on my laptop…
00:56ihodes,(time (take 39 (map second (iterate (fn [[x y]] [y (+ x y)]) [0 1])))))
00:56clojurebot(1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986)
00:56clojurebot"Elapsed time: 0.873 msecs"
00:56mebaran151alright?
00:57ihodeswell, i feel as though i'm missing something.
00:57mebaran151that it's going that fast?
00:57ihodesmy little fibo fn is orders of magnitude faster than cgrand's
00:57ihodesand i guess rich's too
00:57ihodesyeah…i must be not seeing the whole picture
00:57mebaran151ihodes: his fib's I think were purposefully inefficient
00:58mebaran151they were meant to show how fast math can be
00:58mebaran151because you're using iterate, you're caching the intermediate results (as though you'd memoized the functions)
00:59ihodes"computes (fib 38) on my laptop in 650ms where my (or even Rich’s) best http://clj-me.cgrand.net/2010/06/04/primitive-support-for-fns/"
00:59mebaran151I don't think there's do: it was just a numeric benchmark
00:59ihodes"took 2 seconds"
00:59ihodes(later amended to 800ms)
01:00mebaran151see, his fib is purpsoefully bad
01:00mebaran151he's not trying to make it fast
01:00mebaran151he's trying to make a lot of math ops
01:01mebaran151it's like when people demonstrate the factorial function using recursion: it nicely shows the power of recursion: really a loop is probably a lot more efficient
01:03BahmanHi all!
01:03ihodesmegaran151: haha alright, i figured i was missing something there. thanks
01:08mebaran151no problem
01:09mebaran151this misunderstanding shows the most important part of programming: the right algorithm can beat the most clever compiler every single time
01:09ihodesexactly what i was thinking.
01:10ihodesthough i wish there were an even nicer way to express the fibos than the one i have (above)
01:10mebaran151the iterate seems pretty nice to me
01:10ihodesi know... but mapping second over it... inelegant! haha
01:11mebaran151nah, that's par for the course in functional programming: you have to keep your state in your arguments
01:12mebaran151I think they used exponentially more math ops than you do in the iterate version
01:12mebaran151you could just use plain ol' loop and recur too, but I think the iterate version is a lot nicer
01:13ihodesit's certainly the favorite one of the far too many i've thought up haha
01:14mebaran151you could have also kept some atom local to your function and mutated that to maintain your state, but that wouldn't have been nearly as functional
01:14ihodesmy favorite* but there's got to be some construct that would allow me to drop the mapping
01:14ihodesoh that would've been AWFUL! :P
01:14mebaran151you could probably do it using the lazy-seq macro, but that would be less convenient
01:17ihodestrue, but still a little more complex than before. thank you for the help! i'm off to bed
01:21tomoj,(time (dorun (take 39 (map second (iterate (fn [[x y]] [y (+ x y)]) [0 1])))))
01:21clojurebot"Elapsed time: 1.371 msecs"
01:21bartjtrying to avoid reflection warnings
01:21bartjwhy is this wrong: (map #(String. ^Byte % "UTF-8") (byte-array 100))
01:24tomojthere is no such string constructor
01:24hiredmanhttp://gist.github.com/550864
01:24Chousukedo you really want to transform each byte in the array into a string? :P
01:25bartjChousuke, yes (but the example I give is slightly fake)
01:25hiredman^- totally awesome using interpreter to figure out which classes are referenced, without executing the code and generatng an import list
01:26Chousukebartj: that's weird though. You'll get completely weird results if you have anything but ASCII text :/
01:26mebaran151where did you get generate-imports?
01:26hiredmanI wrote it
01:26mebaran151ah that would be neat to have in IDE to get all the imports upfront
01:26hiredmanbrand spanking new arkham.analytics
01:26bartjok, let me clear myself
01:26hiredmanright
01:27mebaran151what's arkham.analytics (other than an awesome name)
01:27bartjI have a Java byte array and need to get a "UTF-8" string as the output
01:27Chousukebartj: you don't need map for that.
01:27hiredmanhttp://github.com/hiredman/Arkham
01:28Chousukebartj: String has a constructor for byte arrays IIRC.
01:28bartjer, I mean an array of byte-arrays
01:28Chousukeah.
01:28Chousukebartj: if you're getting reflection warnings, hint the arrays as ^bytes
01:29bartjcurrently I do: (map #(String. % "UTF-8") array-of-byte-array)
01:29bartjI tried to use ^Byte to avoid the reflection warnings
01:29Chousukethat specifies the type as Byte, not a byte array :)
01:29Chousuke^bytes is shorthand for a byte array type tag.
01:30ChousukeAt least IIRC :P
01:30tomoj,(meta ^bytes {})
01:30bartjChousuke, gee thanks, what is the longhand ;)
01:30clojurebot{:tag #<core$bytes clojure.core$bytes@1219ee8>}
01:30tomojweird
01:30Chousukehmm
01:30Chousukemaybe not.
01:30hiredmanarkham.analytics can generate the correct import declaration for arkham.core
01:31hiredmanthat may also mean the interpreter can run the interpreter
01:31Chousukeif ^bytes doesn't work try ^"[B"
01:32Chousukehiredman: you need to test that. D:
01:36hiredmandamn
01:36hiredmannope
01:37hiredmanwell I know I am missing deftype*, reify* and set!* support
01:40mebaran151hiredman: it reminds me of Ruby's evil.rb
01:52bartjChousuke, bytes does work, thanks!
03:21LauJensenGood morning all
03:22BahmanMorning LauJensen!
06:35fliebelmorning
06:35esjsalut.
06:35raekgod morgon
07:18vu3rddLauJensen: great blog post!
07:19LauJensenvu3rdd: Wow, thanks! I'm a little out of familiar waters when not blogging about Clojure :)
07:20vu3rddLauJensen: :) I am also always looking to improving productivity and am an emacy guy..
07:21vu3rddBut I like those non-emacs stuff in your blog post the most. I think they are all very important and right on.
07:21LauJensenGreat, thanks
07:22fliebelLauJensen: Where can I find your blog? vu3rdd made me curious.
07:22LauJensenbestinclass.dk
07:22vu3rddhttp://bestinclass.dk/index.clj/2010/08/developer-productivity--the-red-pill.html
07:22fliebelI've seen that url berfore...
07:22LauJensenI think there's almost 35 posts on Clojure, and 2 on misc
07:24LauJensenAnd for those of you using Conkeror, you can browse all posts just hitting ]]
07:29fliebelLauJensen: What is the magic in Conkerer? That's what ships with KDE, right?
07:29LauJensenfliebel: No no no... NO!
07:29LauJensenThats Konqeror
07:30fliebelLauJensen: Ah, you scared me :P
07:30LauJensenConkeror is a webbrowser which adheres to Emacs standards. There's virtually no UI. You hit 'f' to following a link, 'g' to enter a URL, M-x some-command to run arbitrary commands. B to go back, F to go forward etc..
07:30LauJensenIts very, VERY fast
07:30LauJensenIn terms of the UI. Its Mozilla under the hood, so perf like Firefox
07:31fliebelLauJensen: I'm a vin and webkit user ;)
07:31fliebel*vim
07:31bobo_think there is a plugin for firefox that does that, but with vim commands
07:31LauJensenfliebel: Then you will frown upon all talk of productivity :)
07:32fliebel*frowns*
07:34fliebelLauJensen: I'm just reading that your site is 'baked' as you call it. Amazing :)
07:34LauJensenyea its wonderful :)
07:37fliebelLauJensen: But you do run some script to 'log' comments?
07:37LauJensenNo scripts - The submit form sends the comment to the backend where Moustache is waiting for it. Then its sent into a moderation queue, once I approve its directly baked into the html file
07:39fliebelThat is what I mean, you run Moustache at the back to catch the comments.
07:39sparievLauJensen: great post! one question, though - does #clojure channel count as Social network :) ?
07:40fliebelLauJensen: Do you have a search function?
07:40esjspariev: no, too old skool
07:40LauJensenspariev: No
07:40LauJensenfliebel: grep goes a long way when everything is html :)
07:40LauJensenspariev: and thanks :)
07:41fliebelLauJensen: I'd generate a jsonp index and do it all in JS.
07:41LauJensenfliebel: I wouldn't, because I want to use Enlive for reading the data
07:42fliebelLauJensen: ? So how would you do it?
07:42LauJensenfliebel: Its open source
07:43fliebelLauJensen: Where is it?
07:43LauJensenfliebel: Right where the baked blogpost says it is :) http://github.com/LauJensen/bestinclass.dk
07:44fliebelLauJensen: Hadn't reached the bottom yet.
07:44LauJensenSorry, no rush
07:45sparievbtw, any recommendations on tiling wm for windows ? others, than "use Linux" :)
07:45LauJensenspariev: Hmm, no I think you stole my best one :)
07:45sparievheh
07:46LauJensenBut are you planning on doing serious development on Windows? Seriously? :)
07:47sparievwell, I have Ubuntu at home, but have to use Windows at work
07:48sparievgonna try bug.n http://www.autohotkey.net./~joten/
07:49LauJensenSweet, that almost looks like Awesome
07:49esjspariev: i was forced into windows for a while 2 years back, at that time there was no tiling wm.
07:49esjI quit that job after 3 months
07:50esjwindows is too painful
07:51LauJensenTrue, I sympathise esj that you had to go through that
07:52esjseriously, I won't work in a windows shop. period.
07:52cemerickwow, you'd think this was #linux or something :-P
07:53LauJensenhehe
07:53sparievesj: actually, usually I develop remotely on linux servers, but for other MS SQL/Office etc-related work I have to keep windoze on my desktop
07:53LauJensenspariev: ?!!? Its not even policy thats forcing you?
07:53LauJensenWhy dont you jut boot MS SQL, Office etc, under Linux ?
07:53opqdonutcan't you just run a vm
07:53LauJensenThe only thing you cant work your way out of, is policy restrictions
07:59bobo_i dont find windows THAT horrible to work in
08:00opqdonuti find
08:00opqdonutcygwin alleviates it a bit
08:00opqdonutbut the wm is horrible
08:00sparievopqdonut: I considered vm, but stuff I do with MS SQL and our in-house win-only apps are at times resource-heavy and it was dog-slow under vm
08:00cemerickWindows over linux any day of the week here. :-P
08:00fliebelLauJensen: Did I mention defn and I are going to do a 'baker'? that is why I'm so interested in your static site generator.
08:00LauJensenfliebel: No you didn't, what are you baking?
08:01LauJensencemerick: please, if you're going to be unintelligent, please be quiet about it :)
08:02LauJensenthanks
08:02fliebelLauJensen: We're doing about the same as you did. Get our blogs to run on Clojure by writing a baker. With the difference that we're taking a more general approach and that I don't have a VPS to run Moustache on, so it'll be even more static than yours.
08:02cemerickLauJensen: it's a large, wide world. Different strokes for different folks, as they say.
08:03LauJensenfliebel: Great, I will look forward to seeing that, are you open sourcing it ?
08:03fliebelLauJensen: We named it Utterson, after the character in Jekyll(ruby) and Hyde(python). It's on github ;)
08:03LauJensenhehe, alright
08:04LauJensenUtterson... man thats almost as terrible as 'madison', why arent anybody grabbing 'Clabango' ? :)
08:04fliebelLauJensen: I'm thinking about a git based workflow for publishing, possibly using gh pages.
08:05fliebelI'm even trying to come up with something for comments that does not involve running something special on the server, but haven't figured that out yet.
08:05LauJensencemerick: If you fly in for Conj Labs Frankfurt, I'll be happy to help you install Arch
08:06fliebelLauJensen: There are actually Clojure conferences in europe?!
08:06cemerickLauJensen: Thanks, but no thanks. I've had enough desktop linux pain for one lifetime.
08:06LauJensenfliebel: http://conj-labs.eu
08:06fliebelcemerick: How about BSD?
08:06cemerickfliebel: same-same
08:06LauJensencemerick: The pain comes from ignorance, once everything is set up correctly, its a very helpful system to be on
08:07cemerickLauJensen: this is just like our emacs disagreement -- I've better things to do with my time on earth than screw around with window managers and the like
08:07fliebelLauJensen: around €1000 is a bit much for a student like me.
08:07cemericknevermind getting sound cards to work :-(
08:07LauJensencemerick: You're the lumberjack who's too busy to sharpen his axe. So instead of spending 2 days on getting setup, you spent 15 years working at 70% speed
08:08fliebel*thinks cemerick should sing the lumberjack song*
08:09LauJensencemerick: Im not trying to give you a hard time, so if you're working on a hateful rant now, you can save it for later :)
08:09opqdonutI'm not convinced that what works for LauJensen works for everybody
08:09opqdonutbut for me, yes
08:09opqdonutexcept I prefer opera >:)
08:09LauJensenopqdonut: Does it have keyboard browsing?
08:09fliebelcemerick: Don't want to be a Mac fanboy, but I havea working sound card, window manager and Unix power ;)
08:10opqdonutLauJensen: pretty much, yes
08:10fliebelLauJensen: No, mouse gestures ;)
08:10LauJensenhaha
08:10cemerickLauJensen: I'm pretty sure I've never hatefully ranted at anyone. :-(
08:10opqdonutLauJensen: lots of one-key shortcuts, navigating with the keyboard is easy
08:10LauJensencemerick: Im glad - I just wanted you to know that it wasnt personal, just in case you were warming up :)
08:10opqdonut, starts a search for links
08:10clojurebotjava.lang.Exception: Unable to resolve symbol: starts in this context
08:10opqdonutso mostly I just navigate with ,<typesomething><return>
08:11LauJensenI particularily like how 'f' searches both for links and input fields
08:12fliebelLauJensen: http://github.com/pepijndevos/utterson There is and 'old' branch, containing our previous efforts. We both walked off, met yesterday and started over with a clean slate :)
08:12LauJensenOuch :)
08:13fliebelLauJensen: So there is a workish generator in 'old', an not very much in 'master', but 'master' is going to be awesome.
08:13LauJensenAre you guys using Enlive templates to generate the html ?
08:14fliebelLauJensen: 'old' is using the [html [head]] thingy from contrib, the new one… enlive if it depends one me.
08:14fliebelLauJensen: Enlive is like DOM for Clojrue, right?
08:15LauJensenOk - I dont think I could recommend any Clojure lib more than Enlive at the moment, its that good
08:15LauJensenfliebel: Enlive is 2 things. 1) Selectors that work like CSS selectors, and 2) Templates which allows you to transform data into html using those selectors
08:15fliebelLauJensen: Do you write posts in Markdown, Textile, plain HTML or something else?
08:15LauJensenIt was a couple of relatively simple (take 'relatively' loosly), that allowed me to import my entire Wordpress blog into html
08:16LauJensenfliebel: I write them in a nice WYSIWYG editor
08:16fliebelLauJensen: What?! You? a productivity emacs guru? :P
08:17LauJensenYes ma'am
08:17LauJensencemerick made me :(
08:18fliebelMy blog is currently on Posterous, but I find myself writing posts in markdown all the time, becasue wysiwyg editors screw up my html. especially things containing code.
08:18LauJensenWell, it helps when you write the stuff yourself
08:19LauJensenYou can install bestinclass locally and launch the admin.clj file to bring up the admin interfaces, browse to /editor to make a blogpost, hit submit to send it to moderation in /admin
08:20fliebelLauJensen: Ah! so you wrote a wysiwyg editor with emacs keybindings? Or just plain old… what's the WP thing called...
08:20fliebeltinymce
08:20LauJensenfliebel: No I use the ckeditor, but I parse the results myself (not doing much to it), and the emacs keyboard bindings I get for free since I use Conkeror
08:21fliebelLauJensen: Okay, you win… I still prefer Markdown though.
08:21LauJensenI might prefer it aswell after seeing Utterson
08:22fliebelLauJensen: Are you runnign bestinklass.tk on a private server?
08:23LauJensenI have no association with bestinklass.tk
08:23fliebel*bestinclass.dk
08:23LauJensenoh, yes thats on a personal server
08:24LauJensenBut I suppose GAE could be used if you wanted to
08:24LauJensenThe only thing which is very non-general about my solution is its commitment to nginx - You need to run on a linux host (ofc) and you need to have the default logging module enabled
08:24fliebelLauJensen: That is something… Can you run any ring app on GAE's java api?
08:25LauJensenI would think so
08:25LauJensen(haven't tried)
08:25LauJensenThere are a few annoying restrictions like no threading, no concurrency semantics
08:25esjseduced by the power of the dark screen he has become....
08:26fliebelLauJensen: Maybe only run a comments module on GAE, and keep the rest safe and warm on my local computer.
08:27fliebelMight even poke that together with Python...
08:27LauJensenfliebel: Yea, I considered outsourcing comments to DISQUS, but I think my solution is more elegant.
08:27LauJensenYou would have to modify the queue though, as its actually handled by an agent right now, but that should only be a small workaround
08:27sunkencityrylehI've run clojure on appengine but I've found the environment being a little too much work to get to run smoothly
08:28LauJensenSomething like a comments engine could nearly run on a C64, theres no work involved
08:28fliebelLauJensen: DISQUS had spam in its sample form when I last looked, so I'm not trusting them. Your solution is very elegant if you have access to a good server.
08:29fliebelgood server != shared php host
08:29LauJensengood rule of thumb :)
08:29LauJensenI didn't know about the spam, scary
08:29LauJensenThey are in wide use
08:30fliebelLauJensen: Maybe I'll device something with Twitter or Facebook to handle my comments :D I've also thought about merging gists and other crazy things.
08:30LauJensenoh no :(
08:31fliebelLauJensen: Yea, that's bad :(
08:32fliebelLauJensen: I think the gist idea is rather interesting, but not very workable.
08:32@chouserI've had knocking around in my head ideas for a sort of split server for blogs and websites, where the bulk of the content is handled by a static server, whose content is regenerated on demand (such as when a comment is posted) by somethat that can be slower to start (like GAE) or sometimes unavailable (like a server at home)
08:34LauJensenfliebel: I think its a little like stealing their capacity
08:35fliebelLauJensen: It is, and it wouldn't work anyway.
08:35LauJensenchouser: I have actually pondered a system like that myself
08:36fliebelLauJensen: I f you find an mbox parser for Java, you could handle comments by email :)
08:37LauJensenfliebel: hmm, thats not a bad idea. Just use maildir instead and you've got plaintext
08:37LauJensenActually that would be super simple to set up
08:37LauJensenJust configure a dovecot to receive and distribute
08:38mrBlissIf anyone's interested, here are my dotfiles (Emacs, Conkeror, Zsh etc) http://github.com/mrBliss/dotfiles
08:38LauJensenmrBliss: Thanks
08:38fliebelLauJensen: Even my PHP host has an email server built in. Just need to fetch and parse them.
08:40LauJensenyea, so fetchmail works with maildir I believe
08:43fliebelLauJensen: The interesting thing is how to match mails to posts.
08:44LauJensenShouldnt be a problem
08:44LauJensenI dont recall how I do it now, but I wouldnt be surprised if I just inspect the referer field in the header of the POST request
08:46fliebelLauJensen: emails don't have a referrer, do they? or are we talking about different things?
08:46LauJensenNo they dont, but Im just saying, but the info in the email somewhere and scan for it, emails have headers as well
08:48fliebelLauJensen: Tell me about it… :S They have a message ID and a lot of crap about through which servers it traveled.
08:49fliebelLauJensen: You could of course put something in the subject line to identify the post.
08:50@chouserI think you can put a subject in a mailto: url
08:50LauJensenyea
08:50LauJensenand body as well
08:50fliebelchouser: Yea, you can put a whole lot of gunk in the mailto url.
08:51LauJensenbut anyway, its a non-problem
08:51fliebelI agree
08:52@chouserthe biggest issue with comments, I think, is spam.
08:52LauJensenchouser: I haven't had a single spam comment since I added the lisp captcha
08:52LauJensenAnd I had ... MANY ... before :)
08:53fliebelSecurity trough obscurity is something when you write captchas ;)
08:54LauJensenIf it works, it works :)
08:54LauJensenAnd since its a lisp specific captcha, I can do more of the language comparisons without getting any flame :)
08:54fliebelMillions of spam bots are programmed to spam wordpress blogs and circumvent re-captcha and akismet. No soe many attack bestinclass.dk
08:55fliebel(the platform, not the specific blog)
08:57fliebel*waiting for defn to get started*
08:57raekI get a "dot already refers to: #'net.licenser.sandbox/dot in namespace: se.raek.trattern" when I try to re-evaluate the ns declaration of the namespace se.raek.trattern
08:58raekanyone else have this problem?
08:58LauJensenfogus: thanks for putting my article on HN :)
08:58fliebel*votes*
08:59LauJensen*thanks* :)
08:59fliebel*gets lost in reading HN*
09:06alekx1. what is the essential tool set for a clojure-man?
09:06alekx2. is there a Sinatra-like web framework in Clojure?
09:06MrHusalekx: compojure
09:06alekx(newbie questions for learning purposes)
09:06LauJensenwow, 4 points and Im already #5 on HN frontpage :) thanks guys
09:07MrHushttp://github.com/weavejester/compojure
09:07LauJensenalekx: A very minilistic and interesting web framework is Moustache, be sure to check it out
09:07fliebelLauJensen: I suppose it multiplies points by the inverse time since the submit, or something like that :P
09:07alekxLauJensen: is it that "Mustache"
09:08LauJensenHmm
09:08fliebelalekx: No, that is a templating engine
09:08LauJensenhttp://github.com/cgrand/moustache
09:08alekxhttp://mustache.github.com/
09:08LauJensennono alekx, http://github.com/cgrand/moustache
09:09alekxgot it... so I got compojure (heard of it before) and moustache... that's good enough for now
09:09alekxwhat about the "toolkit"?
09:09fliebelalekx: Dangerous questing with all these vim and emacs people in one chanel ;) haha
09:09alekxare there any essential tools that would be recommended to have around? right now I'm just using clojure w/ jline
09:10MrHusalekx: leiningen is a must
09:10MrHushttp://github.com/technomancy/leiningen
09:10alekxI know... I've tried to avoid any mentions of editors/IDEs/etc.
09:11alekxleiningen is sort of Ant + Maven, right?
09:11fliebelI personally have nothing but clojure, contrib, leiningen and a modal editor ;)
09:11MrHusalekx: correct
09:11fliebelHow about a nice debugger?
09:12alekxI hope IntelliJ will help me there... but being at the beginning I'm not really sure I need it so soon
09:12MrHusfliebel: Are the nice clojure stacktraces not enough.
09:12zmila,(apply * [])
09:12clojurebot1
09:13alekxis there a link to the core/contrib APIs?
09:13MrHushttp://richhickey.github.com/clojure-contrib/
09:13fliebelIt;s right on the homepage I think, or most of the time on top of google.
09:14alekxthe format probably tricked me :-)
09:14alekxthanks
09:14raekhttp://clojure.github.com/clojure-contrib/ is the new page
09:15raekthe official repository is now at github.com/clojure (was at github.com/richhickey before)
09:16LauJensenalekx: A good slime setup and jvisualvm takes you a looong way
09:16LauJensenIn terms of debugging
09:16alekxslime?
09:16clojurebotslime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72
09:16n2n3,()
09:16clojurebot()
09:16LauJensenalekx: Slime is SUPER LIST INTEGRATION MODE for EMACS
09:16LauJensens/SUPER/SUPERIOR/
09:16sexpbotalekx: Slime is SUPERIOR LIST INTEGRATION MODE for EMACS
09:17LauJensen:)
09:17alekxlooks like the discussion is going the direction I wanted to avoid initially :)
09:17LauJensenalekx: With it, you get to set breakpoints in your code, inspect locals, lookup source code, etc etc
09:17LauJensenOh sorry, go on :)
09:17mrBlissLauJensen: wikipedia tells me it is Superior Lisp Interaction Mode for Emacs ;-)
09:17alekxI suck at emacs... used with new fancy IDEs and vim
09:17LauJensenmrBliss: :(
09:18raekalekx: what was compojure 0.3 is now (well basically, at least) split up into Ring (middleware and servlet containers), Hiccup (HTML generation) and Compojure 0.4 (Routing)
09:18LauJensenalekx: I sucked at Clojure once, didnt stop my progress though :)
09:18LauJensenraek: Clout as well?
09:18alekxand I guess I'll be sticking with those for now...
09:18raekMoustache is a small and well documented routing lib, really recommend it
09:19raekhrm, what did clout do again?
09:19mrBlissalekx: I have been tweaking my tools non stop since I started with Clojure (13 months ago)
09:19alekxI guess it's one thing to suck at a language and another to an env/editor/etc
09:19MrHusI don't agree with emacs for a beginner, there's just to much to lean before you can even start with clojure.
09:19LauJensenWow, Im #1 on HN now :)
09:19LauJensen:)
09:20n2n3and there's a slimv.vim
09:20alekxanyways... no religious/vim vs emacs/vegan vs non-vegan flamewars for me :D
09:20fogusLauJensen: No problem. I liked it.
09:20raekok, so if compojure routing was split off into clout (correct?), what is left in compojure then?
09:21LauJensenfogus: I appreciate any and all help I can get, to help spread the FUD :)
09:21MrHusraek: glue code
09:21LauJensenraek: A list of imports and a little routing helper I think
09:21raekright.
09:22LauJensenSo again, learning both Moustache and Enlive is seriously well spent time
09:22MrHusI just hope ring gets to be de defacto standard, its really easy to make a small framework around it.
09:23LauJensenMrHus: It already is
09:23LauJensenBoth Compojure, Conjure and Moustache rest fully on Ring
09:23fliebelIt would be nice to have some heroku-style ring hosting...
09:23mrBlissWhat's the best way to interact with PostgreSQL from Clojure?
09:24fliebelLauJensen: Do you know anything about aleph + ring?
09:24LauJensenfliebel: A little
09:25LauJensenmrBliss: I recommend trying contrib.sql, theres a wiki page that shows how with psql
09:25MrHushttp://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#DataSource_-_PostgreSQL
09:25LauJensenWhich my lovely assistant just fetched for you
09:25fliebelLauJensen: Just wanted to know their relation.
09:26LauJensenfliebel: alpeh uses Netty and not ring as far as I know
09:26mrBlissLauJensen & MrHus: thanks, btw Lau, what's gonna happen with ClojureQL?
09:26fliebelLauJensen: But you could maybe run Ring apps on Aleph ;)
09:26LauJensenmrBliss: Im thinking very seriously abou that right now
09:27LauJensenI think, I hope, that I'll find the time before new years to push it into 1.0, in which case you will have the worlds finest interface to mysql, psql and derby, which is easy to extend to any number of backends
09:27LauJensenBut Im pressed on time, the crew has been released. Time will tell
09:27mrBlissLauJensen: Looking forward to it
09:27LauJensenYea me too. Its frustrating that I have so little time for it, because truthfully its a fantastic project
09:28mrBlissLauJensen: It's ok if you spend your time on writing blogposts abouts Emacs or Clojure ;-)
09:29LauJensenhaha, thanks
09:29fliebelLauJensen: Do you have anything in mind for noSQL? or is i SQL only?
09:29LauJensenfliebel: Meikel had almost completed Mongo integration and FleetDB is already supported
09:30LauJensenWhich was one of the things that caused a slowdown - We were eager to work with nosql, but it required us to split the codebase
09:31fliebelinteresting...
09:32LauJensenIf anybody wants to donate about $5000 I'd be happy to wrap it up and tie a bow around it :)
09:32fliebelI still need to take a closer look at FleetDB. So far the only noSQL I've done is CouchDB.
09:33LauJensenI gotta jet, bbl
09:33LauJensenAnd thanks for all the upvotes guys
09:33fliebel:)
09:34fliebelWhen you use FleetDB in Clojure, do you talk via the server, or directly to the Clojure code?
09:36alekxLauJensen: at 1st glance I don't like Enlive... I think HTML code should stay HTML
09:36MrHusalekx: shameless self plug: http://github.com/MrHus/Hadouken
09:37mrBlissalekx: would you rather mix HTML with Clojure like those but ugly php scripts
09:37mrBliss(no offense intended for templating systems, yes offense for php ;-)
09:38MrHusmrBliss: php is great :p
09:39mrBlissMrHus: imho it's like using notepad instead of Emacs ;-)
09:40MrHussure its has stupid function names with weird parameter's. No one ever knows where the haystack is.
09:40MrHusBut it has great documentation. And it runs everywhere.
09:40alekxmrBliss: it doesn't need to be completely messy... there are good templating engines out there
09:41MrHusPlus notepad beats emacs every day :P
09:41mrBlissMrHus: lol
09:42MrHusimho emacs is absolutely horrible, I can barely tolerate aquaemacs
09:42mrBlissMrHus: which editor do you use then?
09:42MrHustextmate
09:43sid3kLauJensen: you've a very nice website, I'm going to follow it
09:43mrBlissMrHus: mmm, and on windows and Linux?
09:43MrHusbut i don't use any fance features anyway.
09:43sid3kthanks for the latest post btw
09:43MrHusnotepad++
09:43MrHusredcar
09:43mrBlissMrHus: Do you write Clojure in notepad++?
09:44MrHusIf i need to yes.
09:44MrHusOr e text editor
09:44MrHuson windows
09:44mrBlissYeah, the textmate for windows
09:44mrBlissDoes it have a builtin repl?
09:45MrHusnope
09:45MrHusI use terminal
09:45MrHusand lein repl mostely
09:45mrBlissDoes lein repl have history (select previous input etc)?
09:45MrHusyes
09:45jkkramerdo any of those editors have lisp indentation yet?
09:45clojurebotLisp isn't a language, it's a building material.
09:46MrHusAlan Kay
09:47mrBlissI don't know textmate very well, but can you do everything with your keyboard?
09:47MrHusmrBliss: http://redcareditor.com/screenshots/
09:47MrHusredcar is textmate for linux
09:47MrHusbut you can do everything by keyboard
09:47raekwas there any consensus on what the word for "clojure programmer" is, btw? Clojurian? Clojurist? Clojeur?
09:48MrHusthe real power lies in the snippet though
09:48mrBlissClojurian
09:48mrBlissI like CLojeur
09:48raekme too
09:48MrHusClojurians
09:48MrHushttp://first.clojure-conj.org/
09:48MrHusnear the bottom
09:49mrBlissMrHus: isn't Redcar horribly slow (written in ruby)
09:49MrHusI have to admit I'm a mac guy
09:49MrHusso I dont use linux that much anyway
09:50mrBlissI have a MBP too
09:50raekit would be fun if Clojure would have a super hero mascot called "Sir Clojeur"...
09:50MrHusWhats the default notepad on linux anyway, i cant remember its name
09:50mrBlissGedit for gnome
09:51MrHusgedit
09:51MrHusthat one
09:51MrHusWhat linux are you running
09:51raeksyntax hilighting for clojure was recently added to gedit
09:51fliebelraek: Really? nice!
09:51mrBlissCurrently Windows 7! Programming happens in a Ubuntu 10.04 VM
09:52raekhttp://groups.google.com/group/clojure/browse_thread/thread/f2f698c594c84bbf/9b15b243fdfccbd5?lnk=raot
09:52MrHusDoes arch linux have clojure support?
09:52mrBlissLike ubuntu?
09:52raekclojure really only depends on a java runtime
09:53MrHusbut as a package
09:53vsthesquareshey guys, how do I get leiningen to compile all the files in my src tree?
09:54mrBlissMrHus: nope: http://www.archlinux.org/packages/?q=clojure
09:54mrBlissvsthesquares: $ lein compile
09:54raekI think clojure os packages aren't used that much
09:54raekleiningen takes care of downloading the correct clojure version
09:54vsthesquaresmrBliss: it skips files that are in subdirs of src
09:54raekwhich might be different from project to project
09:55mrBlissvsthesquares: you prolly need the gen-class directive in your ns declaration
09:55mrBlissvsthesquares: why do you want them compiled?
09:55raekthat depends on if he wants to generate custom java classes or not
09:56vsthesquaresmrBliss: because otherwise main file won't compile
09:56raekI think one might have to add a :aot directive in the project.clj
09:56mrBlisshttp://github.com/technomancy/leiningen/blob/master/sample.project.clj#L60
09:56MrHusvsthesquares: are you trying to create a jar?
09:56vsthesquaresyes, most certainly
09:57vsthesquaresyou need :aot directive for building jars?
09:57mrBlissno
09:57MrHuslein jar or lein uberjar
09:57mrBlisslook at Uberjar on this page: http://github.com/technomancy/leiningen/blob/master/TUTORIAL.md
09:57MrHuslein uberjar creates a stand alone jar
09:57MrHuswith clojure included sort of speak
09:57vsthesquaresalright
09:57cemerickfliebel: just noticed the blogging software discussion earlier; I've found wordpress.com very pleasant, including clojure code highlighting (via syntaxhighlighter)
09:57vsthesquareswill look through those docs, thanks guys
09:58raek:aot is for choosing which namespaces that should be ahead-of-time compiled
09:58vsthesquaresoh ok
09:58raek:main could be relevant too
09:58vsthesquaresi got that figured out
09:59vsthesquaresbut when lein tries to compile main, it says it can't find some class files
09:59vsthesquareswhich is logical, because it hasn't compiled them
09:59MrHuslein jar compiles for you
10:00mrBlissvsthesquares: are your namespace names correct
10:00MrHuscan you pastebin your code
10:00mrBlissfoo.bar for src/foo/bar.clj
10:00MrHusmight help
10:02vsthesquaresmrBliss: okay, i got my namespaces messed up
10:02vsthesquaresthat should fix it
10:02MrHusplease let us know
10:02fliebelWhat is the best Markdown solution I can get for Clojure? I found 3 possible options so far: MarkdownJ, Showdown+Rhino and Pegdown.
10:04mrBlissI'm gonna go for pegdown for my own blog
10:06mrBlissLast version of markdownj is from Oct 2008, pegdown 13 Aug 2010
10:06fliebelmrBliss: Did you manage to get it from Leiningen?
10:06jkkramerfliebel: had a pretty painless experience using markdownj. it's on clojars
10:06jkkramerpegdown looks pretty nifty, though
10:07fliebeljkkramer: I used Markq
10:07fliebeldownj for awehil
10:07fliebel*screws up typing*
10:07mrBlissfliebel: I haven't actually used it, but: http://clojars.org/search?q=pegdown
10:07polypusgiven a leiningen project P, with a jar Q as a dev dependency, and that jar has dev dep R, will R be pulled into lib/dev if i do a lein deps in P?
10:07vsthesquaresokay, so I guess dash in namespaces translates to underscores on the filesystem
10:07vsthesquaresthanks guys
10:07vsthesquaresproblem solved
10:08fliebeljkkramer: MarkdownJ works fine, but it uses regex, which busts the stack on Java for large files.
10:12raekpolypus: yes
10:12notsonerdysunnyHi everybody, I am trying to use " lein native-deps " ... Assuming that I might not be using it right i tried it on rincanter(just to test native-deps) .. and I get the following error.. "Caused by: java.lang.IllegalAccessError: make-dependency does not exist" does anybody have a suggestion?
10:12notsonerdysunnyLeiningen 1.3.0 on Java 1.6.0_17 Java HotSpot(TM) Client VM
10:13dnolennotsonerdysunny: huh, native-deps 1.0.2 ?
10:13notsonerdysunny [native-deps "1.0.2"]
10:13notsonerdysunnydnolen: yea right
10:13dnolennotsonerdysunny: darn, been busy, I guess my fix wasn't enough. lein 1.3.0 shuffled a few things around.
10:14dnolennotsonerdysunny: will look into that.
10:14fliebeluh-oh… what does a clojure comment look like? not # not // … lost
10:14notsonerdysunnyoh thanks dnolen
10:14pdk; fliebel
10:15notsonerdysunnydnolen: do you think going to lein 1.2.0 will solve the problem?
10:16fliebelHow can I get a package updated on clojars?
10:16dnolennotsonerdysunny: 1.2.0 will probably work with native-deps 1.0.1
10:16notsonerdysunnydnolen: k will try that ..
10:16MrHusfliebel change your version and push again
10:17fliebelMrHus: I mean, a package someone else pushed to clojars.
10:17mrBlissfliebel: you can make your own account and update his package
10:17mrBlissI've seen it happen in the past
10:17dnolennotsonerdysunny: oh if you're feeling extra nice (and it's probably the same amount of work), you could figure out what the deal is with native-deps and send me a pathch :D native-deps is only like ~20 lines of code.
10:18mrBlissfliebel: like lein-javac: three versions on clojars
10:19mrBlissfliebel: http://clojars.org/lein-javac and http://clojars.org/org.clojars.neotyk/lein-javac (and some others)
10:19polypusraek: ty
10:19fliebelmrBliss: That's not very nice...
10:19notsonerdysunnydnolen: I will see what I can do .. I am all new to this java and jar stuff .. and jna .. If I can do some thing I will send you the patch
10:20mrBlissfliebel: it's not very nice of the authors when they don't update their package on clojars ;-)
10:21dnolennotsonerdysunny: thx! ... native-deps isn't very fancy. all it does is unjar the native dependencies jar into the right place. the bug is that lein fns got moved to different namespaces.
10:25MrHusdnolen: make-dependency is now in leiningen.util.maven
10:28MrHusdnolen same for make-repository
10:29BahmanHi all!
10:31dnolenMrHus: thx
10:44fliebelHow can I run the clj repl with all lein deps on the cp?
10:46bobo_fliebel: lein repl?
10:46fliebelbobo: wow, nice :)
10:46bobo_sometimes its to easy :-)
10:47fliebelnah, can't be to easy. Only frustrating to overlook it all the time :P
10:47fliebelrepl is not even listed in help: pom
10:47fliebel help
10:47fliebel upgrade
10:47fliebel install
10:47fliebel jar
10:47fliebel test
10:47fliebel deps
10:47fliebel uberjar
10:47fliebel clean
10:47fliebel compile
10:47fliebel version
10:47fliebel new
10:47@chouserplease don't do that.
10:48fliebelchouser: Did that come across as a dozen messages? at my end it looks like one
10:48dnolennative-deps 1.0.3 on github now, clojars later today.
10:48@chouserfliebel: IRC doesn't support newlines inside a single message
10:48@chouserfliebel: so yes, a dozen messages
10:48fliebelchouser: I'm sorry
10:49@chouserfliebel: I forgive you.
10:49@chouser:-)
11:00fliebelbobo: the lein repl doesn't seem to work properly. I still can't import pegdown.
11:03mrBlissfliebel: how do you import pegdown?
11:05fliebelmrBliss: (import (org.pegdown PegDownProcessor))
11:06LauJensensid3k: thanks :)
11:07mrBlissfliebel: maybe you forgot the quote (import '(org.pegdown PegDownProcessor))
11:08fliebelmrBliss: Still the same java.lang.ClassNotFoundException: org.pegdown.PegDownProcessor (NO_SOURCE_FILE:3)
11:08mrBlissfliebel: I'm gonna try it out now (with cljr)
11:09mrBlissfliebel: I just tried it and it worked
11:10mrBlissfliebel: can you paste the output of lein classpath
11:10mrBlissfliebel: or check if pegdown is on your classpath
11:10fliebelmrBliss: classpath is not a task. Use "help" to list all tasks.
11:12mrBlissfliebel: which version of leiningen are you using (1.3.0 is the latest)
11:12fliebelmrBliss: Leiningen 1.1.0 :$
11:13mrBlissfliebel: you now what to do ;-)
11:14mrBlisss/now/know
11:16fliebelmrBliss: Yea, I got it from MacPorts :s Can lein upgrade itself, or do I need to get a frsh version from somewhere else?
11:17mrBlissfliebel: lein upgrade
11:17fliebelmrBliss: Guess what… upgrade is not a task. Use "help" to list all tasks.
11:17LauJensenAny of the Cake authors in here now?
11:18mrBlissfliebel: you should install it manually than
11:19mrBlissfliebel: replace your current lein script with http://github.com/technomancy/leiningen/raw/stable/bin/lein (chmod +x it) and run lein self-install
11:19fliebelmrBliss: How about this? curl http://github.com/technomancy/leiningen/raw/master/bin/lein | sh
11:22jlf`technomancy: btw, `lein new' doesn't terminate the last line of the defproject form in project.clj with a newline
11:22mrBlissfliebel: $ which lein to see where you're current lein is located
11:23fliebelmrBliss: It's located in .Trash now I'm afraid ;)
11:24mrBlissfliebel: cd /opt/local/bin; sudo wget <the mentioned url>; sudo chmod +x lein; ./lein self-install
11:24fliebelmrBliss: I'm busy already :)
11:24mrBlissfliebel: let me know if it solved your problem
11:25arohneris there a function to remove several keys from a map at the same time?
11:25fliebelmrBliss: I don't get the lein installation… I download a file, run install, and the have the same file(name)
11:26arohner(dissoc-multi m [:a :b :c])
11:27MayDanieldissoc can do that.
11:27mrBlissfliebel: it downloads a jar containing the real leiningen in ~/.m2/...
11:31fliebelmrBliss: I think it works!
11:32mrBlissfliebel: good work
11:32arohnerMayDaniel: oh, thanks. I should read the doc string more often...
11:33fliebelmrBliss: well, almost :( after running a command I can't get back my prompt.
11:34fliebelah, I can
11:35jlf`is there a cli for searching for clojar libraries and adding them to project.clj? maybe a lein plugin or somesuch?
11:36mrBlissjlf`: lein-search?
11:37Raynescljr has search capabilities built in as well.
11:38jlf`thanks
11:40ninjuddLauJensen: i'm here for a few minutes
11:41LauJensenninjudd: I gotta go though, so we can catch up later
11:42ninjuddLauJensen: i'll be around all day starting in about 2 hours
11:44jlf`is there a way to specify additional default dependencies and dev-dependencies for new lein projects?
11:47mrBlissjlf`: no easy way
11:48fliebelIs there any definitive guide to getting vimclojure set up with leiningen?
11:48fliebelI found a lot, but all of them are different.
11:48jlf`hmm, so lein-search must be manually added to each project for the clojar search functionality to be available in that project?
11:50mrBlissjlf`: http://github.com/technomancy/leiningen/blob/master/NEWS#L36 (I haven't tried it out yet)
11:51jlf`mrBliss: thanks, i'll check that out
11:56Bjering50000k clients, jvm CPU usage, 2% :)
11:56Bjeringeh
11:56Bjering50k I mean ;)
11:59jkkramerBjering: nice, planning to blog or post code about your adventure?
12:00danlarkinwhat kind of clients?
12:02ChousukeBjering: You had worse results earlier, didn't you? What did you do to make it better?
12:02BjeringChousuke, I switched to JDK7 and Nio.2
12:03ChousukeOh, cool.
12:03Bjeringdanlarkin: Chat bots, they say something every 1-10 sec
12:03ChousukeBjering: so it's on par with the C++ version now?
12:03BjeringChousuke, it _works_ on windows. It was the selector based "old NIO" that had horrible performance on windows.
12:04danlarkinBjering: using netty? or rolled your own NIO crud?
12:04BjeringChousuke: Yes, though one caveat still, its Java now, but I am sure my clojure code will be just as fast now that I am ready. (Write in java first as to follow the NIO.2 samples I saw easier)
12:05Bjeringdanlarkin, my own, as I couldnt wrap my head around Grizzly and netty dont have NIO.2
12:05technomancyclojurebot: forget slime-install
12:05clojurebotTitim gan éirí ort.
12:07technomancyjlf: nice catch; thanks
12:13Bjering_hmm :( Something is wrong. After a few minutes it totally hung my system.
12:15LauJensenBjering_: I just dropped in - How did you get the JVM to perform like the C++ ?
12:15Bjering_By using NIO.2 on windows
12:15Bjering_ie the stuff that maps to IOCP
12:15LauJensenOk, great
12:16Bjering_That is the same OS tech used by my C++ solution.
12:16LauJensenHow did you hook into NIO.2 from Clojure?
12:16Bjering_havent done that yet, it was the Java version
12:16LauJensenoh
12:16Bjering_but earlier tests suggested bottleneck was all javas selector.
12:16LauJensenSo next up from you is a wrapper-lib I assume? :)
12:17Bjering_yes, and perhaps when I do that I can think it through and find the bad bug that killed my system.
12:17LauJensenk
12:17Bjering_I suspect it has todo with memory, still far from the C++ one there, 1.6Gb vs 100MB.
12:18LauJensenBjering_: Optimizing functional code usually boils down to one word: Allocation
12:19LauJensenAnd by boiling down I mean, removing reflection, getting to the primitives, etc..
12:20Bjering_Well, it the same in C++, key there is pretty much to is to never ever allocate memory... use the stack, and if that fails use your own custom mem-pool. Now I understand I need to let go of that thinking and find new ways in the jvm way.
12:20technomancyLauJensen: nice post ... except for the part about paredit. when are you going to come into the 21st century with us? =)
12:21hiredmantechnomancy: you see http://gist.github.com/550864?
12:22danlarkinhiredman: I saw, and I did an :-o
12:22technomancyhiredman: zomg
12:22technomancymy hat, sir. it is off to you.
12:23hiredmanit's not perfect (yet)
12:26Raynes:-o
12:31fliebelhiredman: what's that gist about?
12:33arkhdoes anybody know any examples using seque?
12:33hiredmanuses arkham (clojure interpreter) to trace clojure code without executing it, and generate imports for the classes you use
12:43raekhrm, auto complete messed up my slime
12:44raekit made the buffer-namespace association not work, so that when I evaled things in foo.clj (after having evaled (ns foo)) the defs ended up in user
12:50slyrustechnomancy: URL for LauJensen's post you're talking about?
13:15LauJensentechnomancy: hehe :) One day we'll sit down together, and you can show me why you love it
13:15LauJensenslyrus: http://news.ycombinator.com/item?id=1635764
13:15LauJensenIts quite crazy how much interest that post gathered, I posted it about 4 hours ago and the site has been hit over 10.000 times already
13:16raekis there any way of stopping servlet containers to add "; charset=iso-8859-1" to the Content-Type header?
13:16mefestoi read that post this morning and thought it was really good :)
13:16mrBlissLauJensen: have you got a graph of the 'HN effect'?
13:16mefestoalthough i can't give up coffee :(
13:16LauJensenthanks mefesto :)
13:16mefestothe headaches are too much for me :-\
13:16LauJensenmrBliss: No I just count hits in my interface, hits and referrers
13:17LauJensenmefesto: The headaches just made me more determined, I refuse to have anything have power over me
13:17LauJensenBut man they were bad :)
13:17LauJensenEven up until like the 13.th day or so, they could almost cripple me
13:18mefestoYeah, I kicked coffee a while ago for 6 months, then somehow it got me again
13:24esjLauJensen: yeah, the headaches are the worst
13:27ChousukeI haven't even bothered trying to give up coffee :P Properly brewed coffee actually tastes good.
13:28Chousuke(I don't use sugar or milk either)
13:29LauJensenWorkwise what I hated the most, was getting up, having my coffee and then working effectively for 1.5 - 2 hours, then feeling the slow-down, having to get a new batch. I cant say I'll ever want to go back to that
13:38LauJensenIs there a variable in the JVM someone, which will tell me if theres an active internet connection on all OSs?
13:40jfieldswhat do you do for dissoc-in? update-in with dissoc?
13:40@chouserjfields: yeah
13:41jfieldschouser, thanks.
13:41mefestoLauJensen: java.net.NetworkInterface.isUp() ?
13:41mefestohttp://download.oracle.com/javase/6/docs/api/java/net/NetworkInterface.html
13:42LauJensenmefesto: didn't know about that one, thanks
13:42LauJensenI wonder when I'll get used to those docs being on oracle.com...
13:49neotykHi *, Why do I get "WARNING: promise already refers to: #'clojure.core/promise in namespace: async.http.client.test, being replaced by: #'async.http.client.util/promise"?
13:50neotykok, I had (refer-clojure .. in my (ns, instead (:refer-clojure
13:50neotykthanks :)
13:52LauJensennp
13:58LauJensen,(enumeration-seq (java.net.NetworkInterface/getNetworkInterfaces))
13:58clojurebot(#<NetworkInterface name:tap0 (tap0) index: 4 addresses: > #<NetworkInterface name:lo0 (lo0) index: 3 addresses: > #<NetworkInterface name:xl0 (xl0) index: 1 addresses: >)
13:58LauJensen,(map #(.isUp %) (enumeration-seq (java.net.NetworkInterface/getNetworkInterfaces)))
13:58clojurebot(true true true)
13:59LauJensenits all true..
14:06mefestoLauJensen: is that good or no?
14:06mefestoLauJensen: I just did an ifdown eth0 and ran that and it reported false as expected
14:07LauJensenyea its good. You cant rely on just filtering out the first interface which is up, since lo count as such
14:07mefestoyou can filter out lo using the isLoopback property
14:07LauJensenoh right
14:08mefesto(filter #(not (.isLoopback %)) ifaces)
14:09mefestoAnyone know if there is a good swt clojure wrapper somewhere?
14:11@chousereven if all the interfaces are, doesn't mean you have an ip address or are connected to anything
14:11@chouserperhaps you just want to ping some server?"
14:11fliebelHas anyone seen defn today? (I think clojurebot might be able to tell me that)
14:12@chouser~seen defn?
14:12clojurebotdefn was last seen in #clojure, 1712 minutes ago saying: http://copperthoughts.com/p/the-golden-ratio-is-evil/
14:12hiredman,(/ 1712 60)
14:12clojurebot428/15
14:12hiredman,(int (/ 1712 60))
14:12clojurebot28
14:13fliebelchouser: Does clojurebot have a manual?
14:13@chouserfliebel: yep. his name is hiredman
14:14fliebelhttp://github.com/hiredman/clojurebot
14:14danlarkinBjering: what about NIO.2 did you find necessary? Over non-2 NIO I mean
14:15Bjeringdanlarking, It seems on windows "old-NIO" is using select, which works very poorly on windows. Windows high performance network should use IOCP.
14:16Bjeringdanlarking, but there might be some switch to make it work, I mean they have made NIO providers extendable etc, I am just to poor at the Java infrastructure to find it.
14:16danlarkinBjering: ah, ok
14:19BjeringWell I think/hope I am done with the fiddly OS-related issues now and can focus on the fun (and on topic!) part, that is to learn how to wrap it up in good clojure code.
14:21danlarkindo you happen to know if nio2 is on the netty roadmap? I've used netty and I quite like its abstractions -- you too might find them useful
14:21BjeringA naming question, ctor-like functions, that builds an "identity", is there a standard way of naming these? Should it be create-acceptor or make-acceptor or just create or make in the acceptor namespace?
14:22Bjeringdanlarking: I did, they are great, not their fault it didnt work so well on my windows machine. I dont know how they view NIO.2 I would suspect they will add it once its officially released.
14:23@chouserBjering: I haven't seen a single common naming scheme yet. make-Foo and new-Foo are both pretty common.
14:25LauJensenchouser: how about create- ?
14:25@chouserLauJensen: I haven't seen that as much.
14:26@chouserI'm not stating an opinion -- they all look a little ugly to me.
14:26@chouserwait, there I did.
14:26LauJensenhehe
14:26LauJensenWhat would you prefer?
14:26@chouserI've used new- and make- myself. Felt dirty.
14:27mrBlisshttp://lamp.epfl.ch/~odersky/blogs/isscalacomplex.html can you guys come up with good pictures for Clojure? :)
14:27LauJensenchouser: A near cousing to "Something." would be nice
14:28danlarkinI use create-
14:28danlarkinand make-
14:28LauJensenmaybe you should just stick with one?
14:28@chouserI sometimes use foo to create Foo
14:28danlarkinI should, it's a bad habit
14:29@chouserIs it better to stick with a bad one than to experiment trying to find a good one?
14:29LauJensenIf constructing java objects has syntatic support, shouldnt the same be available when dealing with clojure stuff?
14:29Bjeringhow finegrained should one be about namespaces, should I stick most of my functions into one namespace (caio as in clojure aio) or split into many, like "caio.acceptor", "caio.connector" etc ? I suspect the former, the latter smells of "OO-thinking" ?
14:30LauJensenBjering: It depends on the size, but the former is most often used I think
14:30Chousukejust remember to have at least two segments in the namespace :P
14:30Chousukeso caio.core instead of just caio
14:31LauJensenalso, you cant name it caio if it contains clojure code, then it must be caiojure, right technomancy? :)
14:31Chousukeno.
14:31Chousuke:P
14:31danlarkina good rule of thumb is no more than a handful of functions per namespace. Some domains aren't suitable to that level of separation though
14:32LauJensendanlarkin: I would say very rarely do I keep them so small
14:32BjeringSo, start with a single one, split if it becomes unwieldy? Now that suts the door on cleverly naming ctors _only_ make, but I guess that is a not such a good thing, hampers refactoring if I cannot move it around.
14:32ChousukeBjering: I think in general you want to make the namespaces so that a person who only wants one piece of functionality doesn't need to require multiple namespaces.
14:33Bjeringbut prefixing/postfixing function-names depending on what datastructre they act on (or in ctor case, returns) when there exists a namespace facility feels bad too.
14:34Chousukewell you should try to make them polymorphic in that case :/
14:34Bjeringwell, if they are _at all related_
14:35Chousukebut I suppose in that case splitting them into their own namespaces can help.
14:36ChousukeI would err on the side of having more namespaces
14:36Chousukeas long as they have more than a few functions each :P
14:41@chouserI tend to only split namespaces if I think they're actually likely to be used independent of each other
14:49LauJensenbtw, whats the general attitude about clojars, everybody happy with it, is it working out okay ?
14:50RaynesI'm certainly happy with it. Never crapped out on me before.
14:54technomancyLauJensen: it's quite good, but it's a very serious problem that its maintainer is not always available. he's working on moving it to somewhere that a team can admin it, but progress is slow.
14:54LauJensenOh okay - So he's being kept quite busy I take it
14:55technomancybusy with school, it sounds like.
14:55technomancyonce it's on the new server then kotarak and myself can help out with maintenance.
14:55technomancyand we can start talking about setting up mirrors.
14:56LauJensenCool
14:56LauJensenWhy is that a length progress? Copy files, change dns, life goes on?
14:57technomancydunno. =\
14:57fliebeltechnomancy: I think it would also be useful to device a way to keep packages updated… as one package, not as a copy name pepijn.somepackage which is also abandoned shortly thereafter.
14:58bartjer, what does "^:static" mean ?
14:58bartjthat it is a static variable ?
14:58bartj, (doc :static)
14:58clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.Symbol
14:58pdksymbols don't have docstrings
14:58pdkhmm
14:58pdk(doc ^)
14:58clojurebotUnmatched delimiter: )
14:59pdk(doc ^)
14:59clojurebotUnmatched delimiter: )
14:59pdk(doc '^)
14:59clojurebotUnmatched delimiter: )
14:59pdkthanks clojurebot
14:59pdk^ must be a reader macro there so time to google that
15:00bartjgoogling [^:static] just searches for "static"
15:00bartjthis was introduce after 1.0 for sure :)
15:00kotarak^:static foo means *rougly* (with-meta foo {:static true})
15:00kotarakThey are not equivalent, though.
15:01pdk^ adds metadata to an object it seems
15:01pdkhttp://clojure.org/reader
15:01pdkso in this case it probably is acting as a compiler hint to make the object static that we attached the :static metadata to
15:02arohnerbartj: ^:static attaches {:static true} as metadata to the next object. It's used in, e.g. defn to mark the function as static
15:03arohnera static function 1) can't be a closure, 2) can take primitives (long, double) as arguments and return a primitive
15:03bartjstatic functions in a functional langugage ?
15:04bartjwas all of this stuff introduced in 1.2 ?
15:04arohnerand 3) executes faster than a "normal" function because the JVM can inline it
15:04pdkare those the only differences with static functions in clojure
15:04pdkor does it also apply with the traditional java meaning when you try to make/extend a java class in clojure
15:04arohnerthey were introduced in a branch that was made between 1.1. and 1.2, and just got merged into master
15:04technomancyrelated to 3) static functions cannot be rebound.
15:05arohnerpdk: clojure static has no relation to java the language static
15:05LauJensenarohner: Has this been put into an artifact yet, or is it strictly avail from github?
15:05arohnerLauJensen: I don't know. There might be a 1.3 snapshot that contains it
15:05@chouser(symbol (apply str (mapcat #(cons "\n" (next (map {\0 \ \1 \#} (Long/toBinaryString %)))) [185 13235209671M 25939708511M 1654794401M 12429901063M 131081 65539])))
15:05kotarakLauJensen: if it's available from github it should be in the snapshots
15:06LauJensenkotarak: which one?
15:06kotarakThe latest one?
15:07LauJensen(rich said no snapshot, just after he merged)
15:07bartjthis static functions in clojure seems new, can any one please point to some tutorial on the web ?
15:07LauJensenbartj: its right around 3 days old, dunno if there are any tutorials yet, but the concept is simple
15:07bartjgoogle doesn't seem to help in this rare case -
15:07bartjhaha
15:07kotarakLauJensen: aha? When it's in master it should get compiled on the hudson server, I would think..
15:07LauJensenkotarak: Thats what I thought
15:08arohnerbartj: the design notes are here http://www.assembla.com/wiki/show/clojure/Enhanced_Primitive_Support
15:08LauJensenbartj: Its a regular function, that just works on primitives, ie math is 100x faster or so
15:08bartjLauJensen, I found a mention of this on your gist - http://gist.github.com/442044
15:08bartjand was very bewildered
15:08technomancy"you keep using that word; I do not think it means what you think it means"
15:08LauJensenI gist too much, blame gist.el :)
15:08kotarakLauJensen: the last build was 4 days ago...
15:08LauJensenThe merge was 3 days ago I think
15:09tomoja804f7c9
15:09kotarakLauJensen: then it's probably not contained...
15:09mefestoinconceivable!
15:10bartjsorry for sounding naive- but I thought static = "don't create an object"
15:10bartjthat analogy doesn't seem to ring a bell for "static" functions in clojure
15:10LauJensenbartj: its just a word we use :)
15:10technomancybartj: that's the java meaning of static, which has nothing to do with the English meaning.
15:11tomojoh, changelog on hudson is backwards..
15:11bartjtechnomancy, what would you say is the true meaning ?
15:11arohnerbartj: the clojure meaning has to do with the function not being rebound
15:11tomojit's at 9b702a06d, so that's the latest :)
15:12arohnerliterally, static means "unchanging"
15:12bartjok, but in the Clojure context ?
15:13arohnerthe clojure function can't be rebound, i.e. using binding
15:13arohnerso then it doesn't need locking or a volatile
15:13bartjha! so static functions are not first-class ?
15:13bartjor am I mixing up stuff ?
15:14arohnerbartj: they are still first class, but they can't be in closures
15:14arohnerso you can't do (let [a 1] (defn ^:static foo [x] (+ a x))
15:14arohnerbut you can do (defn ^:static foo [x] (inc x)) (map foo (range 0 10))
15:15arohnerthat's a map outside the defn, in case the parens aren't clear
15:15bartjarohner, the map example is pretty clear
15:15arohnerfirst class function means the function can be passed around as a variable, like any other
15:15dnolenbartj: ^:static also allows the JVM to do really crazy optimization tricks
15:23bartjok, thanks a lot guys
15:24bartjeverytime I ask a question you guys just have all the answers
15:25bartjI was reading a bit of closures
15:25pdkif you were to add multiple bits of metadata to a function in a defn form arohner
15:25arohnerpdk: I don't understand
15:25bartjand I think I have been using closures without knowing what they were
15:25pdkwould it go something like (defn ^:meta1 ^:meta 2 function [args] ...) or (defn ^{:meta1 true :meta2 true} function [args] ...)
15:26bartjbut does closure = anonymous functions ?
15:26pdkno
15:26arohnerpdk: (defn ^{} function [args])
15:26pdkclosures are created e.g. by defining a function within the body of a let form
15:26pdksay (let [x 1] (fn [] x))
15:27mefestobartj: they also include variables available in the scope that the fn was defined in
15:27@chouserdepends on if you want the science or engineering defintion of "closure"
15:27pdkin this case it returns a function that's closed over the value of x defined in the let form
15:27mefesto(defn make-adder [x] (fn [y] (+ x y)))
15:27pdkthere's another example
15:28pdkin mefesto's example
15:28pdkif you call say (make-adder 3) it'd return a function that took one argument y and returned y + 3
15:28arohnerchouser: what's the difference?
15:29@chouserI just mean that AFAIK there's no special case in the code for fn objects that close over things vs. those that don't.
15:29bartjpdk, strictly speaking there are no let forms here - http://lispwannabe.wordpress.com/2008/10/24/closures-in-clojure/
15:30arohnerchouser: doesn't there have to be, because of ^:static?
15:30@chouserso from an enginerring or language implementation stand point, it's not very meaningful to give them different names
15:30@chouserarohner: oh, ^:static is different.
15:30mefestobartj: illustrating the example a bit more: http://pastie.org/1118666
15:31@chouserbut sciency mathy people would say (def f (fn [])) creates a function not a closure
15:31@chouserbut the compiler doesn't care
15:31arohnerchouser: the name is useful to distinguish what you can do with closures vs. languages that don't allow them
15:31tomojhmm, I'm getting an error about missing org.clojure.contrib:complete:jar:1.3.0-SNAPSHOT, but I can see it right there at build.clojure.org/snapshots
15:32tomojis [org.clojure.contrib/complete "1.3.0-SNAPSHOT"] not right?
15:32arohnerchouser: I wouldn't say (def f (fn [])) creates a closure, because it doesn't "close over" anything
15:34bartjmefesto, thanks for you example, it was definitely illuminating!
15:35@chouserarohner: I am hereby dubbing you "mathy" :-)
15:35arohnerok :-)
15:35arohnerI don't think I'm mathy, just a pedant
15:36@chouserI'm just suggesting it's not useful pedantry, in this case
15:36bartjmefesto, so, in your example add1 and add2 would be closures, right ?
15:36@chouserfn objects are created using the same code path, and behave the same way, whether they close over anything or not.
15:37arohnerchouser: agreed, but I find it very useful when talking to C programmers about what makes lisp / FP different
15:37mefestobartj: yeah they are functions that "closed over" the x value in the 'make-adder function
15:37@chouserhm, sure.
15:38bartjso come on! anonymous functions are closures!
15:39bartjbecause, well - they are functions whose variables are bound in the lexical enironment of the function
15:39bartjs/enironment/environment
15:39arohnerbartj: you're talking about two different properties of the same thing
15:40arohnerbartj: anonymous means, "I can create a function without naming it" i.e. (fn [x] (inc x)) has no name, unlike (defn foo [x] (inc x))
15:40bartjok...
15:41arohnerbartj: the concept of closures means, "a function can refer to variables in its enclosing scope, defined outside the function"
15:41@chouser,(map #(* % %) (range 5))
15:41clojurebot(0 1 4 9 16)
15:42@chouserthere's an anonymous function that doesn't close over anything
15:42arohnerbartj: so yes, clojure functions can be anonymous, and can be closures
15:42hiredmanit means it can refer to names lexically bound in the lexical scope the function was created in
15:43pdkclojure has a shorthand syntax for very brief anonymous functions too as in chouser's example with the #(* % %) bit
15:43@chouser,(let [n 2, double (fn double [x] (* n x))] (map double (range 5)))
15:43clojurebot(0 2 4 6 8)
15:43pdkuseful for passing simple functions as arguments for map, reduce, apply, whatever
15:43@chouserthere's a fn named double (not anoymous) that closes over n
15:44fogus,(let [f (let [x 100] #(+ x %))] (f 42))
15:44clojurebot142
15:44foguschouser: !! you're too fast
15:44@chouser(fn [x] (* x x)) ...another way to write the same anonymous fn
15:45@chouserI guess #() is called an anonymous function literal, as opposed to just an anon fn
15:45patrkrisis reduce not using InternalReduce in 1.2?
15:45@chouserpatrkris: I don't think so.
15:45@chouserit got commented out
15:45DanielGlauserchouser: #() is the same as (fn [] ()), correct?
15:46patrkrischouser: you know why?
15:46@chouserDanielGlauser: right
15:47bartjarohner, chouser hiredman I can't thank you guys enough
15:48patrkrischouser: no explanation in the commit log, except that rich just says he is disabling it
15:49bartjstrictly speaking, in this example - http://pastie.org/1118666
15:50bartjhow does make-adder "know" to assign y = 1
15:50bartjthe above example is for closures
15:50mefestomake adder doesn't know about y
15:50mefestomake-adder returns a function/closure that accepts a parameter called y
15:51bartjI am sorry add1
15:51bartjsorry, I meant add1
15:51mefestoadd1 = (fn [y] (+ 1 y))
15:51@chouserbartj: the thing that make-adder returns know the values of the things it closed over
15:51mefestomake-adder creates a function with x already set
15:52pdkin those examples make-adder doesn't know about y
15:52mefesto(make-adder 5) => (fn [y] (+ 5 y))
15:52DanielGlauserbartj: make-adder returns a function that takes one argument
15:52pdkit only knows about x and it returns a function that does know about y and x but has x set to whatever the argument to make-adder was
15:52bartjyes, sorry guys that was a mistake on my part
15:53bartjok, I get it
15:54LauJensenDoes anybody here have a working example, of setting up a connection to a h2 embedded db from clojure?
15:54bartjbut, it looks like such a contrived example - almost like watching Inception!
15:54DanielGlauserNow, is the anonymous example returned by make-addr a closure?
15:54DanielGlauserbartj: I wouldn't be sorry, we're all trying to learn here
15:54pdkyeah closures dont tend to be immediately obvious how they can be used
15:54DanielGlauserif make-addr is a closure, what does it close over from its environment?
15:55mefestomake-adder is not the closure
15:55pdkprobably helps to read tutorials on places like schemers.org/cliki, blog posts in various places, books like on lisp or let over lambda
15:55mefestowhat it returns is the closure, right?
15:55DanielGlauserI meant the function it returns
15:55pdkthat talk about lisp traits like macros/closures/whatever in depth to show the fancy pants uses of them
15:56pdkdoesn't it close over the argument given to make-adder dan
15:56mefestoyes, the function it returns is because in order for that function to work, it needs to resolve x which is provided by the lexical scope it was created in
15:57DanielGlauserCool, just wanted to be clear :)
15:58mefestolooking at the fn on it's own shows that it has to have some "extra magic" in order to work
15:58mefesto(fn [y] (+ x y))
15:58mefestothat alone couldn't work
15:59@chouserin fact you get a compile error
15:59bartjok, the only use case for closures right now seem to be when using the surrounding variables ?
16:00hiredmanbartj: that is literally *THE* case
16:00pdkif you did something like (let [myref (ref blah blah)] ...)
16:01hiredmanhttp://en.wikipedia.org/wiki/Funarg_problem
16:01DanielGlauserbartj: Think about a function that builds other functions and what problems you would want to solve with that pattern
16:01pdkthen in the body of that let block you could define one or more functions that operate on that myref variable
16:01pdkwhile keeping it invisible to everything else
16:02DanielGlauserLet's say you were creating a function that spit out parsers, you would want to say what each parser would parse when you spit out the function
16:03DanielGlauserbut each parser would want to take an argument of what they needed to parse
16:03DanielGlauserClosures are good for patterns of building functions
16:04DanielGlauserbartj: does that make sense or am I totally out in left field?
16:05bartjwent to drink some water...
16:05bartjbut, yes it makes a lot of sense right now
16:06mefestobartj: this is an example of what pdk was saying: http://pastie.org/1118745
16:06DanielGlauserHmmmm... perhaps we could use a place up on clojuredocs.org that covers examples of concepts as well as library functions
16:06mefestothe currval atom cannot be accessed by anything... kinda like a private variable
16:07hiredmanlocal
16:10bartjmefesto, that is quite an intelligent way to get two different outputs based on your *current* state
16:14pdkalso lets you keep those bits of mutable state visible only to a set of functions you're allowing to use/modify it so other bits of code can't scribble over that state
16:26_ulises-evening all
16:27astoddardis anyone here using org-babel-clojure in org-mode?
16:29tomojI'm not, but I'm interested
16:29tomojthink it needs a rewrite
16:30_ulises-can anybody help me with this: http://pastebin.com/Y52yuNwi (newbie here)
16:32mefesto_ulises-: (load "/foo/bar") ?
16:32_uliseshmm, let me try
16:32mefesto_ulises: if you want to make an instance of foo.bar you need to compile it too
16:33_ulisesI thought that loading foobar.clj was enough?
16:33_ulisesalso, (load "/foo/bar") doesn't work but (load "foobar") does so I suppose that the latter is the way to go
16:33mefestofor clj files but im guessing you want to create a java class right?
16:33_ulisesyup :)
16:33mefestoi was guessing that since your ns is foo.bar that your file is foo/bar.clj ?
16:34_ulisesoddly enough, this works just fine: (defn make-foo (proxy [Object] [] (-toString [] "Hi!")))
16:34mefestoif it's foobar.clj then i guess that makes sense :)
16:34RaynesYou rarely ever need to actually compile your Clojure code to Java class files. You only need to do that for generally advanced Java interop purposes.
16:35_ulisesmmm
16:36arkhmefesto: what causes the symbols test1-nextval and test2-nextval to remember (and apply) their current value to the function assigned to them?
16:37mefestoarkh: they are closures that have an atom called currval available in their environment
16:37astoddardtomoj: about org-babel-clojure, I am in the same boat
16:38arkhmefesto: : ( currval is local and should disappear between invocations (obviously it sticks around so I'm missing something)
16:38astoddardI am wondering about how to connect babel with something like cljr to control the setup
16:39mefestoarkh: that's the behavior of closures, they have access variables that they reference that are in the lexical scope
16:39mefesto*access to variables
16:40arkhmefesto: I'll have to read up on that. Given that the value is persistent, why is it implicitly used for the single parameter 'num'?
16:40arkhmefesto: subsequent calls aren't made with any arguments
16:40_ulisesalso, when I load the file, the result is nil while if I eval (proxy ...) the result is not
16:40_ulises:(
16:41mefestoarkh: this is the line of interest: (fn [] (swap! currval inc))
16:41bartjarkh, put in another way, they are local in their scope
16:41mefestoarkh: on it's own that code is invalid since currval isn't defined
16:41mefestoarkh: what makes it valid is the outer scope
16:41mefestoi hope im wording that correctly :)
16:42arkhbut the outer scope is requires the parameter num on each execution
16:42arkhs/is//
16:42sexpbotbut the outer scope requires the parameter num on each execution
16:42mefestoarkh: currval is an atom that is initialized to num
16:43arkhohh
16:44arkhok - I need to read up on closures. mefesto:. bartj: thank you for the explanations
16:45technomancy~suddenly
16:45clojurebotBOT FIGHT!!!!!111
16:45technomancywhat?
16:45clojurebotwhat is cells
16:45@chouser~cells?
16:45bartjarkh, you weren't here when all these guys were explaining closures to me ?
16:45clojurebotcells is http://gist.github.com/306174
16:45mefesto_ulises: this works: http://pastie.org/1118839
16:45technomancyclojurebot: facepalm is http://tinyurl.com/38v7jlj
16:45clojurebotRoger.
16:45arkhbartj: I think I was away and just caught the tail end of the discussion
16:45mefesto_ulises: but your classpath needs to be setup a certain way
16:46_uliseslet me try
16:46kilofuq
16:46arkhbartj: I'll read the backlog ;)
16:47mefesto_ulises: by default clojure will compile assuming there's a classes dir in $PWD
16:47raek_ulises: proxy always returns an object, but gen-class generates an ordinary class *when compiled*
16:47raekso 'load' does not return an instance...
16:47_ulisesah, that explains the nil
16:48_ulisesback to the (ns foo.bar ...) do I have to have foo/bar.clj ala Java?
16:48raekbut as mefesto showed, you can compile the namespace and use the ordinary contructor syntax to create an instance
16:48raek_ulises: basically, yes
16:48raekthat is the recommended way
16:48_ulisesok, I didn't know that, thanks
16:48mefesto_ulises: i don't think your file paths _have_ to match but the generated class will use the ns to create foo/bar.class
16:49_ulisesoh!
16:49mefestobut yeah thats recommended
16:49bartjhere I created one paste based on the explanations here
16:49bartjhttp://pastie.org/1118851
16:49raekif you require a namespace foo.bar, clojure will look for foo/bar.clj
16:50raek(compile looks for the file using the same rule too)
16:50raekalso, hyphens in namespace names correspond to underscores in file names
16:50_uliseswell, call me thick but it just doesn't work for me :(
16:51_ulisesI've set it up like mefesto did (foo/bar.clj)
16:51mefesto_ulises: what was the error?
16:51_ulisesthen ran (compile 'foo.bar)
16:51_ulisesIO exception, no such file or dir.
16:51_uliseshrm
16:52mefestothis is probably the classpath thing
16:52_ulisesthis is using cljr swank + emacs btw
16:52mefestoby default clojure assumes ./classes exists and is in your classpath
16:52mefestoyou can override in the repl with: (set! *compile-path* ".")
16:52_ulisesah, it may be that ./ is not in my classpath
16:53raekif you do ahead-of-time compilation (or basicaly anything that requires you to divide the source into multiple files) I would recommend leiningen
16:53mefestoassumeing the current dir is in your classpath :)
16:54_uliseshrm ... still no luck :/
16:54mefesto_ulises: you on linux?
16:54_ulisesos x
16:55raekyou can print the classpath using (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
16:55raekwhat file path does the IO exception complain about?
16:56_ulisesthat it can't find bar.clj
16:56_ulisesbut it must be the classpath as I did the set! *compile-path* and then it worked
16:56_ulisesin any case, got to go, thanks for your help chaps :)
16:57raekI pernollay think leiningen would be a better fit than cljr in your case (at least for setting up the classpath)
16:57raekas it works with project directories
16:57raekwith src/ and classes/ directories automatically added to the classpath
16:57raekyou shouldn't have to tweak the classpath manually, really
16:59ssiderisdo you guys know whether running "lein swank" from a project dir will setup the classpath automatically for you?
17:00Raynesssideris: It does.
17:01ssiderisRaynes: thanks, I'll give it a try...
17:01raekit adds src/, lib/, classes/, resources/ (and maybe some more) plus those for all the dependencies and dependencies dependencies, etc
17:05ssiderisif I add new dependencies and then run "lein deps" I suppose I'd have to re-start swank and reconnect from emacs, right?
17:05Raynesssideris: Yes.
17:28ssiderisit works! thanks :-)
18:05jkndrknHey all. I'm using a BufferedReader to access a resource hosted at a remote location. I'm doing streaming writes.
18:05jkndrkn*streaming reads.
18:06jkndrknMy application code requires me to pass this reader to an instance of SuperCSV for CSV parsing.
18:06jkndrknHowever, I also need the raw lines of CSV for composing detailed error reports.
18:07jkndrknCurrently, I am having to use two readers but would like to avoid doing so since this scheme essentially requires me to pull data down twice.
18:08jkndrknI can create a lazy sequence of strings from one reader, is there any way that I can both consume this lazy sequence in one place in my application code and also draw from it elsewhere by somehow converting it into a BufferedReader?
18:09jkndrknIn other words, can I create a BufferedReader that reads from a lazy sequence. And, if so, is this a safe approach to use that won't cause head retention or other kinds of excessive memory consumption?
18:14raekthat should indeed be possible
18:15raekI have to sleep. good luck!
18:23tomojdid ignore-trailing-slash disappear? :(
18:48jkndrknHere's my question written in a more coherent fashion: http://stackoverflow.com/questions/3580152/clojure-java-most-effective-method-for-minimizing-bandwidth-consumption-when-per
18:48jkndrknI would greatly appreciate if someone could take a look ^_^
18:55ssiderisis native-deps broken?
18:55ssiderisit seems that although i've added it as a dev dependency, :native-dependencies is being ignored
18:56dnolenssideris: no it should work I just tested it this morning, you need 1.0.3 tho
18:56dnolenwill be pushing it clojars in 30-45 minutes or so.
18:56dnolenssideris: if your in a rush, just clone the git repo and run install from the repo directory
18:58ssiderisdnolen: no particular rush, just learning how to use leiningen etc and I was hoping to play with penumbra a bit. Thanks!
18:59wwmorganjkndrkn: Could you download the file to local storage, and then open two streams on it?
19:12jkndrknwwmorgan: Yes, but that would defeat the purpose of streaming in the first place: to begin processing data right away as soon as it starts arriving rather than wait for the whole file to download.
19:14jkndrknwwmorgan: We may have to fall back to that scheme if we can't figure out a good way to do this.
19:18wwmorganjkndrkn: are you reading the records by calling CsvBeanReader.read?
19:24@chouserjava.lang.RuntimeException: java.lang.IllegalStateException: no 'this' pointer within static method
19:24@chouserwhat does that mean?
19:24@chouseror rather, what sort of code can trigger that error?
19:25ssiderisin java?
19:25fsmunozchouser: I could be completely wrong
19:25wwmorganchouser: it strongly resembles the java compile-time error of having a "this" in a static method. There is no "this" for static methods
19:25fsmunozchouser: but a static method doesn't have a "this", it is used fr instance methods
19:26@chouserright, but how to get this from a clojure defn form?
19:27fsmunozchouser: I use "this" when I'm implementing istance methods via proxy... they work as expected there. Apart from that I know close to nothing.
19:29@chouserhuh!
19:30@chouserok, it appears to happen when you call a protocol method from inside a static function
19:31@chousernow that I say that, it sound vaguely familier. hm.
19:32tomojit's a "temporary limitation"
19:34fsmunozSOme hours ago I mention this doubt, bu maybe I'll have better luck now: I'm having trouble "converting" an imperative solution to a functional one. Essencially I need to build an array/vector that contains x/y coordinates for an hexagon. They are calculated like this.x[0] = foo; this.x[1] = this.x[0] + bar, etc, etc. I'm using make-array and aset now, but that is, well, hardly idiomatic. Any hints on a more "functio
19:34fsmunoznal" way of going at it? I've toyed with the idea of having the two vectors as atoms, is that sensible?
19:36wwmorganfsmunoz: can you paste the imperative code?
19:36fsmunozwwmorgan: sure: https://malenkov.dev.java.net/20090226/hexagon.java
19:37fsmunozThe relevant part is there in the middle, the "this.x[0]" stuff
19:37ssiderisi have the feeling this is going to be 4 lines in clojure :-)
19:38fsmunozssideris: that's partially what I'm hoping, I'm very aware that I'm using an hammer for everything
19:38fsmunozIn this case make-array, which is clearly a coup-out since it allows aset.
19:39fsmunozHaving 6 different let vars doesn't seem much cleaner either.
19:44@chouserI'd just use a let to compute the things that are used more than once first
19:44@chouserthen put those and the remaining expressions into your array or vector or whatever.
19:47fsmunozchouser: yes, that would be the "6 different let vars" approach. It would work, but somehow it doesn't look very elegant. In this situation it would work, but if doing a polygon with 20 vertices it wouln't scale well.
19:48fsmunozbut maybe that's the way to go, that or setting x and y as atoms and using swap!
19:48kencauseythis doesn't seem like a common thing to me, normally shapes are going to be defined by external data
19:48fsmunozwould still be more imperative, but would at least avoid using Java arrays
19:48kencauseyare you sure the issue is that you are try to treat data as code?
19:49kencauseys/is/isn't/
19:49sexpbotare you sure the isn'tsue isn't that you are try to treat data as code?
19:49fsmunozkencausey: this is a grid... the hexagons will have to be drawn somehow, it's the "base world".
19:50kencauseyok, fine, this case may not be a problem and may really be imperative
19:50kencauseyThere is a point though on the complexity scale where it makes sense for it to change from a code issue to a data issue
19:51fsmunozkencausey: yes, I was wondering that, the objective itself is merely to do the calculation for determining the vertices, so it's perhaps one of those situations were it's ok to "cheat" ;)
19:51fsmunozsexpbot: how so?
19:53fsmunozI really can't think of a way to draw an hexagon that doesn't involve calculating the vertices using math (and some variables that govern superficial stuff like scale)
19:53fsmunozBut I'm almost as bad at math as I am at clojure, so feel more than free to correct me
19:53kencauseythe questions is not whether math is used or not
19:54kencauseyit's whether it is done at runtime or compiletime
19:54fsmunozkencausey: runtime, since e.g. the user could change the zoom scale. But why exactly is that difference important in terms of the way of calculating it?
19:55fsmunozSorry to burden you with questions that could be obvious, I'm trying to pick as much brains as possible ;)
19:55kencauseyfor a hexagon, probably none, for thousands of them or more maybe an optimization
19:55@chouserit'd be better to cheat with extra locals than with atoms
19:56@chouseratoms suggest coordinated mutation from multiple threads
19:56fsmunozchouser: yes, probably bad idea, true
19:57fsmunozkencausey: ahh, yes, instead of calculating it on the fly having it all pre-calculated in order to improve performance, something like that?
19:59wwmorganfsmunoz: right now you're using mutation for the local variables i and j?
20:00fsmunozwwmorgan: let me check, I'm not using i/j for coordinate printing yet, merely for adjusting the loop increments
20:00fsmunozwwmorgan: no, I set them in let, then just use them to increment x/y in the respective recurds
20:00fsmunoz*recurs
20:01fsmunozwwmorgan: I've used loop/recur in place of the while's in there.
20:02@chouser(map #(vector (+ x %1) (+ y %2)) [0 R R 0 (- R) (- R)] [(- S) (- L) L S L (- L)])
20:03fsmunozLooks like TECO Emacs, which means it's probably perfect!
20:03@chouserheh
20:04fsmunozIntersting, very interesting
20:04fsmunozAnd without a doubt more elegant than using aset.
20:05fsmunozPlus, completely functional
20:05fsmunozmany thanks chouser
20:05fsmunoz(and wwmorgan, kencausey)
20:07fsmunozPart of my difficulties with Clojure have to do with imperative thinking: I've notived that when using imperative style I could get away with not knowing much about a language, but with functional programming it's almost fundamental to learn them.
20:12wwmorganfsmunoz: that paint method is pretty oversized. You can get practice writing more functional clojure by writing more functional java :-)
20:13fsmunozwwmorgan: ehehe, yes, but what I was really after was the hexagon stuff, it just happened to be in Java. The coords-to-x/y stuff isn't obvious, and that page has the advantage of explaining it well enough
20:14fsmunozThe paint stuff I'll likely rewrite (eventually having each hex drawing itself instead of doing it linearly, etc).
20:14fsmunozBut the calculation itself is always needed.
20:15bortrebfsmunoz: you're doing the meteor contest?
20:16fsmunozbortreb: no, what's that?
20:16bortrebhttp://shootout.alioth.debian.org/u32/performance.php?test=meteor
20:16bortrebit's a benchmark game that involves placing hexagons on a board
20:17fsmunozWell, I'll be damned
20:17fsmunozPlenty of source code in there!
20:17bortrebyou can submit clojure stuff too :)
20:18fsmunozbortreb: as you can see from my doubts, I don't think it would do it justice ;)
20:20fsmunozBut thanks a lot for the hint, I will most surely use it.
20:28@chouserfsmunoz: that map/vector solution may be more elegant, but it's certainly slower than a 6-clause let would be
20:28fsmunozchouser: I'll optimise it latter then, at this stage I'm putting elegance above performance :D
20:28fsmunozchouser: even because it has better learning value
20:29bortrebIs there a real solid way of creating a map of all the static final ints in a class?
20:29bortreber, I mean a seq
20:33mefestobortreb: by "solid" do you mean non-reflection based way?
20:33mefestojava.lang.reflect i mean
20:34bortrebnot at all, just something that isn't in any way a hack
20:34bortreband is in all cases functionally correct
20:36mefestobortreb: not sure if contrib has something already but the manual way would be: (.getFields ClassName)
20:37mefestoit'll give you an array of fields that you can filter based on type or other characteristic you are looking for
20:37bortrebyes, I've done that, but then what? How can I sell if they're static ints and grab the actual values?
20:38mefestogetModifiers i believe
20:38mefestojava.lang.reflect.Modifier has the constants that will be bitwised or'd on the field's modifiers property
20:39bortrebhuh
20:39mefestoModifier.STATIC
20:40mefestoim rusty on bitwise stuff so someone please correct me but maybe: if (Modifier.STATIC & field.getModifiers()) {...} is it
20:40bortrebcool --- that's everything I need. thanks mefesto
20:43mefesto(bit-and Modifier/STATIC (.getModifiers field))
20:44tomoj(Modifier/isStatic (.getModifiers field))
20:45mefestough, way better :)
20:45bortrebyay for tomoj!
21:17fsmunozchouser: just as a note, the new version based on your map approach is *much* quicker than the previous one I had, which followed the original Java code using aset and aget. When maximising it would take 1 second to fill the new area, now it is immediate.
22:27dnolenanybody else experiencing issues pushing to clojars?
23:59fielcabralI just got swank-clojure from github. Should I use the latest slime on common-lisp.net with it or the one from elpa (20100404)?