hi all,

On 2005-01-01 (22:09) Miguel wrote:

>Bob wrote:
>>>General question: What is your experience with running JavaScript
>>>functions based upon timers?
>>>
>>>I am thinking of polling for events rather than callbacks.
>>>
>>
>>If I read your question correctly, you are suggesting letting the
>>JavaScript loop for events from the applet and perhaps have public
>>access to variables that would indicate, for example, that a script
>>has run, that the message buffer has been loaded, etc.?
>
>Correct ... that is what I am wondering about.
>

javascript timeouts are daily fare in Chime pages, and in my experience they 
work okay even in fairly complicated js code.  so I think a timed polling of 
Jmol from javascript would be okay for simple Web applications.


>>Callbacks seem to me to be ultimately more efficient than polling.
>
>One would think so.
>
>But I saw a posting that said that under Mozilla calling from Java
>to JavaScript was up to 40,000 times slower than from calling from
>JavaScript to Java.
>
the theory of callbacks is great.  in practice, they suck. :-)  in fact, 
callbacks are one reason why so many Chime pages need js timeouts!  argh.


>Rather than have many functions do the polling, I am thinking of 1
>function that does the polling. One that I write and put into
>Jmol.js
>
I am strongly in favor of replacing the callback mechanism with something 
better.  I don't know what exactly, so I am not casting stones on the idea of a 
js polling function, but I have some questions:

what happens if a function needs data from Jmol in the middle of the polling 
interval - would it have to wait for the poll to return?  this might require 
salting your js code with lots of timeouts that wait on the polling timeout.  
this is my biggest concern, especially since js "time" is not independent of 
platform, computer, browser.

how would the polling function get the data from Jmol?  the only mechanism I 
know is the callback mechanism :-(

javascript is not truly platform-independent like Java, so there are bound to 
be more problems like what we have with liveconnect in general.

what data would be returned to the polling function?  a script is done, a 
structure is loaded, a selection is made, etc.?


and here's a complete duffer's question: isn't there some way for js to just 
"peek" inside a Java applet class at any time after the applet is loaded?  that 
could contain all of the relevant status info of the applet - selected set, 
script status, structure loaded, etc.  then the js could simply go get the info 
whenever it wanted, instead of having to wait for Java to send it along.  (I'm 
sure you've explained this before, Miguel, but it's early on a sunday morning 
here ;-)


happy new year,

tim
-- 
Timothy Driscoll
molvisions - see, grasp, learn.
<http://www.molvisions.com/>
usa:north carolina:wake forest


"I sometimes go to my own little world, but that's okay, they know me there." - 
Joel Hodgson


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to