#clojure logs

2008-09-24

00:48arohnercan you create a macro that takes a variable number of arguments?
00:48arohnerI'm trying to use the same syntax as defn, but it's not quite working out
00:49lisppaste8arohner pasted "macro" at http://paste.lisp.org/display/67353
01:07arohnernm, got it working
10:47Chouseranyone want to help me churn out another few hundred lines of tedious JavaScript?
10:47tomhickeyChouser: how tedious?
10:48ChouserI'm walking through clojure/lang/*.java and translating to JS.
10:50ChouserNot all of it will have to be done: nothing from Compiler.java, for example.
10:50tomhickeyChouser: i would need to take some time to review what you've done so far, but i'm interested in getting involved with the clojurescript work
10:50Chouserclj.js is the file I'm populating now. I think nearly everything else is done.
10:51blackdogis that up to date on contrib Chouser ?
10:51ChouserI already did the fun part, writing Clojure code that translates ClojureScript to JavaScript.
10:52Chouserblackdog: yep, close enough. I'm working on PersistentHashMap now, and none of that is checked in.
10:53blackdogi'll have a look too, it would be nice for me to be able to do all my stuff in clojure, basically servlets right now, but adding a clojure client would be cool
10:54ChouserI'm not sure how big this "runtime" piece will be in the end -- that is, how much JS you'll have to load into your page for ClojureScript to work.
10:55ChouserI also don't know how fast we may be able to make it.
10:55Chousereither of those could make using it a "deal breaker" in a lot of cases, I'm afraid. We'll just have to see how it goes.
10:57Chouserblackdog, tomhickey: thanks for even considering helping. :-)
10:58ChouserI'm also completely open to critique of my approach. Anything you can think of to make the JS smaller, faster, or easier to write would be great.
10:59ChouserFor now I'm mainly working on getting something working correctly, and trying to mimic the layout of the .java closely enough that patches there can be pretty easily ported over to the Js.
10:59blackdogi think an important thing if possible is how well the integration with standard js libs is, well like jquery for example
11:00blackdognot just doing a clojure port, but making sure those popular frameworks can be dealt with
11:00blackdogdojo, ext etc
11:00blackdogand also debugging, but i guess that is really tricky
11:00Chouserone of the benefits of JS over Java is that it's already dynamic. This allows more seamless integration between the two.
11:01ChouserFor example, if you make a cljs function named foo in a namespace my.ns, you can call it from JavaScript just by saying: my.ns.foo( a, b, c )
11:02Chouserinterop the other way looks just like in clojure: (.getElementsByTagName document "script")
11:02blackdogok, and calling into a js namespace is ?
11:04blackdogok so call into jquery would be (.css JQuery "div" "bakground-color" "#0") for example
11:05blackdogso the top level global is the object
11:05Chouserhm, good question. We may need a bit more tweaking there -- I think we'd want it to be (JQuery/css ...) and I don't think that works right now.
11:06blackdogi'm not sure if that's a static or not
11:06blackdogi think in practive JQuery("#id") actually adds to the object itself
11:07ChouserIt looks like your example works as-is. We should have to ability to make other forms work as needed.
11:07blackdogbut the good thing is it's all so dynamic it can be dealt with
11:08ChouserRight, and rhickey supports this effort, so if we need to get patches into Clojure, that's definitely an option.
11:09blackdogi have to say i think this is a very important effort, i was drawn to the haxe programmign language originally because it supports multiple "platform" options
11:09blackdogjs is one of those
11:09blackdogbut it's server side story is weak
11:09blackdogthis is coming from the other direction
11:09Chouseryep, I found exactly the same thing with haxe.
11:10ChouserIt would be interesting to add a Flash target to clojure as well.
11:11blackdogif you used haxe, i tried to implement a jquery lib on top of it, hxServlet
11:11blackdogoops wrong lib, hxScriptlet
11:12blackdogso i can see the benefits of targetting js
11:12blackdogesp with these massive speed increases
11:12baetis-flyhi folks. new to closure here, hope this isn't too silly: is there something similar to common lisps subst that i can do on a seq or should i just write my own. and if i find myself writing my own does that mean i'm doing something fundamentally flawed :)
11:13baetis-flysubst in common lisp replaces the nth value with something else.
11:13Chouserbaetis-fly: clojure vectors support that directly.
11:13Chouserbaetis-fly: do you specifically want something that works on any kind of seq?
11:14Chouserblackdog: yeah, the JS speed increases we're seeing make something like this less ... ridiculous. :-)
11:14baetis-flyChouser: well, i was kind of under the impression that i should try to make everything work ok seq, but i guess using a vector would solve all my problems.
11:14blackdog:) did you see squirrelfish are posting 2 * v8 now too
11:14blackdogit's already in their trunnk apparently
11:14blackdogamazing
11:15baetis-flyChouser: i'll just try to get my function to work on a vector as a starting point and maybe revisit it with seq later. Many thanks.
11:17Chouserblackdog: no, I hadn't seen that. Well, I don't care whether squirrelfish, V8, or tracemonkey wins, as long as they keep egging each other on.
11:18blackdogyep all to the common good
11:19Chouserbaetis-fly: PersistentVector's internal design is specifically made to make setting a particular index fast. You could write something that works on any given lazy seq, but there's no way it could be as efficient.
11:19blackdoghttp://webkit.org/blog/214/introducing-squirrelfish-extreme/
11:21ChouserI hope writing the persistent collections in JS is the right choice. I made a brief attempt at writing them in Clojure, but it didn't look like it was going to work very well.
11:22ChouserBut if that could be made to work, cranking out a new target (Flash, C#, Java source code, etc.) would be smaller task.
11:22blackdogwell it fits more clojure's model right now, which may help the port
11:23Chouserhm, scratch Java source from that list -- Java's already got the collections. ;-)
11:23blackdoglike haxe has a common set of haxe libs which are #if according to platform
11:23blackdogand makes a port easier
11:26blackdogprobably the base ds need to be native for performance though, maybe get better optimisation
11:27blackdogit was interesting that your closure test was a lot slower than the prototype test
11:27Chouseryes, I was surprised at how different.
11:27blackdogand it seems that webkit is using the same optimisation technique as v8 too, creating background classes
11:28ChouserNow that I'm further into the project, I'm much less worried about the lack of protection.
11:29ChouserPeople just aren't going to use this code from JS -- they'll use cljs, and that won't expose the dangerous parts in any natural way
11:30baetis-flyhttp://paste.lisp.org/display/67372
11:31baetis-flyis that remotely correct for a shuffle in clojure? I realize it doesn't return the vector (getting there :)
11:32Chouserbaetis-fly: (doc rand-int)
11:34ChouserI think there have been discussions of other shuffle algorithms on the google group, but for this algorithm your implementation's not bad I think.
11:35baetis-flyyeah, it was just an excercise. i don't actually need to shuffle anything.
11:35lisppaste8ozzilee pasted "Java Shuffle" at http://paste.lisp.org/display/67373
11:35ozzileeThere's another way :-)
11:37baetis-flyozzilee: bah, that's cheating ;)
11:37blackdogozzilee, that was my approach too :)
11:38Chouserbaetis-fly: you might use (doseq n (range (count v)) ...) instead of loop/recur
11:39Chouserhm, scratch that -- you'd have to use reduce or something to pass along your incrementally modified vector.
11:39baetis-flythe java version is faster :(
11:39baetis-flyas in ozzilee's version.
11:40Chouserbaetis-fly: http://groups.google.com/group/clojure/browse_thread/thread/180842eb58c58370
11:41baetis-flyChouser: oh great. thanks for that. Note to self: search the google group.
11:56Chouserrhickey: good morning!
12:02rhickeyhey - broadcasting live from the JVM languages summit!
12:02blackdogoh nice
12:02blackdogwhere?
12:04rhickeySun Santa Clara
12:04blackdognah, the live feed :)
12:04blackdogdon't see it
12:04blackdogon the summit page
12:04rhickeythis is it
12:05blackdogyou!
12:05blackdogok
12:05blackdoggotcha
12:11fyuryuit seems the summit will be recorded by InfoQ
13:09Chouserclj.js is already up past 1200 lines, and it's got a ways to go. :-/
13:12shooverChouser: Yeah, that may be a bummer, but keep your eye on the prize... once it's done you're writing Clojure!
13:13Chouserheh, yeah.
13:13ChouserHopefully this will all compress down to some sane size.
13:25baetis-flyok, another questions. I can call (seq (myfunc (range 10)) just fine, but if i make my func call (seq result) i get a class cast exception on Range. What's the difference?
13:26baetis-flywhere my func converts it's argument to a vector at the start, but wants to return it as a seq.
13:26baetis-flyi can paste if it's not clear.
13:27Chouserbaetis-fly: I think you'll have to paste. Sounds like it should work.
13:29baetis-flyhttp://paste.lisp.org/display/67381
13:31baetis-flysame problem if i (seq (loop
13:35fyuryubaetis-fly: i think you're hiding seq
13:35fyuryuyour parameter is named seq
13:35baetis-flyug, of course.
13:36baetis-flyfyuryu: that was it. many thanks.
13:36fyuryubaetis-fly: np
13:38Chouserfyuryu: good catch. I was stumped.
13:40achim_p_hey
13:40achim_p_Chouser: i just discovered your zip-filter.xml lib. very nice!
13:40achim_p_i was just about to get started on something similar when i found it. saved me a lot of time, thank you!
13:41achim_p_(half-finished rewrites of stuff i didn't know already existed - i'm rather good at these ;)
13:45Chouserachim_p_: glad you like it.
13:45Chouseras far as I know, it's not gotten a whole lot of abuse yet, so I'd be interested to know how it works out for you.
14:01achim_p_Chouser: doing very basic stuff (for now): extracting dependency information from maven metadata (e.g. getting every dependency with runtime scope from a file like http://repo1.maven.org/maven2/maven/maven/1.1/maven-1.1.pom). so there's not much to report, but i'll let you know if i run into troubles
14:02achim_p_i like the way the query expressions seem to resemble xpath
14:03Chouserthat was a specific goal.
14:03ChouserI like xpath. :-)
14:04Chouserthe other main goal, though, is to allow you to drop in custom filter expressions, which isn't natural in any xpath API I've seen.
14:34achim_p_Chouser: yes, i've seen it's possible, but haven't used it yet. it's a nice feature
14:35achim_p_btw, speaking of reimplementing already existing things: i'm (ab)using maven repos. metadata to implement some kind of "add-classpath" replacement for jars on the net, with local caching and automatic dependency resolution.
14:35achim_p_you could start your code with e.g. "(deps/depend :maven [["org.apache.velocity" "velocity" "1.6"]])" and the specified jars plus dependencies would be downloaded into a local directory (in case they weren't in there already) and added to the cp. has this or sth similar been done? would this be useful to anybody?
14:40achim_p_PLT does vaguely similar things with planet
14:41ChouserI think people have discussed similar schemes in general, but I've not heard of anyone working on an implementation.
14:47ozzileeachim_p_: That would be killer. Even without the automatic downloading, some kind of local shared repository of jars would be great.
14:49achim_p_ok, i'll tinker on then ...
16:00Chousergah. Anyone know of some good fast hashCode code for JS?
16:20baetis-fly\quit
16:43Chouserns :use ?
16:44drewrNo, the function use.
16:44drewrI would say USE, but rhickey doesn't like that. :-)
16:44Chouserwhat are you trying to do?
16:44drewrIf I say (use 'dbauth), I get all the symbols in the dbauth namespace grandfathered into my current one.
16:45Chouseryes
16:45drewrBut then if I say (require 'dbauth), it doesn't get the dbauth ns.
16:46drewrSorry, if I do (use 'dbauth :require), it doesn't mimic (require 'dbauth).
16:46Chouserah
16:47Chouserwhat would you want it to do?
16:47drewrSomething different than just (use 'dbauth) :-)
16:47ChouserUse "use" when you might otherwise do both "require" and "refer"
16:48drewrHm, OK.
16:50ChouserIf you really want to use "use" but don't want it to bring in any symbols, you could say (use '[dbauth :only []])
16:51drewrI was just trying to migrate to use usage.
16:51drewrIf I still need require, I can use it too.
16:53ChouserI think ns is recommeneded now above both use and require. (ns my-ns (:require dbauth))
16:54drewrOh.
17:49aperottehello everyone
17:53drewraperotte: Hi.
17:53aperottehi drewr
17:53aperotteI'm new to clojure
17:54aperottebut very excited about it
17:54aperottehow are you?
17:57drewrDoing fine, thanks.
17:57drewrWe're all excited about Clojure!
18:02aperotteSince I'm relatively new to thinking about building things using functional programming and concurrency, I wanted to ask for a more well informed opinion
18:04aperotteIn general, I was curious about whether clojure would be a good choice for machine learning sorts of problems
18:05aperottethings that you would usually write to include lots of elements, each of which change with time
18:11fyuryu`aperotte: that kind of problems often involve lots of number crunching
18:13fyuryu`aperotte: so it's probable that you'll have to write some java
18:14fyuryu`because Clojure uses boxed numbers, which are slow
18:14aperotteoh ok
18:14blackdogyou can type hint numbers
18:14blackdogand they can be very fast
18:14fyuryu`but if you're prototyping clojure is perfect
18:14fyuryu`you can optimize better
18:15fyuryu`s/better/later
18:15blackdoghttp://clojure.org/java_interop
18:15blackdoghave a look at java primitives
18:16blackdogclose to the bottom
18:16fyuryu`blackdog: yeah that too
18:16aperotteyup, I'm there
18:16aperotteoh ok ... that's fantastic
18:17fyuryu`blackdog: but it's mostly for arrays, right?
18:17blackdognot sure haven't used it
18:18fyuryu`blackdog: because most of the good stuff comes via seqs
18:19aperotteare the java primitives mutable?
18:19aperotteand would I need to use mutation to get decent performance?
18:20blackdogyou can use set! if you have a thread local variable
18:20blackdogi think
18:20blackdogChouser would have the definitive answer
18:20aperotteok
18:20fyuryu`aperotte: primitives are not mutable, but you're probably asking for something else
18:21fyuryu`java objects are (if they have mutable members)
18:21aperotteI mean if I make an array of java primitive floats, can I then assign to one of the members
18:22fyuryu`aperotte: yes
18:24aperottethanks fyuryu` and blackdog
18:24blackdogyw
20:20wmorganhttp://paste.lisp.org/display/67399 <-- I'm struggling with nested macro-quotes. Any ideas?
20:51shooverwmorgan: what if you replace the nested backquote with (list default x#)
20:53wmorganwon't work because then x# doesn't get gensym'd at all
20:56Chouseryou can't use the x# syntax in nested backticks -- they only resolve to the same symbol within the same level of backtick
20:57Chouseroh, you figured that out already. :-)
20:58wmorganyeah, and I added an annotation with one solution that I don't really like
21:02shoovergiven the limitation, maybe you just need to make your own (let [x (gensym)] ...)
21:07shooverdoes this do what you want? http://paste.lisp.org/display/67399#2
21:08wmorganshoover: that's exactly right, thanks
21:12shooverno problem