#clojure log - Jul 30 2008

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

0:00 pjb3: shoover1: that does it, thanks!

0:03 shoover1: pjb3: 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.

0:05 It also worked with the foo.invoke code, as long as you call something in RT before Compiler.loadFile to get the runtime initialized.

0:09 pjb3: have a Compiler.loadFile, I was having IDE issues :)

0:10 but RT.loadResourceScript works too

0:49 shoover1: For 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

5:51 mac__: 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?

6:15 hoeck: mac__: i haven't found one

6:16 mac__: 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 ;)

6:18 hoeck: in your case, you would just need to remove the let in the doto macro to make it an sdoto

6:18 are you doing opengl stuff?

6:19 (thats the only api i know where one has to make several static method calls in row)

6:33 mac__: yep

6:34 using lwjgl

8:17 Chouser: shoover: oh, good. That'll be helpful.

9:02 cemerick: rhickey: 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.

9:05 rhickey: cemerick: what's the default?

9:06 cemerick: rhickey: it's system-dependent -- the value of the file.encoding system property. "MacRoman" on my system right now.

9:07 rhickey: ick

9:07 cemerick: Given 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).

9:08 rhickey: could you please post this on the group - I'm fine with it, but would like to get broader input first - thanks

9:08 cemerick: np

9:45 rhickey: just out of curiosity, are you planning on accepting the PersistentStructMap patch I posted with the genbean impl?

9:53 rhickey: cemerick: done, rev 976

9:53 cemerick: rhickey: ah, thanks very much -- I figured you were still thinking about it :-)

9:54 rhickey: cemerick: no, I just didn't realize they were separate patches (not ready for genbean yet)

10:31 jykrd: would you say that clojure is easier to learn than, say, lisp or scheme, or harder?

10:49 arbscht: jykrd: for whom? between those three languages, I'd say it's subjective

11:06 jykrd: arbscht: for the beginner

11:10 arbscht: jykrd: I can't imagine that clojure is conceptually any harder than another lisp or scheme

11:10 jykrd: so probably just about the same then, eh?

11:10 cemerick: I'd say it's clearly easier to jump into than CL; it's probably on par with various schemes, though.

11:11 arbscht: considering 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:11 Chouser: If you're used to other languages, the immutability of Clojure can be tricky at first.

11:12 But it's so much smaller than Common Lisp, that's a huge help.

11:22 arbscht: even CL's mutability can be equally tricky for such a person

11:26 jykrd: yea, it's such a subjective question.. Especially when you try to compare the learning curve to something like python, ruby, or even java

11:32 I'm already biased because I've already learned the way to work with those imperative language styles

12:02 I 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:02 You'd just have to get them early

12:24 Chouser: I 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:25 I'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:26 like logo, except functional instead of imperative.

12:27 jykrd: It was actually seeing scratch (http://scratch.mit.edu/) today that prompted my comment

12:29 Chouser: hm!

12:31 jykrd: this one is neat http://scratch.mit.edu/projects/Cyclone103/221614

12:34 cemerick: http://www.alice.org is pretty slick -- very smalltalk-ish

12:36 Chouser: scratch 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:38 jykrd: well, I think recursion is inherently more advanced than a sequential form

12:39 but recursion, as a concept, by itself, I don't think is beyond the intellect of an elementary school kid

12:41 Chouser: yeah, I guess recursion is harder than a looping construct in a lot of cases.

12:41 jykrd: I'm not sure if immutability is inherently more unintuitive than mutability. I'm biased, coming from the mutable world.

12:41 Chouser: but 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:42 slava: i find higher order functions easier than both explicit recursion and looping syntax

12:42 jykrd: But I still feel like my hands are a bit tied.. like I have a lot less options. that may change though

12:42 Chouser: also, 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:43 jykrd: I still don't know what the canonical definition of "higher-order" is

12:43 slava: a function taking another function

12:43 or returning another function

12:43 jykrd: I don't think that's necessarily harder for a kid

12:44 Chouser: One 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:44 That 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:45 jykrd: in the sense that python is a "real" language?

12:46 Chouser: yes, to the extent that it's got all the platform support and library selection you need to tackle any real-world problem.

12:46 slava: except for anything that requires performance

12:46 Chouser: networking, 3d graphics, web apps, GUI apps, etc.

12:47 the resource-sharing community around scratch looks really good.

12:49 jykrd: "a function taking another function..." question: that's not the same thing as a function taking an object, is it?

12:49 seems like a silly question

12:50 dudleyf: It can be, if functions are also objects

12:50 jykrd: I understand the difference, lexically, between a function and an object... but, numberObject.increment is a function, right?

12:50 Chouser: jykrd: 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:51 slava: jykrd: its best not to map everything back to java syntax

12:52 jykrd: so, a language where "everything is an object".. what about "everything is a function"

12:52 slava: lambda calculus

12:52 Chouser: jykrd: ok, so you have this person object -- what does it do if you call it?

12:53 jykrd: depends how you call it? person returns person?

12:54 Chouser: I 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:55 on 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:56 jykrd: the comment about kids understanding higher-order functions is what prompted the line of thought

12:57 if one didn't have differentiate, at the syntactical level, between primitives, objects, functions, would that make things easier to understand?

12:58 Chouser: that's one reason I think a lisp might be easy to teach -- no syntactic difference between anything. :-)

12:58 jykrd: agreed.

12:59 Chouser: my 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:00 I'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:03 jykrd: well, there's always squeak (http://www.squeak.org/)

13:03 oh wait.. looks like scratch is an offshoot of squeak :)

13:04 I guess scratch has smalltalk underneath it

13:06 bbiab

14:39 drewr: What's everybody doing with LOAD-FILE regarding relative paths?

14:41 cemerick: drewr: I understand that a relative file loading mechanism either exists in clojure-contrib/lib, or is planned.

14:41 so far, we don't have any multi-file namespaces, so lib/use is sufficient

14:41 drewr: I would like to use lib.clj, but how can I bootstrap it without a known path somewhere?

14:42 This is the first time I've really tried to break out some clojure into a modular file structure.

14:43 Chouser: I 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:43 cemerick: drewr: Put a form like (. clojure.lang.RT (loadResourceScript "lib.clj") in a user.clj file in a top-level of your classpath.

14:44 or that :-) (although the user.clj route ensures that lib is loaded right at clojure's init, and done only once)

14:45 lib will become part of core clojure eventually, or so I've heard

14:48 Chouser: yeah, putting it in user.clj is probably a good idea. I don't user user.clj at all currently.

14:49 kotarak: I use it for lib and bye (= (. java.lang.System exit 0))

14:49 cemerick: The 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:40 drewr: So, ADD-CLASSPATH followed by a loadResourceScript doesn't seem to work.

15:41 Does ADD-CLASSPATH manipulate something different than the "official" classpath?

15:42 rhickey__: drewr: it can only manipulate the loader use by Clojure, not the loader that loaded Clojure, which is what resolves loadResourceScript

15:57 cemerick: whoa, the ALL-CAPS thing is making my eyes bug out ;-)

15:59 drewr: cemerick: Sorry, but I prefer disambiguation.

16:07 Chouser: except 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:07 I've been mulling this for a while, and haven't come up with a single viable convention.

16:08 <in-ns>, (in-ns), IN-NS, *in-ns*, CLOJURE: in-ns, (CLOJURE in-ns), etc. each have their own overwhelming drawback.

16:09 cemerick: is disambiguation in irc really a cause for concern?

16:10 drewr: I prefer to waste as little time as possible.

16:12 Chouser: drewr: if you know the classpath you want to add for loadResourceScript, can't you just use load-file directly?

16:12 oh, you probably want to put it in a .jar. nm.

16:13 drewr: Chouser: I probably could for my current situation, but I'd rather have a generic way of doing it.

22:56 arohner: is anyone else having problems checking out clojure-contrib from sourceforge?

23:05 Chouser: yep, connection reset by peer

Logging service provided by n01se.net