#clojure log - Nov 07 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:01 Chouser: yes, .clj files in .jars will be found by require and use

0:03 djkthx: cool

0:03 and if someone has clojure, could they run it from java?

0:09 Chouser: you can actually bundle clojure and your code into a single .jar, and the user won't even have to know clojure's in there. it'll just run like a java .jar

0:09 djkthx: awesome

0:21 pmf: I've uploaded a patch to the files-section of the group that fixes the behaviour of gen-class when a field to be exposed via :exposes is not declared in the immediate superclass, but somewhere in the ancestors.

0:30 Chouser: pmf: it'd be best to announce that on the group

0:30 along with the file name

0:32 pmf: URL of the uploaded file is http://clojure.googlegroups.com/web/genclass-exposes-fix.patch

0:34 For some reason, I can upload files to the group, but am unable to post there (get an error email from GOOG).

0:56 H4ns: lisppaste8: url

0:56 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

4:32 Lau_of_DK: Top of the morning gents :)

4:42 hoeck: good morning Lau_of_DK

7:42 Lau_of_DK: rhickey, pure interest question, how long did it take you to write ants, start to finish?

7:43 rhickey: Lau_of_DK: a couple of hours

7:43 Lau_of_DK: Impressive...But perhaps its an advantage have written the language your working in, thanks

7:48 rhickey, now that Ive got you: Will you consider letting print/println return whats being printed instead of nil

7:49 rhickey: Lau_of_DK: probably not

7:49 Lau_of_DK: rhickey: May I ask why ?

7:49 rhickey: you can ask

7:50 H4ns: one good reason is (print & more)

7:50 rhickey: print et al are not functions, they do IO, they can take multiple args, there's no more reason to return the thing being printed than the stream being printed to etc

7:51 H4ns: rhickey: if it'd be (print object), it would be convenient to return the object, too. this makes it easy to insert printing for debug purposes, at almost arbitary places

7:52 rhickey: but i like (print & more) better, as it is more helpful in the general case. one can always define a debug-printing macro that drt and only accepts one argument

7:52 (not that i've been asked) :)

7:53 rhickey: right, a debug print would be a macro and could do that

7:55 alvin-x: was Clojure at work on election night?

7:56 rhickey: alvin-x: I cannot discuss the details of that system, sorry

7:58 alvin-x: no problem

7:59 Lau_of_DK: rhickey, alright I see your point. My exact situation was actually trying to debug something, and then ended up causing more errors because of prints behavior. Is there a debug macro I could use instead?

8:17 gnuvince: Good morning

8:24 rhickey: gnuvince: hey

8:25 gnuvince: How's everybody doing?

8:28 alvin-x: looking forward to the weekend and the new Bond movie :)

8:29 gnuvince: Ooh, yeah!

8:31 * H4ns will be flying berlin->boston and read stuart's book on the plane

8:34 Lau_of_DK: H4ns, have a good flight :)

8:34 gnuvince: Too bad the beta costs money

8:35 I like how the Bryan O'Sulllivan, Don Stewart and the other gentleman whose name I cannot recall did with "Real World Haskell": directly online with a per-paragraph comment system.

8:51 aperotte: If I wanted to do some heavy numerical computations in clojure, what would be the best approach? Writing it in java, using type hints, or coercions?

8:53 rhickey: aperotte: you can use the primitive support in your inner loops to get the same perf as Java, then wrap in a function of macro wrapper lib for ease of use/expressivity. You'll probably want to stick with (Java) arrays of primitives for best results

8:58 aperotte: rhickey: just to be sure I understand. If I want to do something like a matrix vector multiplication, I'd represent the matrix and vector as java arrays of primitives (by coercion), and write a function or macro whose inner loop(s) perform the computation.

9:01 rhickey: aperotte: not exactly sure what you mean by coercion, but yes, you can use arrays of primitives directly, and use amap/areduce, as shown here: http://clojure.org/java_interop

9:01 see the section: Support for Java Primitives

9:02 aperotte: rhickey: Thanks, I think I got it. I got coercion from that page at the bottom (ie. using (int x) to use a primitive type)

9:06 rhickey: p.s. Thanks for clojure in general. I'm sure you've heard this before, but it's exactly what I've been looking for.

9:07 rhickey: you're welcome!

9:19 Cark: question : in the ns macro, is there a one liner to specify i want to require 'cara.dialog and filter to get only the show-message symbol imported ?

9:23 rhickey: Cark: yes, using the :use option with :only

9:23 Cark: i tried =P

9:23 (:use (cara.language :only (lgstr add-strings)))

9:24 and (:use cara.language :only (lgstr add-strings))

9:24 but that does not work

9:25 rhickey: (:use [cara.language :only (lgstr add-strings)]) ?

9:26 Cark: that's it...thanks a lot

9:26 maybe a better example in the doc would be usefull

9:27 couldn't find any such bracket to give me a hint

9:27 and it's not consistent with :refer or :import

9:29 rhickey: Cark: yeah, (doc require) describes the libspec format, but has no example of that

10:36 Chouser: I can only extract the vaguest of gists from Haskell code. Syntax is tiring to learn.

10:37 rhickey: Chouser: I agree, the syntax is write-only, so much parsing required to read

10:38 Chouser: I think I understand the basics of that IO stream slideset, but I'm not terribly confident.

10:42 danlarkin: hah tell me about it... I'm reading a paper on parser combinators and the haskell code used in examples is not making it easier to understand

10:55 djkthx: is there something i need to have enabled to have [ret] go to a newline and indent with clojure-mode on emacs?

11:00 gnuvince: djkthx: you need to remap it.

11:01 My elisp-fu is rusty, but it should be something like (global-set-key [ret] 'newline-and-indent)

11:01 It's been a while since I used Emacs.

11:03 drewr: Chouser: Can you not permalink in your clojure log anymore?

11:03 How do I link to a paragraph? (FF3)

11:10 Chouser: drewr: you can either use #05:23b type syntax or #05:23b-14:03

11:11 either way you may need to reload once you've built the url to see it work.

11:11 drewr: OK.

11:11 * abrooks spent a moment trying to figure out the new reader syntax (#05:23b-14:03) until he realized the actual context.

11:12 drewr: It's that new Clojure-Firefox integration.

11:15 djkthx: thanks gnuvince

11:15 it was "\r"

11:15 but it works now

11:21 Chouser: rhickey: do you have any thoughts on deprecating .. (in favor of ->) ?

11:30 gnuvince: djkthx: happy to know I was in the ballpark :) I've not used Emacs in two years after pain in my wrists and pinky finger made it impossible to continue using it.

11:30 djkthx: that sucks

11:30 what do you use now?

11:30 gnuvince: Went back to vim.

11:31 djkthx: gotcha

11:31 gnuvince: I was a vim user who converted to Emacs and who came back.

11:31 djkthx: yeah, i primarily use vim, but lisp-y stuff seems so much nicer in emacs

11:31 gnuvince: I'll be writing a book about it: "There and back again"

11:31 :)

11:31 djkthx: haha

11:31 gnuvince: Yeah, Emacs is way ahead of vim when it comes to any language that has a REPL.

11:32 and Lisp support in Emacs is great.

11:33 * drewr has never had a problem with RSI in Emacs

11:33 drewr: And that's using it 8-10 hours a day.

11:34 gnuvince: drewr: there are some factors that come into

11:34 play

11:43 duck1123: I've had some days where my left pinky was so sore after working all day in emacs

11:45 drewr: Maybe it's the intense pre-work finger workout I subject myself to.

11:49 Chousuke: If I didn't use caps lock as control I probably couldn't use emacs for longer than few minutes at a time :/

11:49 drewr: Chousuke: No doubt.

11:50 duck1123: My caps lock is my meta key for stumpwm

11:51 gnuvince: I have capslock mapped to control

11:51 and I used my ring finger

11:52 but I always kept my pinky curled up

11:52 duck1123: is your control still a control?

11:52 drewr: gnuvince: Why not use your pinky? My wrist and my fingers barely move because everything is in the right place.

11:53 gnuvince: drewr: small hands

11:53 duck1123: I think the frustration trying to break that muscle memory would be worse than any RSI it might save

11:53 drewr: gnuvince: That seems to be even more reason to use the pinky.

11:54 gnuvince: drewr: small hands, little strength

11:54 anyway

11:54 Chousuke: having caps lock as control has become a requirement for me... Caps lock only really caused annoyance :/

11:54 gnuvince: I'm very comfortable in vim now.

11:54 drewr: Heh. I like vim too.

11:54 gnuvince: SLIME would be nice, but I'll trade that for being able to play the guitar and stuff when I'm 40 :)

11:55 drewr: gnuvince: Maybe my guitar playing is what keeps my fingers strong enough for Emacs. :-)

11:57 gnuvince: :)

11:57 Chousuke: kotarak is working on some improved REPL support for vim/clojure I think. he has chimp on his site, but he said he's working on "gorilla" now.

11:59 gnuvince: drewr: one thing that really wears out my pinky is that with my keyboard binding (french canadian), / is done with Shift-3 and I do that chord with pinky-index

12:00 so that's a lot of shifting in a day

12:02 duck1123: I've been tempted to buy one of those gamer's keyboards for using with emacs

12:21 danlarkin: kotarak: just the man I want to speak to

12:22 kotarak: danlarkin: who? me? must be misunderstanding! ;)

12:22 danlarkin: I stumbled upon your parser combinator library last night

12:22 it's a nice piece of work

12:23 kotarak: unfortunately, it doesn't get the time slice of my spare time, it deserves. :/

12:23 danlarkin: yes I noticed it's using some old idioms

12:24 kotarak: It's in a transition state...

12:24 danlarkin: oh are you working on it?

12:25 kotarak: yes, but the last change of in september or so...

12:26 As soon as I get some time off from Gorilla and ClojureCheck, I will continue on Parser.

12:28 gnuvince: kotarak: What is Gorilla?

12:29 kotarak: successor of Chimp. With both way information flow, Repl inside a Vim, buffer etc...

12:29 gnuvince: ok

12:29 that's interesting, we were just talking about SLIME and how us vim users didn't have it

12:33 SnowBuddy: I have something like this: (take-while !nil (all-lines-from file)), where !nil is defined as (defn !nil [x] (not (nil? x))). is there a function that already gives me the same effect as !nil that I just haven't seen?

12:33 kotarak: gnuvince: on http://tinyurl.com/5ma9d8 there is a short screencast, with my initial prototype. Currently I'm working make it usable for someone who's not me...

12:34 Chousuke: heh

12:34 kotarak: SnowBuddy: (complement nil?) (not that is shorter)

12:34 rhickey: SnowBuddy: (comp not nil?), or maybe identity

12:34 Chousuke: kotarak: I tried cloning your hg repo but make fails :/

12:35 it just says Makefile:40: *** missing separator. Stop.

12:35 kotarak: Chousuke: which hg repo?

12:35 Chousuke: this a BSD makefile, no GNU makefile

12:35 Chousuke: gorilla's; using the url I found on your site

12:35 right.

12:35 I suspected that. need to get bsd make then.

12:35 kotarak: Chousuke: hmm... give until tomorrow.

12:35 Chousuke: oh, no I don't. it's there already :D

12:36 kotarak: Chousuke: then I will put up a jar.

12:36 Chousuke: then there's no need for the make. :)

12:36 Chousuke: I seem to be missing shtool too. :)

12:37 SnowBuddy: ok, so other options are just alternative ways of writing the same thing then?

12:37 rhickey: SnowBuddy: identity isn't

12:38 danlarkin: kotarak: is Parser in a usable state right now? I've only skimmed through your code and examples so far, haven't tried to run anything yet

12:39 rhickey: SnowBuddy: and re: all-lines-from-file see line-seq

12:39 duck1123: identity would also fail on false, right?

12:39 rhickey: duck1123: yes, but for his lines use would be ok

12:40 presuming string or nil

12:41 SnowBuddy: rhickey: so something like (take-while #(identity %) (line-seq file)) then?

12:41 it took me a moment to grok how identity solves the problem ;)

12:41 rhickey: SnowBuddy: just (take-while identity ...)

12:43 SnowBuddy: rhickey: ah, I see. on a style note, how does (take-while identity ...) compare to (take-while !nil ...) in terms of readability?

12:44 duck1123: "while it's there, take this..." is how I mentally translate it

12:45 vs. "while it's not nill, take this..."

12:46 rhickey: I prefer identity when false isn't involved, else (complement nil?) - prefer standard fns

12:46 SnowBuddy: rhickey: what do you mean by "when false isn't involved"?

12:46 rhickey: but I think all-lines-from-file is suspect, not using seqs

12:48 (filter identity [1 2 false nil 6])

12:48 (filter (complement nil?) [1 2 false nil 6])

12:51 SnowBuddy: all-lines-from boils down to a repeatedly on readLine. so in the first filter are false and nil treated as the same while in the second they're unique?

12:57 Chouser: SnowBuddy: right.

12:58 line-seq is a standard function that also does readLine repeatedly.

12:59 kotarak: danlarkin: Parser is not really usable at the moment.

13:00 Chousuke: the makefile more some convenience for internal usage....

13:01 SnowBuddy: I'm still learning what all the standard functions are and what they do. looking at line-seq, it uses lazy-cons and a recursive call instead of the repeatedly I was using. what's the difference?

13:01 danlarkin: kotarak: aw :-/

13:01 gnuvince: Has anyone started a style guide for Clojure?

13:02 Chousuke: kotarak: I managed to build the .jar and run the socketrepl but I can't figure out how to run the actual vim repl :/

13:02 drewr: gnuvince: boot.clj :-)

13:02 gnuvince: :)

13:02 Chouser: rhickey: I just finished the binding-vector audit and patch. fixing up the doc strings now.

13:03 kotarak: Chousuke: In a clojure buffer \sr

13:03 gnuvince: Specifically, I'm wondering if (. obj method), (. obj (method)) or (.method obj) is prefered

13:03 Chouser: there weren't as many as I thought

13:03 rhickey: Chouser: cool! thanks

13:04 kotarak: danlarkin: I'm working on it. :) Patience, I say! ;)

13:05 drewr: gnuvince: I think the latter. (. obj (method)) is probably from code that hasn't been updated.

13:06 Chousuke: kotarak: hmm, for some reason vim doesn't seem to be detecting clojure files properly now... need to fix that first I suppose.

13:07 gnuvince: drewr: cool, that's actually my favorite ;)

13:08 drewr: Yeah, it's the lispiest.

13:08 Very CLOS-like.

13:09 duck1123: (new Object) or (Object.) ?

13:10 kotarak: I prefer new, but the dot-notation is wide-spread

13:17 Chousuke: kotarak: I'm trying to run it but it says "pattern not found: print-method" :/

13:20 kotarak: Chousuke: sounds like broken, keyboard mapping...

13:20 Chousuke: just a sec

13:21 Chousuke: try to run it manually, :call GorillaStartRepl()

13:21 danlarkin: kotarak: I guess while I wait I can learn a little more about how it works :) it's mostly still over my head at this point

13:21 Chousuke: kotarak: well that worked

13:22 kotarak: danlarkin: one get the hang of it, you see combinators all over the place. :)

13:23 Chousuke: <C-CR> send to the Clojure instance, <C-Up> goes in history, <C-Down> goes down, never ever send two things at the same time!

13:24 Chousuke: I get "IndexError: (eval):66:in `[]': index 0 out of buffer" :/

13:25 ah right

13:25 that was because I had an extraneous newline

13:26 abrooks: kotarak: Is Gorilla publicly available now?

13:26 kotarak: Chousuke: as I said: prototype. I'm working making it more robust right now. Hopefully I have something tomorrow. (I wanted to have something already this week....)

13:26 abrooks: not really.

13:26 abrooks: you can have a look at http://kotka.de/projects/clojure/gorilla.html, but you won't have fun...

13:27 abrooks: kotarak: Okay. Should I keep an eye out in the Clojure Group for your announcement when it is?

13:27 Chousuke: kotarak: well, I wasn't expecting it to be perfect. Still, looks promising.

13:27 abrooks: kotarak: Hehe. :)

13:27 kotarak: abrooks: yes. I will send an announcement

13:29 Chousuke: the biiig improvement over chimp is: it's two-way. With Chimp the information goes only in one-way - out of Vim. Since it's via network, one can also do remote repling, independent of Windows or Unix or Mac, or via a ssh tunnel or whatever

13:32 abrooks: kotarak: I use (and enjoy) Chimp. I create splits in my Chimp session and can use Screen to copy stuff back and forth.

13:32 Chousuke: hmm

13:33 abrooks: kotarak: It's a lot less smooth than going back-and-forth between Vim buffers since I have to shift from Vim to Screen to Vim key bindings but I do use it bidirectionally.

13:33 kotarak: abrooks: yes, but for example auto-completion with display of arglists (omni-completion), etc, is not possible with Chimp.

13:33 Chousuke: oops. I managed to send java into an infinite loop again.

13:33 abrooks: kotarak: Absolutely. And I'm looking forwards to Gorilla for that reason. :)

13:34 kotarak: Chousuke: that's possible if you send something like this: Gorilla=> :a :b

13:34 Then vim and clojure get out of sync.

13:34 I'm still working on that one....

13:34 danlarkin: Chousuke: I think we all do that more than we'd care to admit

13:35 Chousuke: the repl kind of encourages it

13:35 since it's so easy to experiment.

13:35 abrooks: Yeah, infinite, lazy seqs are landmines for the forgetful or typo prone...

13:35 kotarak: abrooks: In the beginning I want to first make Chimp and Gorilla equivalent in functionality. Then I will start to implement additional things like omni-completion.

13:36 Or maybe ballons with docstrings...

13:36 Chousuke: some way to tell clojure to abort evaluation might be useful.

13:36 abrooks: Oooo. :)

13:38 danlarkin: Chousuke: now you're talking

13:38 I like that in python C-c raises a KeyboardInterrupt exception

13:39 and brings you back to the repl

13:39 Chouser: there was some discussion of that on the group some months ago

13:52 rhickey: there's *print-length* now

14:11 AWizzArd: Hello

14:11 Lau_of_DK: Hey AWizzArd

14:11 AWizzArd: Good evening Lau

14:11 kotarak: hi wizz, hi lau

14:12 AWizzArd: Moin Kota

14:12 Lau_of_DK: Ola Kota

14:12 AWizzArd: everyone is slowly waking up :-)

14:12 Lau_of_DK: Friday night, time for coding!

14:13 AWizzArd: qt?

14:13 Lau_of_DK: Hmm, Im as far with Qt now as I need

14:14 I have the designer integrated, I have webkit running, I have hooked slots/signals to anonymous functions. So, its functional as far as smaller fancy GUIs go :)

14:14 Chouser: Lau_of_DK: is that code posted anywhere?

14:14 Lau_of_DK: yea, I put it all in /home/lau

14:14 :)

14:21 sohail: Lau_of_DK, paste.lisp.org man!

14:21 Lau_of_DK: I need to compile the whole thing and comment it, giving credit where credit is due, before I unleash it

14:21 But there are problems with Qt at the core, which makes me a bit cautious to distribute

14:24 sohail: Lau_of_DK, what problems?

14:26 Lau_of_DK: The signal/slot system does not throw errors. If somethings fails it will be silently dropped. If a slot throws an error, QApplication ignores it.

14:27 QObjects are non-thread-safe - Objects spawned in 1 thread can only be called from that thread ( this is probably fixable/patchable), but as of yet its a real problem

14:27 Some of these issues, especially with slots, quire alot of work and attention before being industry grade, and Im not sure anybody will put that work in, or just instead start using it as is, and by doing so throwing all clojure concurrency guarantees overboard

14:30 sohail: Lau_of_DK, they did that by design

14:31 I still don't understand it

14:31 maybe it helps in thread-safety or something

14:31 and yeah for slots throwing errors, you need to basically wrap all your slots somehow

14:32 Python has a really nice "unhandled exception" handler which does this very nicely for pyqt

14:32 I doubt clojure has something similar

14:33 Lau_of_DK: If it could be written in a good way, Im all for it. But Ive seen a few people just jump allover Qt (incl me), which might not be so good

14:33 But Im no expert :) Im just sharing a concern

14:33 sohail: I don't understand what you mean by "jump all over Qt"

14:34 Lau_of_DK: I read a blogspot which celebrated that there was now a Lisp with Qt in it, and gave an example of a GUI and such, without any mention of any of these restrictions, and that gives an inaccurate view of the platform

14:35 sohail: lol, that's probably me

14:35 Lau_of_DK: oh :)

14:35 sohail: the one thread-per QObject is nothing you can change

14:35 AWizzArd: what does this mean? One thread per QObj?

14:36 sohail: means that a QObject may only be used from one thread

14:36 AWizzArd: hmm

14:36 Chouser: for what it's worth, I expect all those issues could be handled pretty well with a single well-thought-out lib.

14:36 AWizzArd: is it not good if you can run each component of your gui in its own thread?

14:37 scrollbar, each point in the menu, buttons, etc

14:37 sohail: AWizzArd, all GUI stuff must be done on the main thread

14:37 but QObjects aren't always GUI threads

14:37 AWizzArd: and what about swing?

14:37 sohail: same, iirc

14:37 I think all GUI frameworks do that

14:37 AWizzArd: so it's nothing special to point out then?

14:38 sohail: nope

14:38 Lau_of_DK, as for signals/slots, yes Qt pretends exceptions don't exist

14:38 Lau_of_DK: Chouser, thats worth alot

14:38 sohail: so you have to do something

14:38 it's fine to have an unhandled exception handler for clojure-qt or whatever

14:38 Lau_of_DK: Yea, I might look into that as the next project

14:38 sohail: it's not very hard

14:39 for my qtcl thing, I had one function that all slots went through

14:39 that's where I did the error handling

14:39 I think anyway!

14:40 Lau_of_DK: Write it up man

14:41 sohail: hm, no I lied

14:42 I didn't do the error handling

14:42 Lau_of_DK: You just pretended, like Qt ? :)

14:42 sohail: but had a macro define-slot-handler which generated a cffi:callback which should have done the error handling

14:43 Lau_of_DK: ok

14:45 sohail: and I had a bunch of (define-slot-handler some-name "(SlotArgList)" (:cffi-arg-list)) so: (define-slot-handler activation-reason "(QSystemTrayIcon::ActivationReason)" (:int)) for example.. then any slots that had the arg list of QSystemTrayIcon::ActivationReason would use that one callback (through some other magic)

14:45 and since I'm sure that makes nos ense, I will take my leave and go debug some multi-threaded code

14:47 Lau_of_DK: Ok :)

14:47 It might make perfect sense, but I cant grapple with it right now, long day

14:48 sohail: Lau_of_DK, I'd like to see what you've done with Qt

14:48 Lau_of_DK: When I have the time and the energy, I'll wrap something up for you, I'll try to get it done this weekend

14:59 AWizzArd: I am running tons and tons of agents. Can I somehow check how much of them are still in the queue?

15:05 Chouser: rhickey: is it intentional that for doesn't support :when and :while at the same time?

15:06 djkthx: does clojure have its own integer square root like isqrt?

15:07 rhickey: Chouser: probably not

15:13 djkthx: also, is there a bit-vector or anything like that?

15:14 rhickey: Chouser: doseq based on for is a perf loss, easiest implementation, I know, but the objective should be imperative version of for

15:16 Chouser: ah, so no laziness inside.

15:16 but still :while :when and nesting?

15:17 rhickey: Chouser: that would be best

15:17 Chouser: yes, same interface

15:18 Chouser: that would probably be easier for me than trying to understand for well enough to fix the :when-and-:while bug. :-P

15:18 rhickey: Chouser: it's not a bug, but a lack of a feature, so no need to fix yet, but yes, imperative much easier

15:19 Lau_of_DK: rhickey, have you plans on making any more screencasts like the one with Ants, where you similarily would walk through lines of code, explaining them as you go along ?

15:20 kotarak: rhickey: may I ask something rather unprofessional? Are you working in parallel to Clojure development? Or is clojure your main engagement at the moment?

15:21 rhickey: Lau_of_DK: the most recent thought was to conduct some sort of online study group, but it hasn't moved forward due to my schedule recently

15:21 kotarak: rhickey, Lau_of_DK: yeah, there was this netmeeting thing spooking around.

15:21 yea, exactly

15:21 Lau_of_DK: rhickey, great, where can I sign up? :)

15:22 kotarak: Lau_of_DK: you considered the time shift?

15:22 rhickey: Lau_of_DK: it's a matter of getting enough people interested who can attend at the same times

15:22 kotarak: I do consulting and Clojure

15:22 Lau_of_DK: Alright, well Im pretty flexible, which I'll have to be considering im in CET

15:23 kotarak: note me down also! I'm absolutely interested.

15:24 But something earlier than 2 o'clock in the night would be good. (also CET)

15:30 gnuvince: What's a $ in an identifier? Inner-class?

15:31 kotarak: inner class

15:31 rhickey: gnuvince: yes, you'll need $ to reach a nested class

15:31 gnuvince: Thanks.

15:32 rhickey: how much Java do you think a casual Clojure programmer ought to know? I only had one (very bad) semester of Java 1.1 in school 5 years ago.

15:33 rhickey: gnuvince: you need to know very little Java syntax, but should understand the object model and how to read JavaDoc

15:33 gnuvince: OK.

15:34 rhickey: the object model is very simple single inheritance + interfaces

15:34 no need to know generics

15:34 kib2_away: rhickey: not so sure (for me indeed), playing ie with Swing if you never touched Java and Clojure before is really hard.

15:34 gnuvince: Just to make sure, inner classes are: class Foo { class Bar { /* I am an inner class */ } }?

15:37 rhickey: kib2_away: well, you do need to know some

15:37 kotarak: the problem with Java is the huge number of classes one has to understand at least a bit. JTree, TreeModel, TreeNode, TreePath, BlaLaberThingyListener, ....

15:37 rhickey: kotarak: that has more to do with Swing than Java per se

15:37 kib2_away: ThisMethodIsRatherBeautifulDontYouThinkSo ?

15:38 gnuvince: I might check out "Head First Into Java" by Kathy Sierra

15:38 kotarak: rhickey: well, that was my closest contact to java up to now. Interfaces and that isn't really a problem.

15:41 there was a google tech talk of some Java Guru, talking about interfaces, with a "don't do it like that" example where some Java library needed have a dozen classes to a simple task....

15:42 AWizzArd: kotarak: you could think about not using swing but a browser instead for displaying a gui

15:42 rhickey: kotarak: in the end, whatever pain exists in Java, Clojure can make go away

15:45 kotarak: AWizzArd: bah, I hate those browser guis.

15:47 rhickey: Clojure - a painkiller - For risks asks you doctor, side effects are forbidden. (So even better than Aspirin. :)

15:50 Lau_of_DK: kotarak, I'll fire up the T-Shirt printer :)

15:50 duck1123: I like that

15:51 gnuvince: Somebody in the Clojure Book reddit thread mentioned the Joda library. That's a very nice one!

15:52 sohail: joda = yoda?

15:52 gnuvince: I'm not sure if that's what they were going after.

15:53 sohail: my date times you have replaced

15:55 gnuvince: :)

15:55 AWizzArd: kotarak: I think in the past 10 years it were exclusively web applications that made people billionairs

15:55 gnuvince: user=> (Days/daysBetween (DateTime.) (DateTime. 2009 1 20 12 0 0 0))

15:55 P73D

16:00 kotarak: AWizzArd: I was never fond of things, which made others billionairs. (Whether these billions are reallistic or not is another story). I'm sitting in the train, no web, esoteric rays, crappy connection, annoying sluggish interface, .... I'm not a fan of having to be online all the time, to read my mails .... I'd rather have them locally with a goode olde mail reader.

16:00 sohail: AWizzArd, that is really, really ignorant!

16:01 AWizzArd: *g*

16:01 sohail: billionaire on paper doesn't count

16:01 I have a company right now that I value at 15 billion and I own half the shares, am I a billionaire?

16:01 hell no :-)

16:02 Lau_of_DK: sohail, but lets imagine that you were a billionaraire, for a second... can I borrow a few bucks? :)

16:02 AWizzArd: If you are allowed to sell them and if they are worth so much/requested so much you could do it like Bill Gates and sell them for 30 million a day

16:03 sohail: so your only example is someone who didn't make his billions via web apps :-)

16:03 Lau_of_DK, I didn't get paper rich by giving money away!

16:03 Lau_of_DK: haha

16:04 AWizzArd: I just say they could (if the law allows it) make at least a few millions per day by selling, or not?

16:04 sohail: but you said billions

16:04 anyway, I've dealt with both web app companies and traditional desktop apps... latter makes many, many times more in my experience

16:04 AWizzArd: no one has billions on his bank account.. your investment manager will "force" you to buy shares and stuff

16:05 Lau_of_DK: Guys, it would be kind of cool it we could get back into a Clojure discussion

16:05 sohail: yeah, so clojure needs to have a good qt interface to make me rich

16:05 Lau_of_DK: Have any of you made some interesting webapps with Clojure ?

16:06 AWizzArd: hmm no, don't know how to do it with the jvm..

16:09 Lau_of_DK: Nobody made anything that runs on a webserver yet?

16:09 sohail: web apps suck

16:10 Lau_of_DK: hmm, I must be gettin forgetful, sohail show me the line where I asked for your oppinion on web apps :)

16:10 sohail: <Lau_of_DK> Have any of you made some interesting webapps with Clojure ? sohail specifically, what do you think about web apps?

16:10 that's what I saw

16:10 Lau_of_DK: LOOOOOOOL

16:11 Sohail, try this out http://www.sumopaint.com/

16:12 * drewr appreciates the joda mention; very useful

16:13 sohail: Lau_of_DK, flash != web app, sorry

16:13 AWizzArd: well, they come with advantages and disadvantages

16:14 for the user it's nice that he needs no installation and gets gradual updates so easily

16:14 rhickey: let's try to stick to Clojure, please

16:20 Lau_of_DK: What are people in here doing with Clojure atm ?

16:20 Are you all building Swing apps?

16:21 drewr: Migrating massive amounts of data.

16:22 kotarak: Lau_of_DK: mainly libraries, but also a Swing app, and tools for Vim mainly...

16:22 Chouser: procrastinating

16:22 duck1123: I'm working on a web app

16:23 AWizzArd: Lau_of_DK: I am testing performance of agents, and I will need tons of them, cause I am looking into porting my Genetic Programming system from Common Lisp to Clojure

16:23 Lau_of_DK: Sounds like you guys are doing some advanced stuff

16:24 AWizzArd: And I am having memory problems, and maybe rhickey or someone else has an idea why:

16:24 lisppaste8: AWizzArd pasted "Running into problems with the Java Heap" at http://paste.lisp.org/display/69919

16:25 AWizzArd: It runs okay when doing a few 100k iterations

16:27 Could it have to do with (fak 35) resulting in a BigInteger which does not get GCed fast enough?

16:27 rhickey: AWizzArd: you are awaiting nothing

16:27 AWizzArd: I thought await would wait until the current thread finished all agents

16:27 rhickey: agents don't run on the current thread

16:27 you can await for specific agents

16:27 AWizzArd: damn, right

16:28 yes, I usually do that

16:28 in this example I wanted to use anonymous agents, but anyway, even if I can't time this correctly right now it still runs into memory problems

16:30 rhickey: AWizzArd: you'll have to allocate enough memory to hold your agents, I have problems with -Xmx1024M

16:31 I have no problems

16:32 Lau_of_DK: huh? You have problems with -Xmx1024M but you have no problems?

16:33 rhickey: a type

16:33 AWizzArd: I think he means when he runs it with 1g it won't cause memory problems

16:33 rhickey: typo

16:33 AWizzArd: okay, so the problem is in the queue? It stores the calls faster than working them off

16:33 Lau_of_DK: oh

16:33 rhickey: AWizzArd: or whatever, it's just a memory allocation/usage thing

16:33 AWizzArd: good good, that is fine for me

16:34 I will then configure slime to run clojure always with 1024M

16:34 rhickey: I don't know exactly how much you'll need, but -server and -Xmx can help

16:34 AWizzArd: rhickey: do you see a good reason to *not* run Clojure with the -server flag when developing?

16:34 rhickey: the important thing is, no problem having that many agents

16:35 AWizzArd: I always run with -server

16:35 AWizzArd: yes, I see, that's good news, so it just means I need more memory

16:35 funny that the default seems to be just these 128mb

16:50 I remember that I got emacs to show me a gui in which I could configure slime/swank/clojure, but I forgot how to do it. Anyone here maybe knows how?

16:53 Lau_of_DK: If the GUI is called firefox and the contents was the Clojure-wiki, then yes, I can point you in the right direction

16:55 AWizzArd: I was running some emacs command and inside emacs there were some options I could set, for example the path to java, etc

16:57 ah yes, M-x customize-group swank-clojure

16:57 Lau_of_DK: cool, I'll have to try that out

17:26 AWizzArd: is there a way to see in the repl with what command line arguments Java was started?

17:26 (like -server -Xmx1024M and so forth)

17:30 rhickey: (.maxMemory (Runtime/getRuntime))

17:30 (System/getProperties)

17:36 AWizzArd: thx

17:36 Hun: AWizzArd: customize-group slime

17:36 oh, you found that already :)

17:37 AWizzArd: yes, but thanks

17:37 Hun: hmm... reading history forwards does not work. backwards neither. any suggestions for better reading? :)

17:39 AWizzArd: Will AOT mean that one can compile all clojure code into .class files and that way is not forced to deliver source code to customers?

17:39 rhickey: AWizzArd: yes

17:40 solkis: What function can I use to determine if a variable has already been bound using def? I need to only initialize something once with an if.

17:41 rhickey: solkis: there is defonce

17:42 solkis: rhickey: thx, that's what I need

17:42 lisppaste8: Chouser pasted "new doseq" at http://paste.lisp.org/display/69926

17:42 rhickey: also (.isBound #'foo)

17:43 Chouser: ugleee but it produces good code (re: doseq)

17:44 hm, it'd be simpler if I left "when" blocks in but used "true" if no :when or :while was given.

17:44 is that too much slower?

17:44 AWizzArd: Good code in what way? You mean efficient?

17:45 rhickey: Chouser: that's what for does IIRC

17:45 simpler is better, HotSpot will remove later

17:46 AWizzArd: Btw, are there already any real world apps written in Clojure yet?

17:47 Lau_of_DK: rhickey, apropos the study group you mentioned earlier, where do I sign up?

17:48 rhickey: Lau_of_DK: when I get some time to organize it, I'll post on the group to measure interest

17:48 Lau_of_DK: Alright, I'll be patiently waiting.

17:50 solkis: Anybody know how to restart (basically clear out) a slime environment in emacs? I just want a fresh REPL with nothing yet defined.

17:53 Chousuke: IIRC there was a slime-reset or something like that

17:54 though you could just kill the clojure repl and restart slime.

17:57 AWizzArd: solkis: you could also just delete all vars from within clojure

17:57 solkis: Chousuke: thx

17:58 AWizzArd: just for fun, how would you do that?

18:01 lisppaste8: solkis pasted "Clojure Java GTK Sample" at http://paste.lisp.org/display/69927

18:01 AWizzArd: solkis: (map #(ns-unmap 'user %) (keys (ns-interns 'user))) where 'user is your namespace

18:03 solkis: AWizzArd: thx, I'll figure that one out as an exercise in Clojure :-)

18:03 AWizzArd: it will kill everything in that namespace that you set up via def or defn

18:05 solkis: Also, I just pasted a short example (based on anther one I saw in the archive) using clojure and the java gtk bindings (I'd never used them and I thought it might be fun.) The original Java example was here: http://java-gnome.sourceforge.net/4.0/doc/examples/button/ExamplePressMe.html

18:06 AWizzArd: solkis: or even better is Chousers version: (doseq [n v] (ns-interns *ns*) (ns-unmap *ns* n))

18:06 solkis: AWizzArd: thx

18:39 Lau_of_DK: Potentially dumb question: Im sitting here on my very first Dual-core system ever. And I wonder why, if I start up some large computation in Clojure, that it only utilizes 1 CPU 100% and the other is resting at around 20%. ?

18:47 ivan: you're right, that is pretty dumb :)

18:47 are you expecting it to parallelize?

18:48 Lau_of_DK: I was actually expecting it to use the full capacity of the system - I mean, whats the idea of a high level language anyway ?

18:51 ivan: i really have little clue

18:51 but http://clojure.org/concurrent_programming suggests that you manage the concurrency for now

18:51 AWizzArd: Lau_of_DK: this is not possible the way you think about it

18:52 Lau_of_DK: You mean in terms of raw power and utilization ?

18:52 AWizzArd: you will need to inform Clojure what exactly it should run

18:52 Clojure itself will run in only one thread all the time if you don't do anything against that.

18:53 the problem is: threads cause overhead

18:53 rhickey: AWizzArd: there is pmap and the parallel lib, but otherwise, yes

18:53 AWizzArd: rhickey: sure, and I am adding more parallel mapping functions

18:54 Lau_of_DK: Clojure should not simply go around and let each function call run in its own thread

18:54 Lau_of_DK: AWizzArd, can you define 'overhead' for me ?

18:54 AWizzArd: if you want to do (count my-vector) then this can be done within a few microseconds

18:55 but if you would say: hey Clojure, run this in a thread, then some extra work needs to be done

18:55 your thread has its exclusive copy of "global vars"

18:55 and some scheduling must be done, etc

18:55 Chousuke: Lau_of_DK: The main problem is, clojure can't tell which operations are safe to parallelise, or whether it makes sense.

18:55 Lau_of_DK: so you need to take care of it manually.

18:55 AWizzArd: so in the end your (count my-vector) in its own thread will take some thousand or ten thousand microseconds

18:56 Lau_of_DK: Okay I get what you guys are saying

18:56 Thanks alot

18:56 AWizzArd: in principle everything should be safe to parallelize in a pure functional environment, but yes, detecting this is also not so easy

18:57 Lau_of_DK: if you have a function that will run for 1 second or longer, then you could decide to give it its own thread

18:57 because the administrative work of the JVM of 2 msecs is not important then anymore

18:58 Lau_of_DK: Ok

18:58 AWizzArd: you will benefit of having 2 calls running at the same time and finish after 1.002 seconds, vs 2 secs with just one thread

18:58 it could be interesting to know where the break-even point is

18:59 Lau_of_DK: But the possibilities for improvements are quite large I see

18:59 AWizzArd: Lau_of_DK: and btw, threads make sense for positive user experience

18:59 Chousuke: there are algorithms that really don

18:59 don't gain benefit from parallelisation

18:59 Lau_of_DK: Yea I know

19:00 AWizzArd: if your application is used by several people at the same time then running their requests in different threads. Just imagine google replying: sorry, can't search because someone else is doing that right now :-)

19:01 but Clojure makes it very easy for you to run your code in parallel

19:01 Chousuke: functional languages in general make it less troublesome I suppose.

19:01 AWizzArd: exactly

19:03 In principle we try to make as much code as possible a mathmatical function. It depends only on it's arguments and will always return the same result when given the same args. In that case it doesn't matter on what processor you run (+ 1 3)

19:25 Lau_of_DK: I gots to the hit sack, thanks for all the input guys

20:08 rhickey: Note on SVN rev 1089:

20:08 Interim checkin - DO NOT USE!!

20:08 Unless you are interested in helping test:

20:08 new print-dup functionality for replica generation of compilation constants

20:08 new *print-dup* flag, prints duplicators

20:08 back to simplified readably printing for repl

20:08 readable fns, as long as they are not closures

20:14 AWizzArd: yummy

20:43 lisppaste8: Chouser annotated #69926 with "simpler doseq" at http://paste.lisp.org/display/69926#1

20:55 djkthx: why doesn't this return true?

20:55 user> (false? (let [a (make-array (. Boolean TYPE) 10)] (aget a 0)))

20:55 false

20:55 ?

20:56 all the values are false in the array

21:02 duck1123: but it's an array of non-zero size

21:03 pjb3: djkthx: false? returns true if it's argument is false, otherwise false

21:03 (false? [false]) => true

21:03 err (false? [false]) => false

21:03 I meant

21:05 oh wait, I didn't see the last part of your expression

21:05 djkthx: but i'm just taking one of the elements

21:05 yeah

21:06 user> (let [a (make-array (. Boolean TYPE) 10)]

21:06 user> (let [a (make-array (. Boolean TYPE) 10)] (aget a 0))

21:06 false

21:06 is what aget returns

21:06 pjb3: (= (. Boolean TYPE) false) => false

21:06 djkthx: ah

21:08 pjb3: (= (new Boolean false) false) => true

21:08 djkthx: yeah

21:09 yay, got it working

21:09 alright, thanks :)

21:25 does anyone have a sample clojure prime sieve function?

21:26 i had a nice one in common lisp, but it used type declaration and mutable bit-vectors, which i'm not sure how to replicate in clojure...

21:26 i tried copying my CL function, but it wasn't nearly as fast

21:27 user> (time (last (sieve 100000)))

21:27 "Elapsed time: 5950.069 msecs"

21:27 99991

21:27 in clojure

21:27 NIFTY-FUNS> (time (last (sieve5 100000)))

21:27 Evaluation took: 0.001 seconds of real time

21:27 0.001421 econds of total run time (0.0(01413 user, 0.000008 system) 100.00% CPU

21:27 2,829,528 processor ycles 90,112 bytes consed

21:27 (99991)

21:27 in sbcl

21:58 ah, cool

21:58 type declarations helped out quite a bit

22:53 is there a tab completion for symbols in clojure-mode?

22:54 drewr: I can ESC-TAB, but that might be SLIME.

22:55 duck1123: M-/

22:55 djkthx: ah, there we go

22:55 thanks duck1123

22:56 duck1123: np

22:56 djkthx: do you know the name of the function so i could rebind it to tab?

22:57 duck1123: dabbrev-expand

22:58 a little tip. C-h k then a keystroke will give info about the command

22:58 C-h c does similar, but only shows minimal info

22:59 djkthx: cool

22:59 thanks

23:00 duck1123: you also might want to bind hippie-expand instead

23:00 it uses multiple methods

23:00 djkthx: multiple methods?

23:01 is that like slime-fuzzy-completion?

23:01 duck1123: there are several different completion algorithms, it'll try them in order

23:01 djkthx: ah

23:01 duck1123: I'm not familiar with that one

23:02 djkthx: i used it with common lisp

23:02 duck1123: also, if you like using [tab] check out pabbrev-mode

23:02 djkthx: typing m-v-b and tab would give multiple-destructuring-bind

23:02 duck1123: I use it all the time with ruby, but havn't gotten around to hooking it to clojure-mode

23:02 djkthx: gotcha

23:09 blah, emacs

23:09 i can't seem to rebind this stupid key

23:10 duck1123: how are you doing it?

23:10 djkthx: (global-set-key (kbd "TAB") 'dabbrev-expand)

23:10 tried dabbrev-completion also

23:11 i put it in my run-clojure fun

23:11 so it would only redifine it if i was using clojure-slime

23:11 redefine*

23:12 duck1123: in that case (define-key clojure-mode-map (kbd "TAB") 'dabbrev-expand)

23:13 although I'm not sure if (kbd "TAB") is the right syntax

23:14 djkthx: i believe it is

23:14 duck1123: modify to taste: (add-hook 'clojure-mode-hook '(lambda () (define-key clojure-mode-map (kbd "C-x C-e") 'lisp-eval-last-sexp))))

23:15 djkthx: wait, do i need both?

23:16 im not terribly well versed in emacs config stuff...

23:17 duck1123: if you replace that second thing I sent with your commands, it'll load that key binding when clojure-mode is loaded

23:17 djkthx: gotcha

23:17 duck1123: I just copied that out of my init.el file, so I didn't bother fixing it

23:19 djkthx: got it working, thanks :)

23:19 duck1123: cool

23:20 djkthx: i feel ready to get down to some clojure hacking now

23:21 duck1123: I need to set up a global lisp eval binding so I can eval stuff out of irc windows

23:21 djkthx: that'd be pretty slick

23:25 duck1123: ok, someone send a clojure form

23:26 (+ 2 2)

23:26 djkthx: (* 1 2 3 4)

23:26 duck1123: didn't work the way I wanted

23:26 djkthx: (map (fn [x] (* x x)) (range 1 10))

Logging service provided by n01se.net