This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#4126 2011-11-23 11:58:19

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

Isn't it awesome when it works out that way and no one gets to gloat?  smile

Jens is much too nice to gloat even when he has reason to.  smile
And I tend to do my own gloating in the privacy of my mind...

EDIT: ... except for that time, early on, when one of you posted something enthusiastic about zebra coloring and I posted an "I told you so." :-/

Last edited by bharvey (2011-11-23 11:59:48)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4127 2011-11-23 15:28:18

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Note: CONS isn't "insert at place 1"!  It does not modify its input list; it makes a new list (which shares storage with the input list).  In the BYOB 3 tools this is called ADJOIN (item) TO (list).  We're considering (item) IN FRONT OF (list) as an alternative.

er...

script variables (copy)
set [copy v] to (copy of (list given as input))
delete (1) of (copy)
report (copy)

does the same thing as your CDR script but is alot faster, and

script variables (copy)
set [copy v] to (copy of (list given as input))
insert (item to be inserted) at (1) of (copy)
report (copy)

does the same thing as your CAR script. In fact, you could make this block:

{apply (function) to (list)} where function is an inline script input and list is a list input.
script variables (copy)
set [copy v] to (copy of (list given as input))
run (function) with inputs (copy)
report (copy)

for a general function to make a new list and do something to it.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4128 2011-11-23 15:38:04

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

one of you posted something enthusiastic about zebra coloring and I posted an "I told you so." :-/

Us kids' personalities are rubbing off on you, eh?


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#4129 2011-11-23 15:45:38

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

delete (1) of (copy)

does the same thing as your CDR script but is a lot faster [...]

No, it doesn't.  Your version changes the original list; my version makes a new, shorter list.

There are two aspects to this that need discussion:   (1) Why would one care about changing vs. not changing the input list?  (2) Isn't it slow?

(1)  Functional programming is an idea that takes some getting used to, if you're accustomed to sequential programming with assignment.  But it's really, really useful, especially in the modern era of parallelism (e.g. multicore processors), because in a functional program, each little piece of the computation is independent of the other little pieces, so things can happen in different orders -- or in parallel, at the same time.  Once you allow changing the value of a variable, you have to worry about the order in which things happen and your programs are harder to parallelize.  Functional programming also avoids the sort of bugs in which one piece of a program changes the value of a variable that another piece of the program expects not to change.

And, believe it or not, once you get in the habit, it's much easier to think about algorithms programmed functionally.  And it's easier to prove theorems about functional algorithms.

You can really see the benefits of functional programming when dealing with recursively defined data structures such as trees.  The tree traversal algorithms in the textbooks are mostly really hairy and full of bookkeeping, whereas functional tree traversal is a piece of cake.

(2) The BYOB scripts I posted for CDR and CONS are indeed slow, but as of yesterday we have primitive CDR and CONS blocks that run in constant time!  This works because we store lists internally as true (linked) lists, made of pairs (arrays of length 2) whose first element (the CAR) is an item of the list and whose second element (the CDR) points to the rest of the list (another pair, or the empty list).  So CONS just creates one new pair, and CDR dereferences the second element of the pair.

So that Scratch-style list programs will also run fast, we actually implement both Scratch-style dynamic arrays and linked lists.  If you just use commands (e.g. INSERT, REMOVE) then your list will be stored as a dynamic array, but if you just use reporters (CAR, CDR, CONS, etc.) then your list will be stored as a linked list.  If you use both styles on the same list, then the list will be converted from one form to the other a lot and your program will be slow.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4130 2011-11-23 15:47:41

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

henley wrote:

Us kids' personalities are rubbing off on you, eh?

Not your personality; you're always the voice of reason around here.

I, on the other hand, never grew up, like Peter Pan.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4131 2011-11-23 16:06:22

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

some long text  tongue

that's cool. but what about merging and slicing? this is much more useful!  smile

Offline

 

#4132 2011-11-23 18:20:24

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

@Jens
"Try it on fractal turtle drawings and enjoy!"
Find herewith an example of warp improvement with this "fern" fractal.

Without/With warp = 870 sec/7.5 sec !!!

[img] http://www.xleroy.net/ByobTuto/New/Snap!/fernwarp.gif (/img]

Offline

 

#4133 2011-11-23 18:22:16

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

Sorry , bracket pb !

http://www.xleroy.net/ByobTuto/New/Snap!/fernwarp.gif

Offline

 

#4134 2011-11-23 20:32:11

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Xavier, these fractals are beautiful! I'm glad you're finding the WARP block useful.


Jens Mönig

Offline

 

#4135 2011-11-23 23:09:05

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Yay!  After several small list-related bugfixes, I can now do this:

http://cs.berkeley.edu/~bh/sort.png

and get an answer in less than a minute!

(@roijac:  See if the above answers your question about the usefulness of functional programming compared with JS merge and slice.  Not that the latter are useless, but you should have more than one string to your bow.)

EDIT:  It'll be even faster once the = block works correctly for empty lists.  hmm

EDIT 2:  And it doesn't even matter if you have a watcher watching BAZ, because it doesn't get its value until the very end, after all the work is done.

EDIT 3:  The quiz:  How come the base case for ODDS, EVENS, and MERGE can be just an empty list, but the base case for SORT has to be a list of length < 2?

EDIT 4:  See, the argument was that Jens thought WARP would solve the speed problem and I thought constant-time CDR and CONS would solve it, but if either of those is missing, mergesort of 1000 numbers is way too slow.  smile

Last edited by bharvey (2011-11-24 00:39:35)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4136 2011-11-24 04:05:34

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

Jens wrote:

Xavier, these fractals are beautiful! I'm glad you're finding the WARP block useful.

More than useful, vital !
The beauty of "warp" block compared to Byob "atomicity" button is that you can select the script that you want to "warp" . In another one application I have limited the "warping" to some  instructions and then I get a faster progressive graph instead of getting a "one shot flash displaying graph"

Offline

 

#4137 2011-11-24 07:53:03

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Yes, Xavier, that's what I like about the WARP block, too. For example I've played with a spirograph of spirographs and only warped the inner ones. that way - as you are saying, too - I can follow what's going on much better. When I was first writing BYOB in 2008 I actually started out with the WARP block, but I later replaced it for the "atomic" checkbox in the Block editor, because I did not want to introduce any new blocks. for the same reason I added a fixed "return value" field to the block editor when editing a custom reporter block, again because I did not want to introduce the REPORT block back then. Now, of course, we can do what's /right/ and add these features as blocks, what they should be.

Last edited by Jens (2011-11-24 07:54:22)


Jens Mönig

Offline

 

#4138 2011-11-24 09:44:12

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

xly wrote:

The beauty of "warp" block compared to Byob "atomicity" button is that you can select the script that you want to "warp".

jens wrote:

Now, of course, we can do what's /right/ and add these features as blocks, what they should be.

Hmm, I hadn't realized until this exchange that you guys want to keep WARP as the permanent user interface for atomicity.

I can see why that'd be appealing for command scripts, in which you can pick a subset of the script to run atomically.  But give a thought to the poor reporters., for whom atomicity should be the default.  One virtue of the check box is that it has the same meaning and the same UI for both commands and reporters.  What's the UI for de-warping a reporter going to be?


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4139 2011-11-24 10:19:16

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

The warp block is great!! But, the name "warp" is misleading in my opinion. Why not "make atomic"?

And I'm not sure I totally understood the question in the above post, but if we keep the "warp" name, then we could use "de-warp" and if "make atomic" is used, then my suggestion would be "make un-atomic".


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#4140 2011-11-24 10:57:00

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Snap! speed-up

Thanks to a hint from John Maloney composing blocks in the scripts pane of our Snap! pre-alpha version and editing text in input slots of long and nested scripts is now significantly faster, even in slower browers.

Check it out everybody, and thanks, John!

Last edited by Jens (2011-11-24 10:57:15)


Jens Mönig

Offline

 

#4141 2011-11-24 13:21:26

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

Jens wrote:

Snap! speed-up

Thanks to a hint from John Maloney composing blocks in the scripts pane of our Snap! pre-alpha version and editing text in input slots of long and nested scripts is now significantly faster, even in slower browers.

Check it out everybody, and thanks, John!

Help !
There is a mistake somewhere in your new speedy update.
Nothing works (like for example a simple factorial block)

Offline

 

#4142 2011-11-24 13:34:40

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I checked factorial and more, and for me everything works fine and super fast both on PC and on Mac in all available browsers, even IE, Safari and Opera. Please do make sure to reload the page emptying the browser's cache and try again!


Jens Mönig

Offline

 

#4143 2011-11-24 13:42:12

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

suggestion: it looks that you are going to definitely add much more blocks. that's cool, but the pallet design won't work. what do you say about a search bar at the bottom, while you can tip a part of the block and it updates the block list? would be especially useful for experted users, but you could always not type anything and search if you don't know how the block's called  smile

Offline

 

#4144 2011-11-24 13:43:37

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

xly wrote:

There is a mistake somewhere in your new speedy update.

Ah, good, this isn't one of those times when Jens puts in a bug that only affects me...   smile


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4145 2011-11-24 13:48:00

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

roijac wrote:

suggestion: it looks that you are going to definitely add much more blocks. that's cool, but the pallet design won't work.

Of course we're going to have separate palettes for the different colors, as before.  It'll be fine.

That's not to say a search bar wouldn't be cool too.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#4146 2011-11-24 14:28:38

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

@bharvey, try use the block palettes when you have about 10 defined blocks. especially control blocks, because you have to scroll it down *even in scratch*. would be a bit hard to use  sad
anyway, this is sooo far from what you have now (which is still very much) so i know i shouldn't expect anything  smile

Offline

 

#4147 2011-11-24 14:59:50

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

joefarebrother wrote:

delete (1) of (copy)

does the same thing as your CDR script but is a lot faster [...]

No, it doesn't.  Your version changes the original list; my version makes a new, shorter list.

Read the rest of the code. It uses the (copy of()) block, which creates a new list as a copy of an existing list.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#4148 2011-11-24 18:20:19

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Since this topic is getting old, and is about BYOB 3, not Snap!/BYOB 4, I took it upon myself to create a new topic!

Lo and behold... The Snap!/BYOB4 Discussion Thread!!

Unless we all want to be creatures of habit, and keep this topic.  tongue  We don't have to move if we don't want to. What do you guys think?

Last edited by henley (2011-11-24 18:20:34)


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#4149 2011-11-24 18:35:26

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Aren't we going to wait for Snap!'s official release? Plus, I think its only fair that Jens or Brian gets to manage the topic.  smile

Last edited by shadow_7283 (2011-11-24 18:36:51)

Offline

 

#4150 2011-11-24 20:00:06

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

Aren't we going to wait for Snap!'s official release? Plus, I think its only fair that Jens or Brian gets to manage the topic.  smile

They don't manage this one.

And why wait? There are so many suggestions, new ideas, etc.


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

Board footer