2008-06-27
| 01:42 | Lau_of_DK | Morning! |
| 01:42 | Lau_of_DK | Question: Does any of Clojure's concurrency features help me, when multiple programs access the same file? |
| 01:55 | cgrand | multiple programs = multiple threads lauched from clojure or multiple processes? |
| 02:02 | cgrand | if it's inside clojure you can use an agent to enforce serial access to some resource (eg a file) |
| 02:04 | Lau_of_DK | Its about 20 users who are going to submit data to the same XML file |
| 02:07 | cgrand | but 20 users going through 1 instance of your app or 20 users going through 20 instances of your app or ...? |
| 02:11 | Lau_of_DK | 20 instances |
| 02: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) |
| 02:48 | Lau_of_DK | Thats what I figured - I wondered if thats really complicated though :) |
| 09: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. |
| 09:10 | cemerick | I feel like I'm missing something fundamental here. (using r55 out of svn, btw) |
| 09:28 | Chouser_ | I still haven't tried out lib.clj, sorry. |
| 09: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 |
| 09:40 | Chouser_ | spacebat_: what's the problem? |
| 09:41 | spacebat_ | I guess there's the problem of not knowhing where to start, I'm used to imperative languages |
| 09:41 | spacebat_ | half of the terminology is fairly opaque since I'm not steeped in lisp/scheme |
| 09:42 | spacebat_ | someone helped me last week to count the invocations of a function with a Var, using bindings |
| 09:42 | spacebat_ | but I'm not sure what that's really for or why it works |
| 09:43 | rhickey | spacebat_: what languages do you know? |
| 09:43 | spacebat_ | c/c++/java/perl/python, the usual suspects |
| 09:44 | spacebat_ | I'm familiar with the term binding of variables |
| 09:45 | spacebat_ | but def's third argument has something to do with a Root, which I don't get |
| 09: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 |
| 09:45 | rhickey | the spelling corrector |
| 09:45 | spacebat_ | cool thanks |
| 09:46 | spacebat_ | I just started working through practical_clojure.clj because I recently did that capter in practical common lisp |
| 09:46 | Chouser_ | I do think functional languages import a bunch of jargon that isn't used in the imperative world. |
| 09:47 | spacebat_ | oh I just sorted one problem, I'm using a script I got to start clojure from the command line |
| 09:48 | spacebat_ | 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 |
| 09:49 | rhickey | http://blip.tv/file/982823 is a gentle introduction of Clojure oriented towards Java programmers |
| 09:49 | spacebat_ | but when I run it from the build dir it works, so I mustn't be setting up the environment properly |
| 09:49 | spacebat_ | thanks again rhickey |
| 09:49 | Chouser_ | strcat has been gone a long time, i think. What is trying to call strcat? |
| 09:49 | spacebat_ | half the clojure source code on the net |
| 09:50 | spacebat_ | ;) |
| 09:51 | spacebat_ | what should I use instead of strcat? |
| 09:51 | Chouser_ | probably just str |
| 09:51 | rhickey | http://en.wikibooks.org/wiki/Clojure_Programming#Where_did_the_x_function_go.3F |
| 09: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" |
| 09:52 | spacebat_ | about two weeks ago |
| 09:53 | spacebat_ | I like that ECL has C linkage so its very interoperable |
| 09: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. |
| 09:53 | spacebat_ | that's also what I like about clojure, the library problem is conveniently solved by java interop |
| 09:54 | spacebat_ | would it be fair to say that clojure is close to being a scheme (except the lack of continuations and tail recursion optimization) |
| 09:55 | spacebat_ | its the square brackets floating around that make me wonder |
| 09:55 | rhickey | Those 2 make it pretty definitively not Scheme |
| 09:56 | spacebat_ | yes, I thought someone would say that :) |
| 09:56 | rhickey | Square brackets are synonyms for parens in Schemes, whereas they represent real vectors in Clojure |
| 09:56 | spacebat_ | worked as a java programmer for a few years, but it was a dismal company making online casino software |
| 09:57 | rhickey | Of CL and Scheme, I think Clojure shares more mindset with CL |
| 09:57 | rhickey | Being functional sets it apart from either |
| 09: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 |
| 09:58 | spacebat_ | perhaps clojure will be my way back to using things from the java universe |
| 09:58 | scgilardi | Hi folks. Is cemerick here? I have some answers about lib.clj. |
| 09:58 | spacebat_ | thanks for the insight rhickey |
| 09:59 | spacebat_ | I know that things are moving quickly, its good that there are so many resources alredy |
| 10:00 | spacebat_ | 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 | spacebat_ | 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 | rhickey | 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 | scgilardi | 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 | cemerick | Having a :deprecated key in def metdata will eventually be useful for enclojure (and maybe the future when clojure can emit classfiles ;-)) |
| 15:28 | cemerick | looks like both clojure.lang.Repl and enclojure's repl force printing of lazy seqs.... |
| 15:30 | cemerick | ...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 | rhickey | 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 | cemerick | Yeah, you're right. |
| 15:35 | cemerick | 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 | cemerick | 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 | cemerick | let me see if I can fish that link up again... |
| 16:03 | cemerick | #^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 | cemerick | 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 | rhickey | only that, or a primitive return value, can give you a primitive local |
| 16:07 | rhickey | unboxed |
| 16:12 | rhickey | (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 | cemerick | 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 |