#clojure log - Jun 27 2008

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

1:42 Lau_of_DK: Morning!

1:42 Question: Does any of Clojure's concurrency features help me, when multiple programs access the same file?

1:55 cgrand: multiple programs = multiple threads lauched from clojure or multiple processes?

2:02 if it's inside clojure you can use an agent to enforce serial access to some resource (eg a file)

2:04 Lau_of_DK: Its about 20 users who are going to submit data to the same XML file

2:07 cgrand: but 20 users going through 1 instance of your app or 20 users going through 20 instances of your app or ...?

2:11 Lau_of_DK: 20 instances

2:15 cgrand: then Clojure won't help you -- except if you break your app in two: client and server (which only purpose would be to handle writes to the xml file send from the clients)

2:48 Lau_of_DK: Thats what I figured - I wondered if thats really complicated though :)

9:09 cemerick: I'm just now looking at lib.clj -- having a couple of issues, though. (a) isn't require supposed to fail if it can't load a library, and (b) what's the correct incantation to get require/use to grab a library from a package? I have foo.clj in com/pkg, and none of these seem to work: (use com.pkg.foo) (use "com.pkg.foo") (use 'com.pkg.foo), etc.

9:10 I feel like I'm missing something fundamental here. (using r55 out of svn, btw)

9:28 Chouser_: I still haven't tried out lib.clj, sorry.

9:40 spacebat_: hi, I'm not having much luck with clojure, I guess its going to take a while for the alien tech to sink in

9:40 Chouser_: spacebat_: what's the problem?

9:41 spacebat_: I guess there's the problem of not knowhing where to start, I'm used to imperative languages

9:41 half of the terminology is fairly opaque since I'm not steeped in lisp/scheme

9:42 someone helped me last week to count the invocations of a function with a Var, using bindings

9:42 but I'm not sure what that's really for or why it works

9:43 rhickey: spacebat_: what languages do you know?

9:43 spacebat_: c/c++/java/perl/python, the usual suspects

9:44 I'm familiar with the term binding of variables

9:45 but def's third argument has something to do with a Root, which I don't get

9:45 rhickey: http://en.wikibooks.org/wiki/Clojure_Programming#Examples has a version of a program and a link to a description of how it works and an implementation in Python

9:45 the spelling corrector

9:45 spacebat_: cool thanks

9:46 I just started working through practical_clojure.clj because I recently did that capter in practical common lisp

9:46 Chouser_: I do think functional languages import a bunch of jargon that isn't used in the imperative world.

9:47 spacebat_: oh I just sorted one problem, I'm using a script I got to start clojure from the command line

9:48 when my cwd isn't the clojure build dir, I get exceptions about wrong number of args for set, and strcat not found in this context

9:49 rhickey: http://blip.tv/file/982823 is a gentle introduction of Clojure oriented towards Java programmers

9:49 spacebat_: but when I run it from the build dir it works, so I mustn't be setting up the environment properly

9:49 thanks again rhickey

9:49 Chouser_: strcat has been gone a long time, i think. What is trying to call strcat?

9:49 spacebat_: half the clojure source code on the net

9:50 ;)

9:51 what should I use instead of strcat?

9:51 Chouser_: probably just str

9:51 rhickey: http://en.wikibooks.org/wiki/Clojure_Programming#Where_did_the_x_function_go.3F

9:52 spacebat_: strangely it was seeing Language::Lisp::ECL on the CPAN that pushed lisp over the threshold from vague interest to "I've got to learn this"

9:52 about two weeks ago

9:53 I like that ECL has C linkage so its very interoperable

9:53 Chouser_: It's great you found your way from lisp in general to Clojure. I've tried to learn LISP (mainly Common Lisp) before, and it just never happened. Clojure's going swimmingly for me.

9:53 spacebat_: that's also what I like about clojure, the library problem is conveniently solved by java interop

9:54 would it be fair to say that clojure is close to being a scheme (except the lack of continuations and tail recursion optimization)

9:55 its the square brackets floating around that make me wonder

9:55 rhickey: Those 2 make it pretty definitively not Scheme

9:56 spacebat_: yes, I thought someone would say that :)

9:56 rhickey: Square brackets are synonyms for parens in Schemes, whereas they represent real vectors in Clojure

9:56 spacebat_: worked as a java programmer for a few years, but it was a dismal company making online casino software

9:57 rhickey: Of CL and Scheme, I think Clojure shares more mindset with CL

9:57 Being functional sets it apart from either

9:57 spacebat_: I don't really like writing java code, too verbose, so I toyed with Jython but its a bit rough, hope to see it improve

9:58 perhaps clojure will be my way back to using things from the java universe

9:58 scgilardi: Hi folks. Is cemerick here? I have some answers about lib.clj.

9:58 spacebat_: thanks for the insight rhickey

9:59 I know that things are moving quickly, its good that there are so many resources alredy

10:00 is there a docstring convention for clojure and/or a help function to read them?

10:00 rhickey: spacebat_: sure - stick with it, and especially look into refs and transactions. Clojure is actually for solving the problems one solves with C#/Java. It supports functional programming _and_ sane state

10:02 spacebat_: when I mention the properties of clojure to some people, they sometimes mention erlang

10:02 I guess with the right libs that sort of distributed fault tolerant concurrency would be in easy reach

10:03 rhickey: Clojure currently only addresses the non-distributed case

10:04 spacebat_: yes, and distributing things is probably best left to the libs

10:04 rhickey: With, IMO, a much more approachable model than Erlang's

10:06 spacebat_: thanks guys, I'm making some progress now, cheers for now

10:07 scgilardi: rhickey: currently loadResourceScript silently fails if the resource doesn't exist. I would prefer it to either throw an exception or return an indication of failure. Would you consider that?

10:12 rhickey: scgilardi: yes, something, either taking a flag indicating throw if not found or a return value. Unconditional throw is out, as I use it for speculative reads and don't like EH for flow control

10:13 scgilardi: thanks for all your help on the group

10:16 scgilardi: ok, cool. is it for user.clj that it's speculative? A return value seems a little cleaner than a flag, but either would work for me.

10:17 you're quite welcome. I'm glad to see interest in clojure (as indicated by new folks in the group) on the upswing. I'm happy to help out with the easy stuff.

10:55 jmbr: hi

10:57 Chouser_: jmbr: hi

12:13 cemerick: darn, I missed scgilardi :-(

13:44 Having a :deprecated key in def metdata will eventually be useful for enclojure (and maybe the future when clojure can emit classfiles ;-))

15:28 looks like both clojure.lang.Repl and enclojure's repl force printing of lazy seqs....

15:30 ...which makes sense, as there's no lazy?, or other way to determine whether a seq is lazy or strict.

15:33 rhickey: You mean when it is the value returned to the Repl?

15:35 you could never really tell if a seq is lazy, as lazy and strict 'links' can be chained together

15:35 cemerick: Yes.

15:35 Yeah, you're right.

15:35 One of the nifty things about scala's repl is that it prints something like [1 2 3 4 5 ...] for streams.

15:36 Chouser_: I'm not sure how useful it would be, but I suppose ISeq could support some sort of "rest-computed?" flag.

15:36 cemerick: I just had to kill netbeans because the repl was rendering the result of drop on an infinite seq :-P

15:36 rhickey: Clojure just needs CL's *print-length* et al

15:37 cemerick: (that will eventually be unnecessary with some judicious enclojure patches, etc)

15:37 rhickey: nothing to do with laziness

15:37 cemerick: I stand corrected. All of the CL work I've done has been very imperative.

16:01 I'm seeing (old) examples that include hints like #^float, but using such things yields an exception (class not found). The primitives section only lists hints for primitive arrays; has simple primitive hinting changed, or gone away?

16:02 rhickey: I'm not sure #^float ever worked (#^Float did and does) - where did you see that?

16:02 cemerick: ah, #^{:tag (.TYPE Float)} works

16:03 let me see if I can fish that link up again...

16:03 #^Float is java.lang.Float though, right, not Float.TYPE?

16:04 rhickey: It's enough for the inference engine. These tags are for boxed things

16:04 cemerick: rhickey: http://blog.finiteimprobability.com/2008/03/27/picnic-invasion-obtimization-explorations/ , which was discussed briefly here: http://groups.google.com/group/clojure/browse_frm/thread/44d84d98372fb177

16:04 right, right -- I forgot that you always emit boxed types, and let hotspot figure it out

16:05 rhickey: the difference is, now (let [i (int 7)] ...) makes i a primitive int

16:06 only that, or a primitive return value, can give you a primitive local

16:07 unboxed

16:12 (let [#^float f 7] f) doesn't fail, that's why his code didn't either - the compiler never needs to use the hint (e.g. interpret it as a class)

16:13 cemerick: Thanks much. :-)

16:14 Interestingly, you can't set *warn-on-reflection* to true in enclojure -- it snaps back to false automagically (or maybe is never changed to begin with).

18:09 jgrant: how do you access command line vars passed to a clojure prog ?

18:09 rhickey: *command-line-args*

18:10 jgrant: thx

Logging service provided by n01se.net