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

#6776 2013-02-06 13:31:37

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

Re: BYOB 3 - Discussion Thread

technoboy10 wrote:

what should I learn in my last two years of high school? I'm homeschooled, so I can pretty much pick and choose what to learn.  smile

You're so lucky!  (Provided you don't have we-don't-want-our-kid-learning-evolution parents.  Funny how homeschooling attracts the most and least intellectual parents.)

Disclaimer:  There's no official answer to your question; someone else might have very different ideas.

1.  SICP!  SICP!  SICP!

2.  As much math as you can.  Discrete math (logic, set theory, probability, mainly) is most directly applicable, plus linear algebra if you're interested in graphics.  But the starting point for a mathematical understanding of fractals is point set topology.  If you get interested in the related field of electrical engineering, you'll need complex analysis.  Of course you can do all that in college, but that'll be way easier if it's second time around.  And thinking like a mathematician, as distinct from knowledge about specific bits of math, is the most important skill you can have.  And, math is more fun than anything, even programming.  (Edit:  If you study calculus, use Tom Apostol's textbook.)

3.  Don't collect programming languages.  Learning a programming language, after the first time, is a one-weekend activity.  Instead, collect programming paradigms.  Understand functional programming; understand OOP; understand logic programming.  (To that end, learning other languages can help if they're languages that emphasize a paradigm you don't know yet.  So, instead of learning Java and Javascript and C++ and Python and Perl, which are really all the same language, learn ML (functional), Smalltalk (OOP), and Prolog (logic).)

4.  Don't spend all your time on technical stuff.  Read Freud.  Read Marx.  Read Dickens.  And find a DVD called "The TAMI Show" and watch it.

Last edited by bharvey (2013-02-06 13:33:08)


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

Offline

 

#6777 2013-02-06 19:27:20

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Thanks!  smile


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#6778 2013-02-06 19:55:32

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Hardmath123 wrote:

Now I can import everything except scripts and sounds!  big_smile

Wow!  Great start.

Thanks! It's not too hard; the formats are quite similar.

Scripts are pretty important.   tongue

Good point, that's next on my list. The thing is, I need to translate each block and separate out the procedures into custom blocks.

When you get this done, what do you want to build next?  The debugger?

Maybe. I was thinking about writing a fast Snap! interpreter in JS, since making my own language is clearly a pain, and I did write a nice little Scheme interpreter (with Lambda!).

@Jens: aside from the SVG glitch, I also (only once!) ran into a glitch where the whole UI just fell apart. There were hazy circles floating around (!!!) and all the panes were displaced.  hmm  I'll let you know if I can reproduce it.

Another issue I have is retrieving the project data (notes and creator's name). In Scratch 2.0 the API is beta.scratch.mit.edu/api/v1/project/<id>/?format=json. This only seems to work if you're looking up your project, and you're logged in. That's really strange. How do I access this from Python? It treats me as not-logged-in from a urllib request and gives me a blank page.

@Cloning: bharvey, have you been to the Scratch 2.0 Beta site? Check it out, it's really well made. But I want to point out specifically how cloning works there, because I think that's a good way to do it and I'm 80% sure that's  similar to what Jens did on Snap!. Basically, you only have 3 clone blocks: clone[myself|sprite list], delete this clone, and a {clone startup} hat block, which is triggered whenever the clone is initialized. On cloning, you retain all the features (position, direction, etc.).


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6779 2013-02-06 21:16:23

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I was thinking about writing a fast Snap! interpreter in JS

Interesting.  An interpreter for visual Snap!?  On top of Morphic?  Or an interpreter for Snap!-as-text?

What I'd really like in that family of project is a Snap!-to-JS compiler, just for speed purposes (the JS wouldn't be human-readable, probably, just a bunch of procedure calls), although I think Jens thinks there wouldn't be that much benefit because it'd have to accommodate the Scratch-style lockstep scheduler and all the display stuff, which is where a lot of the time goes.  (EDIT: What we really need is for JS to have first class continuations.  Or everyone to redo their web browsers using Scheme.)

But I want to point out specifically how cloning works there, because I think that's a good way to do it and I'm 80% sure that's  similar to what Jens did on Snap!.

Oh yes, they've had that design for years and we both know it well.

But, sorry, Hardmath, I really hate to be like this, but I don't want to talk about cloning until we're ready to talk about it in one voice.  That shouldn't take long; please bear with us.

Last edited by bharvey (2013-02-06 21:44:49)


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

Offline

 

#6780 2013-02-07 06:06:59

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

the API is beta.scratch.mit.edu/api/v1/project/<id>/?format=json. This only seems to work if you're looking up your project, and you're logged in. That's really strange. How do I access this from Python? It treats me as not-logged-in from a urllib request and gives me a blank page.

I've mentioned it before, but try httplib2 — it handles forms and cookies better than urllib, so you can login using the main site login (which I can't find right now!).


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6781 2013-02-07 07:26:42

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Httplib2 looks cool, thanks. I'm 80% sure it's at beta.scratch.mit.edu/login/, but I get 403 forbidden when I try to access it with the example on the site you linked to.  hmm

EDIT: And Internal server error if I try to access it from the browser…

Last edited by Hardmath123 (2013-02-07 07:27:07)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6782 2013-02-07 07:32:32

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

If everything else fails, I can actually load the project page and parse the HTML I get to find the notes and creator. But I'm not too convinced that that's a good idea, and would rather use that as a last resort.

@bharvey: It it alright if it's a command-line tool?

Code:

cd ~/path/to/my/tool
./snapin8r.py 100203

(100203 being the ID of the project on the main site). It will take two parameters, one for an output file, the other being a boolean flag telling it whether to open the project instantly or not—I use the #open: trick and Python's webbrowser module to open projects automatically for debugging, and I figured it would be useful for users, too.  big_smile

EDIT: Of course, it also takes --help for help.

Last edited by Hardmath123 (2013-02-07 07:32:52)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6783 2013-02-07 07:46:35

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

@Jens more errors—this time a CORS error!

Code:

Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
morphic.js:2954 SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.

The only costume was the Scratch cat SVG. Thoughts?

Last edited by Hardmath123 (2013-02-07 07:47:02)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6784 2013-02-07 08:40:59

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

Re: BYOB 3 - Discussion Thread

Aha, hmm. Maybe you have to export the Scratch project using Scratch's FILE menu, first? Or we have to ask the Scratch Team to add a CORS header for Snap...


Jens Mönig

Offline

 

#6785 2013-02-07 09:26:17

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I'm 80% sure it's at beta.scratch.mit.edu/login/

I couldn't find the login page, either. I tried again just now and it does seem to be there (/login/), but I can't find the parameters...

Hardmath123 wrote:

I can actually load the project page and parse the HTML

BeautifulSoup's a good library for that task!  tongue  But yes, really don't do that.

EDIT: remove excessive colon-Ps

Last edited by blob8108 (2013-02-07 10:57:06)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6786 2013-02-07 10:18:09

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

Is it alright if it's a command-line tool?

Aww, we can't just drag the project from their page to ours?
I'll let Jens answer that; he's the drag-and-drop fan.


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

Offline

 

#6787 2013-02-07 10:55:15

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

Re: BYOB 3 - Discussion Thread

If the Scratch website supports CORS, we could it just load Scratch projects directly (and by drag and drop)...


Jens Mönig

Offline

 

#6788 2013-02-07 11:01:08

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

Re: BYOB 3 - Discussion Thread

I think we should have more control over threads in snap!. To accomplish this, I think the LAUNCH block should return a procedure that is the thread's control procedure. When this is called with no arguments, it will stop the tread and return the thread's continuation (a command one with no arguments) which can be called to resume the thread. When the thread finishes, it's thread control procedure will return a function which when called, returns the value if it exited via REPORT, or returns "No Value" or something if it exited via STOP BLOCK. The way to distinguish between these "finished thread functions" and a thread continuation would be that when it's finished, the control procedure will return the same function (in terms of IS IDENTICAL TO?) but successive callings will return different continuations of a running thread even if called while it is stopped. The thread control procedure could also be called with one argument, a procedure, that replaces the thread's continuation with that procedure, resuming it if it is currently stopped by the control procedure of no args. This is so you could make the thread do something extra when it's finished or something with the thread control procedure being able to keep up. I think that is all you need to implement thread control tools like pausing and resuming it, making something happen when the thread finishes, waiting for a thread to finish, ect.
(there could also be a block called THIS THREAD'S CONTROL PROCEDURE or something for even more control)


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

 

#6789 2013-02-07 11:11:38

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

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

I think we should have more control over threads in snap!. To accomplish this, I think the LAUNCH block should return a procedure that is the thread's control procedure.

That's a really interesting idea.  For the "maybe 4.2 or 4.3" list.  We already have continuations so it's kind of a natural.


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

Offline

 

#6790 2013-02-07 11:35:28

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

@Hardmath: Okay, now I'm getting this Django response page:

Forbidden (403)
CSRF verification failed. Request aborted.

Request:

Code:

headers = {'Content-type': 'application/x-www-form-urlencoded'}
data = urlencode({"username": "blob8108", "password": "whatever"})
(response, content) = http.request("http://beta.scratch.mit.edu/login/", "POST", data, headers=headers)

EDIT: I'm now convinced the API only allows access to your own projects.  hmm

Last edited by blob8108 (2013-02-07 12:11:35)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6791 2013-02-07 12:42:27

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Maybe use this? http://beta.scratch.mit.edu/internalapi/project/<id>/get


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#6792 2013-02-07 14:02:25

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

MathWizz wrote:

http://beta.scratch.mit.edu/internalapi/project/<id>/get

Oh, clever! And this for the images and media:
http://beta.scratch.mit.edu/internalapi/asset/<filename.png>/get/


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6793 2013-02-07 14:54:04

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

MathWizz wrote:

http://beta.scratch.mit.edu/internalapi/project/<id>/get

Oh, clever! And this for the images and media:
http://beta.scratch.mit.edu/internalapi/asset/<filename.png>/get/

Yeah, but most Scratch 2.0 assets are .svg, not .png.

blob8108 wrote:

@Hardmath: Okay, now I'm getting this Django response page:

Forbidden (403)
CSRF verification failed. Request aborted.

Request:

Code:

headers = {'Content-type': 'application/x-www-form-urlencoded'}
data = urlencode({"username": "blob8108", "password": "whatever"})
(response, content) = http.request("http://beta.scratch.mit.edu/login/", "POST", data, headers=headers)

It has CSRF (cross-site request forgery) protection; you need to GET the main site or any other page and get a CSRF token.


nXIII

Offline

 

#6794 2013-02-07 15:35:20

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

blob8108 wrote:

MathWizz wrote:

http://beta.scratch.mit.edu/internalapi/project/<id>/get

Oh, clever! And this for the images and media:
http://beta.scratch.mit.edu/internalapi/asset/<filename.png>/get/

Yeah, but most Scratch 2.0 assets are .svg, not .png.

I assumed the other media files could be retrieved in the same way...

you need to GET the main site or any other page and get a CSRF token.

Oh, will any page do? I assumed you'd need to get the login form. Cool!
But you still need to parse the HTML, don't you? Meh.


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6795 2013-02-07 15:57:13

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

nXIII wrote:

blob8108 wrote:


Oh, clever! And this for the images and media:
http://beta.scratch.mit.edu/internalapi/asset/<filename.png>/get/

Yeah, but most Scratch 2.0 assets are .svg, not .png.

I assumed the other media files could be retrieved in the same way...

Yeah, I was just pointing out that you probably shouldn't hard-code ".png" in your script.

you need to GET the main site or any other page and get a CSRF token.

Oh, will any page do? I assumed you'd need to get the login form. Cool!
But you still need to parse the HTML, don't you? Meh.

You can just search for the string:

Code:

name='csrfmiddlewaretoken' value='

and go to the next quotation mark.


nXIII

Offline

 

#6796 2013-02-07 16:49:32

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

just pointing out that you probably shouldn't hard-code ".png" in your script.

Sure  smile

You can just search for the string:

Code:

name='csrfmiddlewaretoken' value='

and go to the next quotation mark.

...ew.  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6797 2013-02-08 03:03:00

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

Re: BYOB 3 - Discussion Thread

About cloning etc.

Sorry for all the mystery.  We decided that it would be wrong to put a bunch of new Scratch 2.0 features in Snap! when they've just gone beta, without the permission of the Scratch Team -- especially in light of the fact that we've had privileged access to their plans and partial implementations from the beginning.  I am pleased to say that as of today we do have their permission.  (Had it gone the other way I wouldn't be explaining all this, lest people start thinking "it's the S.T.'s fault that Snap! doesn't do X."  So that's another reason I'm pleased; I don't like secrets, even though sometimes they're necessary.)

So you're going to start seeing things like turbo mode and cloning in Snap! as soon as Jens gets out from under a current burst of work in his real job.  Cloud variables, eventually, too, once our server handles sharing.  (The first release will probably only handle private storage.)

On cloning specifically, Scratch-style cloning will augment, not replace, BYOB 3.1-style cloning.  We have yet to determine how these will fit together.  (The "Duplicate" context menu item is yet a third way to make a sort-of-copy of a sprite, and that's just too many.  I'm leaning toward eventually making BYOB-style the only sort-of-copy, maybe with different degrees of initial sharing of properties.)  Cloning in Snap! 4.2 won't be exactly like BYOB 3.1; people found that too confusing, although the underlying ideas are good.

Scratch-style cloning is a brilliantly simple design and does most of what people need for building bricks and bullets and so on.  We don't want to lose that.  But we're not just in the business of building projects; the whole reason we have a separate Scratch-like thing is to use in teaching computer science to teenagers, and in that context the purpose of cloning is teaching OOP in all its complex structure, including inheritance and message passing.  Our job is to figure out how to have our cake and eat it too.

--------

OK, that's the communiqué.  What follows are my first thoughts about the 4.1 design.

Basically two things confused people, I think:  (1) using getter functions to represent an object property; (2) using the circumlocution RUN (method OF object) to mean ASK object TO RUN method.  And maybe also (3) the blurring of the message/method distinction in a visual programming environment, but I don't think we want to lose the power of that.

I'm hoping that the new 4.0 ring design for lambda will help a lot with both of these; it makes the procedure-ness of the getter functions less obtrusive.  I've just this second had the probably-crazy idea that when you drag an OF block into the ring of a CALL or RUN or LAUNCH, the ring automatically moves into the first input slot of the OF.  (Just this second, as in, Jens hasn't heard this yet, and probably won't like it.)  Another thing we might do, less kludgy because it uses a mechanism we already have, would be to change the DELETE block (which we're going to rename DELETE/INHERIT) to a special form with an Any (Unevaluated) input slot instead of a Reporter input slot.

(EDIT:  Also, after I talk Jens into making the tools blocks auto-loaded, nobody will have to use RUN [() OF ()] because we'll have the TELL and ASK blocks in the Control palette!)

I'm throwing out these preliminary ideas not so much to start a discussion on the specific ideas (although that's okay too) as to make the point that the design changes we anticipate are small details, although maybe several such details.  We're not rethinking the big ideas (such as prototyping, sorry, B.A.A.).  We're not going to lose the gems of UI design such as the ghosting-out of the getters for inherited properties in the palettes.

Last edited by bharvey (2013-02-08 03:15:17)


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

Offline

 

#6798 2013-02-08 05:47:19

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

MathWizz wrote:

http://beta.scratch.mit.edu/internalapi/project/<id>/get

Oh, clever! And this for the images and media:
http://beta.scratch.mit.edu/internalapi/asset/<filename.png>/get/

I'm already doing that to get the data (images, sounds and scripts), I just need a way to get the project notes, creator name, and other junk like that.

@Jens I got sounds and scripts working (I still need to make a library to translate Scratch 2.0 blockspecs to Snap! specs… but I'm procrastinating that.  tongue ). Are the 'id' attributes required for lists of costumes/sounds? It works without it, so it can't be vital.  hmm

@bharvey The best way would be for you to be able to type the project's URL under "open…" (open>Scratch 2.0 project>[dialog box]). You would send the URL to a Python server running my converter, and I would return the XML from a GET request. Happy?

Also, has Jens started on the server yet, and if so, is it in Python? I'd suggest in the end using Google App Engine to get the final release at snap.edu or something.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6799 2013-02-08 08:25:00

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Ok, scripts are working, and I wrote the converter dictionary. Now moving on to lists and custom blocks. This is addictive.  big_smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6800 2013-02-08 08:42:47

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

Re: BYOB 3 - Discussion Thread

@bharvey "About cloning etc."
May I give you the layman viewpoint.
OOP features of old Byob3.1 are very powerful and full of capabilities to write kids projects with bunches of targets, mobiles, monsters, bricks etc But these capabilities have been poorly documented and suffer of no project-sharing to offer examples of applications. IMHO you could in a first stage simply port Byob 3.1 OOP system in Snap!
But one may regret that Byob OOP does not expose the traditionnal CLASS instruction as used by Java,JS and others. Byob 3.1 can mimick this (see page 30 of your documentation). But for "compliance" reasons, it should be wise to provide one CLASS instruction not related to a SPRITE with its own graphical & visual characteristics. Something similar to your Dispatch/Method procedures as documented into page 27 to 30 of your documentation. For example you create a CLASS of circles and then you can use it to display a lot of circles, or move dozens of simple shapes without needing to create a lot of real cloned sprites.

Last edited by xly (2013-02-08 08:47:48)

Offline

 

Board footer