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

#6101 2012-10-18 10:46:25

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

Re: BYOB 3 - Discussion Thread

Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting  XML code is  <ref id=whatever the object's ID stored in the table is/>


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

 

#6102 2012-10-18 10:54:12

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting  XML code is  <ref id=whatever the object's ID stored in the table is/>

Thanks, that makes sense. So it's not object specific? That's what confused me.

Offline

 

#6103 2012-10-18 11:23:54

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

Re: BYOB 3 - Discussion Thread

dreamod wrote:

joefarebrother wrote:

Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting  XML code is  <ref id=whatever the object's ID stored in the table is/>

Thanks, that makes sense. So it's not object specific? That's what confused me.

It's specific to that list, is it not?


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

Offline

 

#6104 2012-10-18 11:50:17

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

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

dreamod wrote:

joefarebrother wrote:

Every time an object with that should have an ID is encountered, it is given the "ID counter" (which starts off at 0) and it is incremented. The object along with it's ID is stored in a table so when the same object is encountered again, the resulting  XML code is  <ref id=whatever the object's ID stored in the table is/>

Thanks, that makes sense. So it's not object specific? That's what confused me.

It's specific to that list, is it not?

If you get Jens to explain it it will be more clearer


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

 

#6105 2012-10-18 12:00:59

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

Re: BYOB 3 - Discussion Thread

object IDs is something we don't have in BYOB, because Scratch doesn't have (need) them. But we need them on order to deal with circularity, because we have first-class lists.

The idea is to give every object a unique identifier when it's being stored. At first the identifier is nil, but when you first touch it to store it, you increment a counter and assign it to the object's identifier. Then when you come across an object you've already stored (which you recognize because it already has the id set to something other than nil) you don't store it again, but instead you just store a reference to that object. That reference is the object's ID.

In Smalltalk it's very hard to add object attributes on the fly, so it's probably best to add another instance variable (how about "serialization_id" to the Object class, or to use the existing object's #hash as an ID.


Jens Mönig

Offline

 

#6106 2012-10-18 12:26:53

dreamod
New Scratcher
Registered: 2012-01-22
Posts: 100+

Re: BYOB 3 - Discussion Thread

Jens wrote:

object IDs is something we don't have in BYOB, because Scratch doesn't have (need) them. But we need them on order to deal with circularity, because we have first-class lists.

The idea is to give every object a unique identifier when it's being stored. At first the identifier is nil, but when you first touch it to store it, you increment a counter and assign it to the object's identifier. Then when you come across an object you've already stored (which you recognize because it already has the id set to something other than nil) you don't store it again, but instead you just store a reference to that object. That reference is the object's ID.

In Smalltalk it's very hard to add object attributes on the fly, so it's probably best to add another instance variable (how about "serialization_id" to the Object class, or to use the existing object's #hash as an ID.

Thanks. By the way, what is the color property? Pen color?

Offline

 

#6107 2012-10-18 12:39:41

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

Re: BYOB 3 - Discussion Thread

dreamod wrote:

Thanks. By the way, what is the color property? Pen color?

Yes (also the sprite color in turtle mode).


nXIII

Offline

 

#6108 2012-10-19 06:38:30

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

Re: BYOB 3 - Discussion Thread

@bharvey: Dug out my old Scheme interpreter I was writing a few months ago this morning. I tinkered with it, then uploaded it to gdocs. I figured you'd want to check it out.  smile  Here's the link.

EDIT: My favorite program is the NQueens solver: input (@run "Examples/queens")

Last edited by Hardmath123 (2012-10-19 06:39:14)


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

Offline

 

#6109 2012-10-19 12:21:24

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

Re: BYOB 3 - Discussion Thread

@bharvey: posted this on another thread, Hardmath thought it might amuse you...  tongue

@Hardmath123: this seems cool! I like the pretty colours  big_smile  Although I haven't used nearly enough LISP/Scheme/whatever to try it out properly...

Last edited by blob8108 (2012-10-19 14:40:20)


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

Offline

 

#6110 2012-10-19 12:48:47

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

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

@bharvey: posted this on another thread, HardMath thought it might amuse you...  tongue

@HardMath123: this seems cool! I like the pretty colours  big_smile  Although I haven't used nearly enough LISP/Scheme/whatever to try it out properly...

Thanks!

P.S. I'm Hardmath. Lowercase m: sometimes people call me math to distinguish from Math (MathWhizz).


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

Offline

 

#6111 2012-10-19 14:42:12

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

P.S. I'm Hardmath. Lowercase m: sometimes people call me math to distinguish from Math (MathWhizz).

Got it.  tongue  All my posts mentioning you duly updated.


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

Offline

 

#6112 2012-10-19 16:37:22

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

My favorite program is the NQueens solver: input (@run "Examples/queens")

Yeah, that's a great problem.  Now solve it using call/cc!  tongue
(I mean, instead of those comparisons to 8.)


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

Offline

 

#6113 2012-10-19 19:43:43

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

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

@bharvey: posted this on another thread, Hardmath thought it might amuse you...  tongue

Indeed!


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

Offline

 

#6114 2012-10-22 14:06:23

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

Re: BYOB 3 - Discussion Thread

Check out Snap! in Japanese and http://snap.berkeley.edu/snapsource/sna … ng:ja_HIRA, both by the amazing Kazuhiro Abe!

Last edited by Jens (2012-10-22 14:13:11)


Jens Mönig

Offline

 

#6115 2012-10-22 16:18:09

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

Re: BYOB 3 - Discussion Thread

Jens wrote:

Check out Snap! in Japanese and http://snap.berkeley.edu/snapsource/sna … ng:ja_HIRA, both by the amazing Kazuhiro Abe!

The http block and the two Unicode blocks are still in English. Other than that... I don't know any Japanese so I can't tell you if they are translated correctly.


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

 

#6116 2012-10-23 13:10:22

scspaeth
Scratcher
Registered: 2010-02-14
Posts: 20

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Jens wrote:

Check out Snap! in Japanese and http://snap.berkeley.edu/snapsource/sna … ng:ja_HIRA, both by the amazing Kazuhiro Abe!

The http block and the two Unicode blocks are still in English. Other than that... I don't know any Japanese so I can't tell you if they are translated correctly.

Japanese readers and writers use roman letters for some words of foreign origin (as in http and Unicode) in addition to two phonetic alphabets and characters.

I read enough Japanese to assure you that they are an outstanding draft that will improve as the English keys continue to mature.

The bigger implication of this milestone is that it is the first fully Unicode translation that shows Snap can now be translated for a much broader range of world languages.

Last edited by scspaeth (2012-10-23 13:14:50)

Offline

 

#6117 2012-10-26 09:26:00

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

Re: BYOB 3 - Discussion Thread

Snap! is quickly becoming ever more internal. Check it in Korean and in Portuguese!


Jens Mönig

Offline

 

#6118 2012-10-26 11:37:22

scspaeth
Scratcher
Registered: 2010-02-14
Posts: 20

Re: BYOB 3 - Discussion Thread

Jens wrote:

Snap! is quickly becoming ever more internal. Check it in Korean and in Portuguese!

I am excited to see these contributions. I hope they develop into equally enthusiastic Snap! user communities.

I'm curious to know how the addition of these language files influences both machine requirements and performance of Snap. As you have it set currently, the snap.html loads all lang-xx.js files. So, it takes a little longer to start Snap but it uses only one translation dictionary at a time.

Are there any advantages to turning language loading scripts of languages I don't know into comments on my local copy of Snap?
Disadvantages?

Offline

 

#6119 2012-10-26 14:19:22

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

Re: BYOB 3 - Discussion Thread

Naw, they're just a bunch of dictionaries containing a limited number of strings. This is the 21st century where a single photograph is bigger than all of Snap, including all the language translations you can think of. We're in the GUI business, if we wanted to worry about conserving machine resources we'd use Scheme.  big_smile

Still, you're right. Ideally we'd dynamically load only the single translation which is currently needed. I've done some experiments with this, but they all turned out to be significantly slower and much more instable than what we have now. And don't forget: In regions of the world where you're neighbors speak a different language than you it's really nice to be able to frequently switch between languages just to learn something about the *language* (not the programming language).


Jens Mönig

Offline

 

#6120 2012-10-26 15:59:56

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

Re: BYOB 3 - Discussion Thread

Jens wrote:

I've done some experiments with this, but they all turned out to be significantly slower and much more instable than what we have now.

Code:

var script = document.createElement('script');
script.src = 'lang-de.js';
script.onload = function () {
    // update UI…
};
document.head.appendChild(script);

Will work in all modern browsers.


nXIII

Offline

 

#6121 2012-10-27 07:03:00

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

Re: BYOB 3 - Discussion Thread

You've asked for it: Morphic.js, Snap's central component and GUI engine, now on Github: https://github.com/jmoenig/morphic.js


Jens Mönig

Offline

 

#6122 2012-10-27 07:05:27

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

Re: BYOB 3 - Discussion Thread

Thanks, nXIII, that's a very good suggestion, and a lot easier to accomplish than what I had in mind! The only problem left is how to touch each file once to retrieve the language "header" info (lanugage name, translator credentials) before actually loading all of it later.


Jens Mönig

Offline

 

#6123 2012-10-27 09:10:54

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

Re: BYOB 3 - Discussion Thread

Jens wrote:

The only problem left is how to touch each file once to retrieve the language "header" info (lanugage name, translator credentials) before actually loading all of it later.

The only way to really accomplish that is to put that information in a separate file, or to make some server-side cleverness to do it for you.

Last edited by nXIII (2012-10-27 09:11:17)


nXIII

Offline

 

#6124 2012-10-27 10:03:39

scspaeth
Scratcher
Registered: 2010-02-14
Posts: 20

Re: BYOB 3 - Discussion Thread

Jens wrote:

You've asked for it: Morphic.js, Snap's central component and GUI engine, now on Github: https://github.com/jmoenig/morphic.js

Jens:

Thank you. This is yet another reason it is so gratifying to participate in this project. I not only get a chance to stand on others' shoulders, I get to see incremental process, learn by doing and reflect on it, too!
Wikipedia: Standing_on_the_shoulders_of_giants

-----------
Stephen Spaeth

Offline

 

#6125 2012-10-27 10:06:49

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

Re: BYOB 3 - Discussion Thread

nXIII wrote:

Jens wrote:

The only problem left is how to touch each file once to retrieve the language "header" info (language name, translator credentials) before actually loading all of it later.

The only way to really accomplish that is to put that information in a separate file, or to make some server-side cleverness to do it for you.

Or use XHRs cleverly, I suppose.


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

Offline

 

Board footer