2009-11-03:
[8:01] <simono> re interactive docs: i took helmangs jsdoc facilities and hacked up a pythonic help() function[8:02] <simono> i intentionally throw away a lot of info jsdoc provides to make the doc a fast ref[8:04] <simono> jsdoc FTW :)[9:23] <ondras> hmm[9:23] <ondras> I have a JSGI question; who is a good person for that? :)[9:24] <evilstreak> ask it and find out ^^[9:24] <ashb> try me or deanlandolt[9:32] <ondras> ashb: so, I am interested about response body[9:32] <ondras> what is that "forEach" stuff?[9:32] <ondras> The Body commonly is an array of Strings or ByteStrings.[9:32] <ondras> array does not respond to "forEach"...[9:32] <ashb> var body = [,..,...];[9:32] <ondras> ah[9:32] <ondras> my bad[9:32] <ashb> body.forEach(functionThatPrints);[9:32] <ondras> of course[9:33] <ondras> and[9:33] <ondras> why it has to be something iterable? why not a single object?[9:33] <ashb> v8's array might not havea forEach, in which case, well v8 is fucking stupid for sticking ot the ES3 spec only :)[9:33] <ashb> you could special case a single string or bytestring object if you want[9:33] <ondras> v8 has 1.6 array methods :)[9:33] <ondras> ashb: actually, I am just curious, I am not implementing jsgi[9:34] <ondras> what is the advantage of having body in multiple parts?[9:34] <ashb> i'm never quire suer what v8 does or doesn't have[9:34] <ashb> as for why, um dunno[9:34] <ashb> that came pretty much for rack i think - i didn't question it[9:34] <ashb> its not too onerous[9:35] * ondras looking up onerous in dictionary[9:35] <ashb> but then i wasn't invovled with JSGI much before 0.3 came along[9:35] <ondras> ok[9:36] <ondras> I think that v8 is very close to js 1.6[9:36] <ondras> bar e4x[9:36] <ashb> e4x is a seperate ECMA spec[9:36] <kriskowal> ondras: the forEach thing makes comet and chunked encoding possible[9:36] <ashb> & time to get off the train[9:36] <kriskowal> or early header flush[9:36] <ondras> https://developer.mozilla.org/en/New_in_JavaScript_1.6[9:36] <ondras> JavaScript 1.6 introduces several new features: E4X, several new Array methods, and Array and String generics.[9:37] <ashb> ondras: yeah fair enough. e4x is a totally seperate thing tho (which has a bug ridden spec that no one is interested in fixingi)[9:37] <ashb> which is a shame, cos native XML handling is actually quite cool[9:37] <ashb> & for real now[9:38] <ondras> kriskowal: hmm, if the body is returned in one function call, one cannot gradually add more body parts...[9:38] <kriskowal> unless the body is an object that implements forEach and stalls between calls to the provided write method[9:38] <kriskowal> an object that isn't necessarily an array[9:38] <ondras> okay[9:38] <ondras> makes kind of sense[9:39] <ondras> albeit some callback-related solution would sound more natural to me[9:39] <kriskowal> yeah, kriszyp and tlrobinson have something worked out with promises that is a super-set of the spec[9:39] <kriskowal> promises are just fancy callbacks[9:40] * ondras refactoring v8cgi[9:40] <ondras> hmm[9:41] <kriskowal> alright, done with my slides for jsconfeu. homeward bound.[9:42] * ondras is sad he won't be able to visit jsconfeu this year[9:42] <ondras> perhaps in 2k10 :)[12:02] <MisterN> what do the other implementers think about shared-nothing worker threading?[12:06] <ondras> no threads in v8/v8cgi so far[12:06] <ondras> fortunately for me, as I have zero experience with threads :)[12:13] <ondras> hmmm[12:13] <ondras> is there some standard regarding the working directory for a cgi script?[12:14] <ondras> dirname(script) seems like a logical choice, chmh[12:15] <ashb> yeah either dirname(script) or /[12:15] <ondras> hmmh[12:15] <ondras> that kind of sucks[12:15] <ondras> the same code cannot be used for cgi and shell scripting[12:16] <ashb> not sure if there is a spec[12:16] <ashb> but / could also make sense[12:16] * ondras wonders how php solves it[12:16] <ondras> probably some cgi-detecting code[12:17] <ondras> to distinguish cgi and cli[12:17] <ashb> why does cwd matter?[12:19] <ondras> well[12:19] <ondras> in cli scenario, imagine I want to implement "ls"[12:19] <ondras> /path/to/my/script/ls.js[12:19] <ondras> => no chdir to be performed[12:30] <ashb> i dont follow[12:33] <ondras> ashb: so, does flusspfer perform a chdir to script's directory?[12:33] <ondras> *flusspferd, ofc :)[12:35] <ashb> no, it keeps the cwd from before[12:35] <ondras> yes, exactly[12:35] <ondras> that is certainly a good behavior[12:35] <ondras> if one wants to implement "ls" in js[12:35] <ondras> however[12:35] <ondras> there are certain scenarios where a chdir() is desirable[12:35] <ondras> apache module for instance[12:35] <ondras> and the same applies to cgi[12:35] <ashb> sure, thats the place of the apache module tho[12:36] <ondras> so when handling /some/path/script.cgi, it makes sense to set cwd to /some/path/[12:36] <ondras> and that is the question: when is chdir() desirable?[15:06] <Wes--> ondras: chdir is desirable only when you want operations from fs-base to be processed relative to a directory other than the "real" unix working dir[15:06] <ondras> Wes--: what about the apache module scenario?[15:07] <Wes--> ondras: That's entirely dependent on what the module does. :)[15:07] <Wes--> (and hence the job of the module author)[15:08] <Wes--> Even so -- say, if you were imitating CGI -- you would change dir to the directory containing the program module, not as part of require()[15:11] <ondras> Wes--: I don't follow here[15:11] <ondras> say my module is like html; it uses js to create webpages[15:11] <ondras> is it feasible to chdir?[15:12] <Wes--> ondras: Why would you want to?[15:13] <Wes--> chdir is not magic, it is effectively just a string which is pre-pended to relative file accesses by the kernel[15:14] <ondras> Wes--: because in the user.js script, it sounds logical to do write(glob(".").join(", "))[15:15] <ashb> diename(module.uri)[15:15] <Wes--> ondras: what would that do?[15:15] <ashb> *dirname[15:15] <ondras> Wes--: write file listing from that directory?[15:15] <ondras> I have implemented that in php million times[15:15] <ondras> and it always worked[15:16] <Wes--> ondras: Then your module must have a concept of directories[15:16] <Wes--> ondras: Which the PHP module does[15:16] <ashb> ondras: if you want to say that v8cgi runs with chdir set to the script, go for it :)[15:16] <Wes--> ondras: let's say you wrote a module which resizes images. Should IT have a concept of directories?[15:16] <ondras> ashb: no, v8cgi does not do that - only as apache module[15:16] <Wes--> ondras: CGI, by definition, changes dir to the directory of the script[15:16] <ondras> Wes--: apache module or js module? :)[15:17] <Wes--> ondras: apache is not a language[15:17] <Wes--> what apache modules are written in is not relevant[15:17] <Wes--> see mod_perl for a concrete example[15:17] <ashb> (just never look at the code for it)[15:17] * Wes-- lols[15:17] <ondras> wait[15:17] <Wes--> Yeah, read the Eagle book though[15:18] <ondras> I never said apache is a language[15:18] <ondras> and cgi is not relevant now[15:18] <ondras> we were talking about module which resizes images[15:18] <ondras> and I was not sure if you are talking about some js code[15:18] <Wes--> ondras: You implied that apache modules and js modules had some kind of equivalence. They do not.[15:18] <ondras> or mod_resize.so[15:18] <ondras> Wes--: not at all![15:18] <Wes--> ondras: Sure, an apache module written in javascript[15:19] <Wes--> THAT module has no need to chdir[15:19] <Wes--> Which is the point I am trying to make[15:19] <Wes--> If your apache module needs to chdir, it is totally dependent on what the module does[15:20] <Wes--> mod_php chdirs to the script dir[15:20] <Wes--> that makes sense for writing content in PHP[15:20] <Wes--> mod_rewrite does not[15:20] <Wes--> And that makes sense, too[15:21] <ondras> yes.[15:21] <ondras> so, my module executes javascript[15:21] <ondras> it takes the request_red->filename[15:21] <ondras> and executes it as a module[15:21] <ondras> *request_rec->filename[15:22] <ondras> in my opinion, that is similar to php[15:23] <ashb> so what juice does[15:23] <ashb> is you call setup with the 'docRoot'[15:23] <ondras> Wes--: are we in some kind of agreement here now?[15:23] <ashb> and then it constructs filenames (for templates/statics) from that[15:24] <Wes--> ondras: That's certainly a reasonable behaviour. But the chdir should be done by your apache module, not require()[15:24] <ondras> Wes--: I never said that require should chdir[15:25] <ashb> don't cross the streams! :)[15:25] <Wes--> ondras: Ah, I missed the initial part of your discussion[15:25] <ondras> ok[15:26] <ondras> so, when we are in agreement that my apache module should chdir[15:26] <Wes--> ondras: :"is there some standard regarding the working directory for a cgi script?"[15:26] <Wes--> Yes, getcwd()[15:26] <ondras> we move on to cgi[15:26] <ondras> as you said, cgi should perform a chdir[15:26] <ondras> to dirname(script) ?[15:26] <Wes--> Yes, that's part of the CGI standard[15:26] <Wes--> Also the behaviour for mod_include IIRC[15:27] <ashb> The current working directory for the script SHOULD be set to the directory containing the script.[15:27] <ashb> http://www.ietf.org/rfc/rfc3875[15:28] <ondras> Wes--: fine... and here comes the finale[15:28] <ondras> v8cgi's cgi and cli binary are the same[15:28] <ondras> but cgi has to perform a chdir, but cli not[15:28] <ondras> :)[15:28] <ondras> and that is the place which I don't like[15:28] <Wes--> Why does the CGI have to perform a chdir??[15:28] <Wes--> That is apache's job[15:29] <ondras> aha[15:29] <ondras> I thought that the cgi script should do that[15:29] <ondras> that would simplify things[15:30] <Wes--> ashb: Only SHOULD on UNIX? That's stupid. I still implement as though "MUST" and challenge the sanity of any httpd that doesn't.[15:30] <ashb> its SHOULD on every platform apart from amigaos[15:32] <ondras> that is good news indeed[15:32] <ondras> co cgi and cli versions can remain the same, cool[15:33] <ashb> yeah, running v8cgi as cgi through apache should chdir for you[15:34] <Wes--> ondras: Curious as to why there is a difference -- gpsee as a CGI is just another script, processing CGI input is user's job[15:34] <Wes--> ondras (mind you, I have a module which can help)[15:35] <ondras> not sure if I follow[15:39] <ashb> modjs \o/[16:05] <ondras> Wes--: I am afraid I did not get the point re. gpsee as cgi[16:06] <Wes--> ondras: When I write CGI programs with gpsee, I don't have a special version of the script runner... I just #! /usr/bin/gsr, then print("Content-Type: text/html")[16:06] <Wes--> *although*[16:06] <Wes--> sometimes I #! ./gsr[16:06] <Wes--> that is usually for backwards-compatibility[16:06] <Wes--> i.e. I have changed code in an incompatible way, but do not want to modify my scripts as they work fine[16:07] <Wes--> so I drop an old version of the script runner in the CGI directory and continue to develop the main line as I see fit[16:07] <ondras> ah, yes[16:07] <ondras> well, v8cgi will remain the same for cgi and cli[16:08] <Wes--> that makes good sense[16:08] <ondras> Wes--: however, what is somebody configures apache to use gsr as "Action" for certain files?[16:09] <ondras> that is a situation similar to cgi[16:09] <Wes--> ondras: That is not CGI, so presumably whoever does that has thought about why they want to. :)[16:09] <ondras> hmm, it is very close to cgi, but your scripts don't have to be executable then[16:09] <ondras> people use this from what I have heard[16:10] <ondras> for instance, on windows, it is difficult to have a "#!/usr/bin/gsr" file as a cgi script...[16:12] <ashb> http://github.com/ashb/juice/blob/master/lib/juice/installer.js#L160-215[16:12] <ashb> ondras: that emulates env from BSD on windows[16:12] <ashb> create a foo.bat, and it looks for 'foo' in the same dir etc[16:19] <ondras> hmm[16:19] <ondras> does fp handle the following?[16:19] <ondras> AddHandler my-handler .ssjs[16:19] <ondras> Action my-handler /path/to/flusspferd[16:21] <Wes--> ondras: What does the Action directive do?[16:21] <ondras> specify a binary to be executed for a given handler[16:21] <ondras> http://httpd.apache.org/docs/2.2/mod/mod_actions.html#action[16:24] <Wes--> ondras: the docs explicitly say that that is CGI[16:24] <ondras> yes, but it executes the binary and not the requested (script) file[16:25] <Wes--> ondras: Does it pass the script filename as an argument?[16:25] <ondras> Wes--: so the point is that this way, gsr is executed without any arguments[16:25] <ondras> no[16:25] <ondras> :)[16:25] <Wes--> well, that's stupid[16:25] <ondras> script filename is set as some env var[16:25] <Wes--> So write a program in javascript that reads the env[16:25] <Wes--> make THAT program the one which is executed[16:26] <ondras> hehe, difficult on windows :)[16:26] <Wes--> or a batch file[16:26] * ondras wondres why php does not use this approach[16:27] <ondras> *wonders[16:27] <Wes--> ondras: because php is built as an apache module[16:27] <ondras> nono[16:27] <ondras> php as a cgi[16:27] <Wes--> php as a cgi is stupid, imho[16:27] <ondras> .)[16:28] <ondras> anything as a cgi is stupid then, because it can be rewritten using a module?[16:28] <ashb> s/as a cgi //[16:28] <ondras> :}[16:28] <ashb> :D[16:28] <ondras> anyway, the fp's bat file can be used as a base for env loader for apache's Action directive[16:29] <Wes--> ondras: Anything as a CGI is stupid which has *already been written as a module*[16:29] <ondras> ah, yes, I agree on this one[19:54] <Sembiance> :)[20:22] <ashb> okay so really. blob.byteAt(1) returning a ByteString just feels really wrong[20:22] <ashb> kriskowal: what was your view on this again?[20:26] <kriskowal> my requirements are "free trade" and "duck-typical programming".[20:26] <kriskowal> i am not ardent about how this is accomplished[20:28] <ashb> Get the byte at the specified index as a ByteString. To get the actual byte value, use [[binary.Binary#get `get(index)`]][20:28] <kriskowal> there just need to be well defined interfaces shared by Array and ByteArray (or whatever a buffer is called; i'm not picky about whether it's fixed width), String and ByteString (or whatever it's called; there should be an immutable fixed width byte type analogous to string that should be returned by read() calls and the like), ByteString and ByteArray[20:28] <ashb> writing docs for it and i've just writtne that about byteAt[20:29] <ashb> i'm basuclaly just not sure thet byteAt reutrning not a Number is the right behaviour[20:29] <ashb> charAt, perhaps could do. but byteAt i dont think should[20:29] <kriskowal> as opposed to a unary byte string?[20:30] <kriskowal> a char is a unary string. we can't implicitly promote byte-string bytes to chars.[20:30] <ashb> charAt returning a unary ByteString that is[20:30] <ashb> bytt byteAt isn't on String, so i dont see why it can't return a byte directlry (i.e. a Number)[20:30] <ashb> *but[20:31] <kriskowal> char == unicode char. byte == 8 bit number, sometimes represented as a unary byte string[20:31] <ashb> its that somteims that grates me. since it makes using it more complex, and i cna't think of a case when it helps right now[20:31] <kriskowal> i can see an argument for byte always implying a numeric representation[20:32] <ashb> that would be my favoured approach[20:32] <kriskowal> this is tricky.[20:33] <kriskowal> one of my fundamental design principles is orthogonality[20:33] <ashb> oone the subject, is it still worth having 2 separate blob classes?[20:33] <ashb> er, on[20:34] <kriskowal> i think so. one would be for buffers and the other for immutable strings of bytes[20:34] <kriskowal> there are different performance and usability implications[20:34] <ashb> guess so. just so happens we dont actually store it differently in flusspferdright now[20:34] <ashb> http://juicejs.org/combined-docs/commonjs%20core/binary/binary.html[20:37] <ashb> time to go cook dinner[21:58] <ashb> also #split only accepting single byte delims seems seriously lacking[22:18] <ashb> huh. so byteArray.toByteArray() returns a copy[22:18] <ashb> byteString.toByteString returns byteString[22:18] <ashb> i guess since byteStrings are imutable this is okay?[22:25] <ashb> okay, more oddness. ByteString.join(array, delim)[22:26] <ashb> seems like an odd sig[22:26] <MisterN> didn't we put join on the constructor of Binary?[22:26] <MisterN> not sure but i thought that was how we did it[22:26] <ashb> i'm going by our header, not the wiki[22:26] <ashb> and we only have it on ByteString[22:57] <kriskowal> ashb: as you're in the process of implementing the thing, i think your insights would be invaluable if you have time to fork the binary/b proposal[22:58] <ashb> kriskowal: implemented months go[22:58] <kriskowal> or start from scratch, either way[22:58] <ashb> i'm just documenting it :)[22:58] <kriskowal> i see.[22:58] <ashb> if you remind me next week I'll look ofer binary/B and binary/C and comment on what i think works and doesn't[22:59] <ashb> (my contract finishes this week, so i have much more time next week)[22:59] <kriskowal> if you could go so far as to take those insights and envision a full proposal, i think it would be far more useful[22:59] <ashb> sure[23:19] <ashb> hmm we have pop/shift etc throwing on an empty ByteArray[23:20] <ashb> that is probably wrong as its not what array does[23:22] <kriskowal> i?don't think we need those ops on bytearray.[23:22] <kriskowal> those were definitely requested by someone else.[23:23] <kriskowal> since this thing is a portal into a lower layer, it might be okay for it to be like an array of numbers, where the length can only be grown or shrunk with .length assignment and bytes default to 0 or something[23:23] <ashb> yeah, there are a few really odd operations that dont make sense in ByteArray/binary buffers[23:23] <kriskowal> and it might be okay if operations that touch outside the buffer's range throw an error[23:23] <ashb> sort in particualr really doesn't make sense to me[23:24] <ashb> there are a certainly class of ops that if oyu want to do, just convert it to a normal Array[23:24] <ashb> i think[23:24] <kriskowal> i agree[23:25] <kriskowal> the use case i envision for byte arrays would be more like the readInto and writeFrom case, where you keep offset positions in some other variable and use them like a queue[23:25] <ashb> push/pop/shift/unshift kinda make sense for building up data structures[23:25] <kriskowal> they'd be the buffer implementation[23:25] <kriskowal> i'm not terribly convinced about those either[23:25] <MisterN> ashb: well sort didn't make a lot of sense to me either. but: it was fucking easy to implement[23:25] <ashb> yeah i see that :)[23:25] <MisterN> so not worth the trouble of bitching about that[23:25] <ashb> all of 5 lines[23:26] <ashb> MisterN: i'm going to be doing a whole lot of bitching about it :)[23:26] <ashb> about everything[23:26] <MisterN> ok :D[23:26] <ashb> kriskowal: have oyu read Dantman's binary/C btw?[23:26] <kriskowal> i scanned it.[23:26] <ashb> i've not in a very long time[23:26] <ashb> but from what i recall there seemed to be some useful ideas in there[23:27] <kriskowal> there were definitely highlights and i think i integrated some of those ideas[23:28] <ashb> ah, so given .prepend and .append, yeah push/pop/shift/unshift don't make much sense either[23:28] <kriskowal> like, .valueAt came from C[23:28] <kriskowal> i kinduh see the thing as lower level, where .prepend and .append would be done with .length assignment and .copy calls[23:29] <ashb> it is doable that way, but prepend and append is a nice api i think[23:29] <ashb> espeically as its entirely possible it could be done more efficently[23:29] <kriskowal> aren't those called extendRight/Left in B?[23:29] <ashb> (i.e. entirely possible that ByteArray would allocate memory in chunks, and there is spare space etc)[23:30] <ashb> might be now. i'm just going on what flusspferd has[23:30] <ashb> since thats what i'm writing docs for :D[23:31] <ashb> oh yeah.[23:31] <ashb> kriskowal: got 5 mins spare?[23:31] <ashb> to try another Juice.mpkg[23:31] <kriskowal> ah, that i can do[23:31] <ashb> i've had one report of it working already on 10.6, just would like another[23:31] <ashb> http://juicejs.org/downloads/Juice-0.1_3.dmg[23:32] <MisterN> 0.1.3?[23:33] <ashb> _3 as in mac build 3[23:33] <ashb> its still Juice 0.1[23:34] <kriskowal> in the words of my klingon brethren, q'plah[23:34] <ashb> score.[23:35] <MisterN> *not understands joke*[23:36] <kriskowal> q'plah is a fictional word used in star trek by klingons for almost every occasion, but generally it means "success"[23:36] <ashb> LMGTFY[23:36] <ashb> much like the french use "d'accord" a lot[23:36] <MisterN> ääh
Logs by date :