Re: Real-time changes pushed to output window?

81 views
Skip to first unread message

Bruce Sherwood

unread,
May 14, 2013, 4:24:46 PM5/14/13
to glowscri...@googlegroups.com
Brett Victor's work is indeed very interesting. Early in the development of GlowScript David Scherer experimented with the particular user-interface object you mention, namely being able to drag the mouse across a displayed number to change the number, a very compact version of a slider. This has so far not gotten integrated into GlowScript, but note that there is now in GlowScript a get_library function that might let you incorporate this slider-like object into GlowScript programs by referencing Victor's library.

Also note this sample program that uses an ordinary slider:


However, note that none of this is in principle different from what can be achieved in VPython, especially now that VPython is based on wxPython, which supports buttons, sliders, etc. 

The really important work of Brett Victor lies in something that GlowScript is very far from enabling, namely the seamless integration between code and display, where as you modify a line of code the display changes, and vice versa.

A general warning as far as student use is concerned: A program with a real user interface can easily be 90% user interface and 10% core program. If your students are writing programs to study math or science, not user interface design, it can be highly counterproductive to engage them in building a nice user interface on top of their core program.

Joseph Elsherbini

unread,
May 15, 2013, 3:15:26 PM5/15/13
to glowscri...@googlegroups.com
Thanks for your response Bruce.

I was not envisioning the students spending any time on UI for the output, but rather having an ACE editor that had some of the UI in place to allow sliding the number values, quickly selecting colors, etc. 

Tributary.io allows javascript to update the canvas, and it does have the "seamless integration between code and display, where as you modify a line of code the display changes, and vice versa." Is there anyway to get glowscript to work in the ACE editor provided by tributary.io? They allow libraries to be imported, but I'm so new to glowscript I don't know which libraries to include. I tried including just glow.1.0.min.js but that didn't work.





--
 
---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bruce Sherwood

unread,
May 16, 2013, 4:07:47 AM5/16/13
to glowscri...@googlegroups.com
It would be great for GlowScript to incorporate Brett Victor's insights. On the first page of the GlowScript Help, do study the section "Using the GlowScript libraries". For your first attempts, it makes sense to use the GlowScript libraries as described in this section, avoiding the additional (though useful) complexities of the preprocessing  carried out by GlowScript to enable vector operator overloading (the ability to add vectors in the intuitive form A+B, etc.), to permit writing infinite loops and yet update the display (by restructuring the program into event-driven form), and to build a "source map" to be able to give line-number information in the case of an error (at least when using Chrome).

The section "Running locally" may also be of interest.

Joseph Elsherbini

unread,
May 16, 2013, 12:41:44 PM5/16/13
to glowscri...@googlegroups.com
Thanks,, that's exactly what I needed. Take a look at this :http://tributary.io/inlet/5593124

Glowscript running side by side with the code, and updating automatically without having to click "run"


On Thu, May 16, 2013 at 4:07 AM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
It would be great for GlowScript to incorporate Brett Victor's insights. On the first page of the GlowScript Help, do study the section "Using the GlowScript libraries". For your first attempts, it makes sense to use the GlowScript libraries as described in this section, avoiding the additional (though useful) complexities of the preprocessing  carried out by GlowScript to enable vector operator overloading (the ability to add vectors in the intuitive form A+B, etc.), to permit writing infinite loops and yet update the display (by restructuring the program into event-driven form), and to build a "source map" to be able to give line-number information in the case of an error (at least when using Chrome).

The section "Running locally" may also be of interest.

Joe Heafner

unread,
May 16, 2013, 1:24:38 PM5/16/13
to glowscri...@googlegroups.com
On May 16, 2013, at 12:41 PM, Joseph Elsherbini <joseph.e...@gmail.com> wrote:

> Thanks,, that's exactly what I needed. Take a look at this :http://tributary.io/inlet/5593124
>
> Glowscript running side by side with the code, and updating automatically without having to click "run"

VERY COOL! It's periodically sluggish in Safari (latest version on 10.8.3) but cool nonetheless. I'll try different browsers later.


Joe Heafner
Sent from one of my Macs

Bruce Sherwood

unread,
May 17, 2013, 4:13:08 AM5/17/13
to glowscri...@googlegroups.com
This is awesome! Congratulations!

Unfortunately I can't see this for myself yet, as I'm in rural Italy with an internet connection too slow to run GlowScript at all. I look forward to seeing this.

Bruce Sherwood

unread,
May 21, 2013, 5:48:12 PM5/21/13
to glowscri...@googlegroups.com
Now that I'm back home, I was able to see the demo. Great!

There were some mistakes in the GlowScript objects, which should look something like this:

ground = box ({pos: vec(0,0,0), size: vec(40,1,40), color:vec(0,0.5,0)});
hive = box ({pos: vec(15,1,0), size: vec(1,2,1), color: vec(1,1,1)});
tree = cone ({pos:vec(-5,0,-10), size: vec(12,2,2), axis: vec(0,1,0), color: vec(0,1,0)});
bee = sphere ({pos:initialpos, size: vec(1,1,1), color:vec(1,0,1)});

There are no attributes length, height, width, or radius for these GlowScript objects (unlike in VPython), and the bee didn't display because the program var is initialpos, not initialPos.

I added the following to animate the bee:

var t = 0
var dt = 0.01

function anim() {
  t += dt
  if (t<5) {rate(100,anim)}
  bee.pos.x = bee.pos.x + 0.01
}

anim()

Changing a parameter in the source code probably shouldn't change the current user-chosen rotate/zoom.

What do you see as plausible next steps? It does seem like it would be a major step forward to incorporate these capabilities into the GlowScript environment.


Joseph Elsherbini

unread,
May 21, 2013, 5:57:11 PM5/21/13
to glowscri...@googlegroups.com
Oh, glad you could see it! Originally I had just put the rotating box from the glowscript help page, butthen I let my friend try it out, which I guess saved over the same link.

I think this sort of functionality would be great for both teaching my fellow students about programming, and about physics. They can spend less time trying to figure out what value everything should be, and try ideas out on the spot.

I do know that Tributary can be forked on github (https://github.com/enjalot/tributary), so this technology could be integrated into the ACE editor on glowscript.org. Or a separate site could be set up for this functionality. It needs optimizing with canvas and webgl, it seems like changing too many values too quickly can cause the canvas to spaz out and eventually webgl crashes, forcing a reload of the page. Those changes would be over my head though. 

What do you think?


Bruce Sherwood

unread,
May 21, 2013, 6:14:59 PM5/21/13
to glowscri...@googlegroups.com
I'm sorry to hear that you feel it's over your head! I'm impressed that you could put this all together so quickly at tributary.io.

I would really like to carry out this enhancement to GlowScript, but unfortunately it is likely to be many months before I can work on this. I've got heavy responsibilities to work with Ruth Chabay on the 4th edition of out intro physics textbook, Matter & Interactions (see matterandinteractions.org), and I can't take on a major overhaul of GlowScript until the textbook revision is carried out. The revision deadline is the end of 2013.

Joseph Elsherbini

unread,
May 21, 2013, 6:34:39 PM5/21/13
to glowscri...@googlegroups.com
Oh, I didn't realize I was talking to one of the authors of my textbook from last year! 

Well, I am not an expert at javascript, but am learning fast. I'm a student at Georgia Tech, though, so there is no shortage of talent around me. It is likely that in the fall I will be working for Dr. Greco updating some examples he has from regular VPython into GlowScript. I think he would be very interested in this sort of functionality as well, and wouldn't mind me devoting some time to it. 

In the meantime, enjalot ( http://enjalot.github.io/) who created Tributary is working to make some sort of plugin system that might make it easier to do the sort of optimizations I think need done. I will keep my eyes and ears open, and be sure to let you know if any of those changes arrive. I will also keep poking around a learning GlowScript, and maybe even take a look under the hood on the bitbucket page.

Let me know if you think of anything else I could do before the fall. 


On Tue, May 21, 2013 at 6:14 PM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
I'm sorry to hear that you feel it's over your head! I'm impressed that you could put this all together so quickly at tributary.io.

I would really like to carry out this enhancement to GlowScript, but unfortunately it is likely to be many months before I can work on this. I've got heavy responsibilities to work with Ruth Chabay on the 4th edition of out intro physics textbook, Matter & Interactions (see matterandinteractions.org), and I can't take on a major overhaul of GlowScript until the textbook revision is carried out. The revision deadline is the end of 2013.

--

Bruce Sherwood

unread,
May 21, 2013, 6:51:05 PM5/21/13
to glowscri...@googlegroups.com
I certainly welcome help in the further development of GlowScript!

Note that on the first page of the GlowScript Help there is information about semiautomatic conversion of VPython -> GlowScript.

Bruce Sherwood

unread,
May 22, 2013, 4:32:44 PM5/22/13
to glowscri...@googlegroups.com
Here's a minimalist working version, including an animation:


Joseph, why did you feel it necessary to add the compiler and symbols libraries to your version?

Joseph Elsherbini

unread,
May 22, 2013, 4:53:53 PM5/22/13
to glowscri...@googlegroups.com
I did not know what it would require, but then realised it still works without those libraries. That was tried before you pointed me to the help file about using glowscript outside glowscript.org


--

Bruce Sherwood

unread,
May 30, 2013, 11:59:52 PM5/30/13
to glowscri...@googlegroups.com
Here's a version of the bounce program: http://tributary.io/inlet/5682828
Reply all
Reply to author
Forward
0 new messages