#clojure logs

2008-07-30

00:00pjb3shoover1: that does it, thanks!
00:03shoover1pjb3: No problem. But by the way, I'm not sure why you don't have Compiler.loadFile, because I have it in my svn checkout and I think it's been around a while.
00:05shoover1It also worked with the foo.invoke code, as long as you call something in RT before Compiler.loadFile to get the runtime initialized.
00:09pjb3 have a Compiler.loadFile, I was having IDE issues :)
00:10pjb3but RT.loadResourceScript works too
00:49shoover1For future reference I added the above code to the wiki (tweaked to show foo accepting parameters from the Java code): http://en.wikibooks.org/wiki/Clojure_Programming#Clojure_for_Java__Programmers
05:51mac__Hello all, is there a static method version of doto available? Or is there some clever way to get the same effect as doto on static methods? I got some java classes with a bunch of static methods that need to be called in succession and it's getting tiresome to write out the class names all the time. Or should I try to make my own macro, like sdoto or something?
06:15hoeckmac__: i haven't found one
06:16mac__Alright, guess I'll make my own macro then. Just thought I'd ask if anyone knew of anything first. Stupid to re-invent stuff ;)
06:18hoeckin your case, you would just need to remove the let in the doto macro to make it an sdoto
06:18hoeckare you doing opengl stuff?
06:19hoeck(thats the only api i know where one has to make several static method calls in row)
06:33mac__yep
06:34mac__using lwjgl
08:17Chousershoover: oh, good. That'll be helpful.
09:02cemerickrhickey: is there any reason why you don't specify a charset when opening a reader in Compiler.loadFile? UTF-8 would seem to be the most reasonable default.
09:05rhickeycemerick: what's the default?
09:06cemerickrhickey: it's system-dependent -- the value of the file.encoding system property. "MacRoman" on my system right now.
09:07rhickeyick
09:07cemerickGiven that, any strings that contain non-ascii unicode characters are generally read incorrectly. Either the reader needs to watch for a per-file encoding indicator in a special comment, or just default to UTF-8 (my vote, certainly).
09:08rhickeycould you please post this on the group - I'm fine with it, but would like to get broader input first - thanks
09:08cemericknp
09:45cemerickrhickey: just out of curiosity, are you planning on accepting the PersistentStructMap patch I posted with the genbean impl?
09:53rhickeycemerick: done, rev 976
09:53cemerickrhickey: ah, thanks very much -- I figured you were still thinking about it :-)
09:54rhickeycemerick: no, I just didn't realize they were separate patches (not ready for genbean yet)
10:31jykrdwould you say that clojure is easier to learn than, say, lisp or scheme, or harder?
10:49arbschtjykrd: for whom? between those three languages, I'd say it's subjective
11:06jykrdarbscht: for the beginner
11:10arbschtjykrd: I can't imagine that clojure is conceptually any harder than another lisp or scheme
11:10jykrdso probably just about the same then, eh?
11:10cemerickI'd say it's clearly easier to jump into than CL; it's probably on par with various schemes, though.
11:11arbschtconsidering the raw volume of documentation, and the fact that clojure is rapidly developing, maybe it is harder for a beginner to learn clojure right now. I don't know
11:11ChouserIf you're used to other languages, the immutability of Clojure can be tricky at first.
11:12ChouserBut it's so much smaller than Common Lisp, that's a huge help.
11:22arbschteven CL's mutability can be equally tricky for such a person
11:26jykrdyea, it's such a subjective question.. Especially when you try to compare the learning curve to something like python, ruby, or even java
11:32jykrdI'm already biased because I've already learned the way to work with those imperative language styles
12:02jykrdI think it's a good question, nevertheless. How early can we start teaching programming in schools? How conducive are the design of new programming languages to process of educating and learning in grade-school. I guess the axiomatic structure of lisp-like languages -- with higher constructs being built out of a small subset of constructs -- might lend itself to the methods of learning and education.
12:02jykrdYou'd just have to get them early
12:24ChouserI think you're asking the education question the wrong way 'round. I want to know how I can best design education to teach prinicples that are needed in the best new languages.
12:25ChouserI've been mulling some kind of game or virtual play environment where kids could attach clojure code to objects and see how they interact.
12:26Chouserlike logo, except functional instead of imperative.
12:27jykrdIt was actually seeing scratch (http://scratch.mit.edu/) today that prompted my comment
12:29Chouserhm!
12:31jykrdthis one is neat http://scratch.mit.edu/projects/Cyclone103/221614
12:34cemerickhttp://www.alice.org is pretty slick -- very smalltalk-ish
12:36Chouserscratch is cool, but looks pretty imperative. I really wonder if imperative is inherently simpler for kids to understand, or if it's just how most of us are used to programming.
12:38jykrdwell, I think recursion is inherently more advanced than a sequential form
12:39jykrdbut recursion, as a concept, by itself, I don't think is beyond the intellect of an elementary school kid
12:41Chouseryeah, I guess recursion is harder than a looping construct in a lot of cases.
12:41jykrdI'm not sure if immutability is inherently more unintuitive than mutability. I'm biased, coming from the mutable world.
12:41Chouserbut with high-order functions, you can often do with no loop or recursion at all. I wonder how hard high-order would be for a kid.
12:42slavai find higher order functions easier than both explicit recursion and looping syntax
12:42jykrdBut I still feel like my hands are a bit tied.. like I have a lot less options. that may change though
12:42Chouseralso, I wonder if loop/recur could be taught or thought of in a way that doesn't really feel like rursion or carry the mental complexity of it.
12:43jykrdI still don't know what the canonical definition of "higher-order" is
12:43slavaa function taking another function
12:43slavaor returning another function
12:43jykrdI don't think that's necessarily harder for a kid
12:44ChouserOne thing to consider about toy languages like logo or scratch is that you're capped -- once you hit its limit, you may have some concepts you can carry with you, but you're going to need a "real" language.
12:44ChouserThat was a huge barrier for me when I learned BASIC very young, and it's one reason I'm curious to see what happens with some of these kids who are learning python.
12:45jykrdin the sense that python is a "real" language?
12:46Chouseryes, to the extent that it's got all the platform support and library selection you need to tackle any real-world problem.
12:46slavaexcept for anything that requires performance
12:46Chousernetworking, 3d graphics, web apps, GUI apps, etc.
12:47Chouserthe resource-sharing community around scratch looks really good.
12:49jykrd"a function taking another function..." question: that's not the same thing as a function taking an object, is it?
12:49jykrdseems like a silly question
12:50dudleyfIt can be, if functions are also objects
12:50jykrdI understand the difference, lexically, between a function and an object... but, numberObject.increment is a function, right?
12:50Chouserjykrd: you're not entirely off-base. In languages where functions are not themselves objects, you can accomplish something similar by taking an object that just has a single method named something like "run"
12:51slavajykrd: its best not to map everything back to java syntax
12:52jykrdso, a language where "everything is an object".. what about "everything is a function"
12:52slavalambda calculus
12:52Chouserjykrd: ok, so you have this person object -- what does it do if you call it?
12:53jykrddepends how you call it? person returns person?
12:54ChouserI guess my point is that some objects don't make much sense as a function, so "everything is a function" might not help you much.
12:55Chouseron the other hand, being able to treat functions like an object (pass them around, store them in a list, etc.) has lots of surprising and useful benefits.
12:56jykrdthe comment about kids understanding higher-order functions is what prompted the line of thought
12:57jykrdif one didn't have differentiate, at the syntactical level, between primitives, objects, functions, would that make things easier to understand?
12:58Chouserthat's one reason I think a lisp might be easy to teach -- no syntactic difference between anything. :-)
12:58jykrdagreed.
12:59Chousermy oldest isn't quite ready to learn such things, and hasn't shown interest anyway, but I'd like to have something to reach for when one of them finally wants to take control of the computer (if they ever do).
13:00ChouserI'd hate to send them on an imperitive or toy-language dead-end if there's any chance a better option would be accessible for them.
13:03jykrdwell, there's always squeak (http://www.squeak.org/)
13:03jykrdoh wait.. looks like scratch is an offshoot of squeak :)
13:04jykrdI guess scratch has smalltalk underneath it
13:06jykrdbbiab
14:39drewrWhat's everybody doing with LOAD-FILE regarding relative paths?
14:41cemerickdrewr: I understand that a relative file loading mechanism either exists in clojure-contrib/lib, or is planned.
14:41cemerickso far, we don't have any multi-file namespaces, so lib/use is sufficient
14:41drewrI would like to use lib.clj, but how can I bootstrap it without a known path somewhere?
14:42drewrThis is the first time I've really tried to break out some clojure into a modular file structure.
14:43ChouserI think the "normal" way right now is to make sure lib.clj is in your classpath, and then use (clojure.lang.RT/loadResourceScript "lib.clj")
14:43cemerickdrewr: Put a form like (. clojure.lang.RT (loadResourceScript "lib.clj") in a user.clj file in a top-level of your classpath.
14:44cemerickor that :-) (although the user.clj route ensures that lib is loaded right at clojure's init, and done only once)
14:45cemericklib will become part of core clojure eventually, or so I've heard
14:48Chouseryeah, putting it in user.clj is probably a good idea. I don't user user.clj at all currently.
14:49kotarakI use it for lib and bye (= (. java.lang.System exit 0))
14:49cemerickThe only downside to that is if your user.clj is shadowed by another user.clj in a jar file or directory further up the classpath. We may set things up so that lib.clj is loaded from Java, for those projects that are deployed elsewhere.
15:40drewrSo, ADD-CLASSPATH followed by a loadResourceScript doesn't seem to work.
15:41drewrDoes ADD-CLASSPATH manipulate something different than the "official" classpath?
15:42rhickey__drewr: it can only manipulate the loader use by Clojure, not the loader that loaded Clojure, which is what resolves loadResourceScript
15:57cemerickwhoa, the ALL-CAPS thing is making my eyes bug out ;-)
15:59drewrcemerick: Sorry, but I prefer disambiguation.
16:07Chouserexcept that clojure is case sensitive, so it's not really the same thing. If we came up with some convention, I could use a different font and maybe even syntax hiliting in the web-based log.
16:07ChouserI've been mulling this for a while, and haven't come up with a single viable convention.
16:08Chouser<in-ns>, (in-ns), IN-NS, *in-ns*, CLOJURE: in-ns, (CLOJURE in-ns), etc. each have their own overwhelming drawback.
16:09cemerickis disambiguation in irc really a cause for concern?
16:10drewrI prefer to waste as little time as possible.
16:12Chouserdrewr: if you know the classpath you want to add for loadResourceScript, can't you just use load-file directly?
16:12Chouseroh, you probably want to put it in a .jar. nm.
16:13drewrChouser: I probably could for my current situation, but I'd rather have a generic way of doing it.
22:56arohneris anyone else having problems checking out clojure-contrib from sourceforge?
23:05Chouseryep, connection reset by peer