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

#5301 2012-05-31 08:00:24

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

Re: BYOB 3 - Discussion Thread

jji7skyline wrote:

Will Snap ever be offline?

Yes, one way or another.  Does it count as "offline" for you if you download the html and js files, and then run your local copy from your browser?


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

Offline

 

#5302 2012-05-31 09:33:51

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

Re: BYOB 3 - Discussion Thread

bharvey, do you have a working Mac which you have access to now/in the near future?


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

Offline

 

#5303 2012-05-31 12:20:26

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

bharvey, do you have a working Mac which you have access to now/in the near future?

I'm typing on a MacBook as we speak!  smile   Why?


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

Offline

 

#5304 2012-05-31 13:04:44

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Yes, one way or another.  Does it count as "offline" for you if you download the html and js files, and then run your local copy from your browser?

As I've said before, I think Windows 8 would be a great opportunity for an offline Snap! It's even allows for open source licenses, and developing an app is almost as simple as copying and pasting the html and JavaScript files.

Offline

 

#5305 2012-05-31 15:37:12

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

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

joefarebrother wrote:

I just realized: one really useful feature that's been left out of snap!: Mesh!

Well I sent this off to the Snap! mailing list but I suppose you all will probably find this interesting too...I wrote a re-implementation of Mesh for Snap! using a WebSockets. It's not quite like Scratch's Mesh, since the server is an external program and not part of the IDE itself, but it's rather more flexible. These are the blocks I included:

join mesh at [host]
Attempts to connect to the Mesh server at the remote address host.

leave mesh
Disconnects from the current mesh

send [message] to [List|String clients]
Sends the message message to all clients in clients (may be an address or list of addresses). Currently this causes all clients that receive the message to broadcast [message], although when Jens invents hat blocks with upvars, this could get its own hat block.

set global [var] to [val] in mesh
The Mesh server keeps a hash of global variables that can be set by any client. This block sets the value of the global hash at var to val.

set my [var] to [val] in mesh
The Mesh server also keeps a hash of variables unique to each client that can be set by that client and queried by any other client. When a client disconnects, their local hash is destroyed and its contents are irretrievable even if they reconnect from the same address. This block sets the value of the client's hash at var to val.

global [var] in mesh
Returns the value of var in the global hash.

[var] of [client] in mesh
Returns the value of var in client's hash.

others in mesh
Returns the addresses of all clients connected to the mesh except for the local client.

my address
Returns the local client's address as seen by the Mesh server.

mesh status
Returns a string based on the value of the Mesh's webSocket's readyState property:

"connecting" if readyState == 0
"connected" if readyState == 1
"disconnecting" if readyState == 2
"disconnected" if readyState == 3

These strings correspond to the meanings of the readyState codes as described in the WebSocket specifications.

You can download the changeset here and include it in your local copy of Snap! by adding the following in the <head> tag of nasciturus.html:

Code:

<script type='text/javascript' src='mesh.js'></script>

This will add the mesh blocks to Snap! The server is Mesh.rb...if you're not sure how to run a Ruby file, see here. While the server is running, anyone who knows the IP address of the computer running the script can join the mesh.

Like Brian said, this is unlikely to make it into the August version...Jens is working hard on making Snap 4.0 look like BYOB 3.1 and I suspect that dealing with a horde of new blocks is the last thing he needs. However, it's certainly fun to use and I thought I'd leave it here for you guys to tinker with!  big_smile

Well the cool thing about BYOB 3.1 mesh is that it can also connect to scratch 1.4 projects and panther projects. Will that be possible with mesh in snap!, too?


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

 

#5306 2012-05-31 15:39:17

Bklecka
Scratcher
Registered: 2011-08-27
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

fullmoon wrote:

joefarebrother wrote:

I just realized: one really useful feature that's been left out of snap!: Mesh!

Well I sent this off to the Snap! mailing list but I suppose you all will probably find this interesting too...I wrote a re-implementation of Mesh for Snap! using a WebSockets. It's not quite like Scratch's Mesh, since the server is an external program and not part of the IDE itself, but it's rather more flexible. These are the blocks I included:

join mesh at [host]
Attempts to connect to the Mesh server at the remote address host.

leave mesh
Disconnects from the current mesh

send [message] to [List|String clients]
Sends the message message to all clients in clients (may be an address or list of addresses). Currently this causes all clients that receive the message to broadcast [message], although when Jens invents hat blocks with upvars, this could get its own hat block.

set global [var] to [val] in mesh
The Mesh server keeps a hash of global variables that can be set by any client. This block sets the value of the global hash at var to val.

set my [var] to [val] in mesh
The Mesh server also keeps a hash of variables unique to each client that can be set by that client and queried by any other client. When a client disconnects, their local hash is destroyed and its contents are irretrievable even if they reconnect from the same address. This block sets the value of the client's hash at var to val.

global [var] in mesh
Returns the value of var in the global hash.

[var] of [client] in mesh
Returns the value of var in client's hash.

others in mesh
Returns the addresses of all clients connected to the mesh except for the local client.

my address
Returns the local client's address as seen by the Mesh server.

mesh status
Returns a string based on the value of the Mesh's webSocket's readyState property:

"connecting" if readyState == 0
"connected" if readyState == 1
"disconnecting" if readyState == 2
"disconnected" if readyState == 3

These strings correspond to the meanings of the readyState codes as described in the WebSocket specifications.

You can download the changeset here and include it in your local copy of Snap! by adding the following in the <head> tag of nasciturus.html:

Code:

<script type='text/javascript' src='mesh.js'></script>

This will add the mesh blocks to Snap! The server is Mesh.rb...if you're not sure how to run a Ruby file, see here. While the server is running, anyone who knows the IP address of the computer running the script can join the mesh.

Like Brian said, this is unlikely to make it into the August version...Jens is working hard on making Snap 4.0 look like BYOB 3.1 and I suspect that dealing with a horde of new blocks is the last thing he needs. However, it's certainly fun to use and I thought I'd leave it here for you guys to tinker with!  big_smile

Well the cool thing about BYOB 3.1 mesh is that it can also connect to scratch 1.4 projects and panther projects. Will that be possible with mesh in snap!, too?

woah. to lazy to try it but it sounds great!


http://i48.tinypic.com/106ijc9.jpg

Offline

 

#5307 2012-05-31 20:02:44

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Well the cool thing about BYOB 3.1 mesh is that it can also connect to scratch 1.4 projects and panther projects. Will that be possible with mesh in snap!, too?

Not for the foreseeable future, but that's certainly something to consider. A bit of technical jargon here: Mesh communication in Scratch happens through TCP sockets, which are basically just a way for a client and a server to have a two-way exchange of data with one another. Unfortunately, no browsers currently give us full access to TCP sockets so my Mesh system is built on the WebSocket protocol. WebSockets are a new feature in browsers that allow for socket communication with a certain set of rules...essentially, they can only communicate with servers that identify themselves as WebSocket servers by using the ws(s):// protocol (compare to http:// or ftp://. So until full socket functionality is added to major browsers, Snap's connectivity is pretty limited.

TL;DR: No. ;)

Last edited by fullmoon (2012-05-31 20:03:04)


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5308 2012-05-31 20:24:27

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

jji7skyline wrote:

Will Snap ever be offline?

Yes, one way or another.  Does it count as "offline" for you if you download the html and js files, and then run your local copy from your browser?

No, I kinda want it to be a proper stand alone application  tongue


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#5309 2012-05-31 20:31:11

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

jji7skyline wrote:

bharvey wrote:

jji7skyline wrote:

Will Snap ever be offline?

Yes, one way or another.  Does it count as "offline" for you if you download the html and js files, and then run your local copy from your browser?

No, I kinda want it to be a proper stand alone application  tongue

Hmm... maybe it could be an app on the Chrome Web Store?  tongue


http://i.imgur.com/WBkM2QQ.png

Offline

 

#5310 2012-05-31 21:03:54

OldCodger
New Scratcher
Registered: 2012-05-16
Posts: 54

Re: BYOB 3 - Discussion Thread

bharvey wrote:

OldCodger wrote:

Counting from 0 is mostly associated with immutable data structures like arrays, where you use an index to get at the elements. Lists are mutable data structures and the classic way to use lists is by recursion.

Don't be overinfluenced by the fact that Scratch calls them "lists."  Scratch lists are really dynamic (resizable) arrays, so indexing them is constant time.  So are BYOB lists.  But Snap! lists are hybrid; under the hood, we have both dynamic arrays and linked lists.  If you cons (IN FRONT OF) together a list, you get a linked list; if you build it imperatively (ADD TO LIST), you get a dynamic array.  You can cons onto a dynamic array and it works -- the user never has to know that there are two implementations -- but your program runs a lot faster if you are consistent about how you use any one list.

So the index origin issue does have to be settled.  smile

List to array: sounds like quicksand to me!

Offline

 

#5311 2012-05-31 22:01:43

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

Re: BYOB 3 - Discussion Thread

Lucario621 wrote:

Hmm... maybe it could be an app on the Chrome Web Store?  tongue

Did no one read the comment about Windows 8? XD

Offline

 

#5312 2012-05-31 23:52:17

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Lucario621 wrote:

jji7skyline wrote:

bharvey wrote:


Yes, one way or another.  Does it count as "offline" for you if you download the html and js files, and then run your local copy from your browser?

No, I kinda want it to be a proper stand alone application  tongue

Hmm... maybe it could be an app on the Chrome Web Store?  tongue

Oh no, not the Chrome web store  tongue


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#5313 2012-05-31 23:56:11

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

Re: BYOB 3 - Discussion Thread

jji7skyline wrote:

No, I kinda want it to be a proper stand alone application

I do too, really.  Ideally we'd find a standalone JS that works on every platform (@shadow: I think that rules out Windows 8) and is free of restrictive licenses (rules out that Adobe one).  But it's not first priority.  We'll get there eventually.


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

Offline

 

#5314 2012-05-31 23:59:17

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

Re: BYOB 3 - Discussion Thread

OldCodger wrote:

List to array: sounds like quicksand to me!

It's problematic if you use both functional (reporters) and mutation (commands)  approaches to updating a list.  If you stick with one, everything you want to do is Theta(1) time and it works like a dream.

The only thing about hybrid lists is that you can say

(value) IN FRONT OF (LIST (item) (item) (item))

and it takes Theta(1) time b/c it doesn't have to convert the format of the existing list.

"List to array" only happens if you start mutating a list that you consed together.


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

Offline

 

#5315 2012-06-01 00:16:50

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

Re: BYOB 3 - Discussion Thread

As always, Brian, the translations are very helpful!  smile 
Though I did wonder if theta always means one in computer science or...? I wikipediad it and found its numeric value is usually 9.

As for a platform for a standalone application, I may have found an alternative. Titanium looks promising. It is released under the Apache open source license. Although at first glance it appears to be exclusively for mobile devices, it actually runs natively on Linux, Windows, and OSX. Unfortunately, in the business world open source isn't always synonymous with free, but the free plan looks like it would suit Snap's needs.

Last edited by shadow_7283 (2012-06-01 00:37:32)

Offline

 

#5316 2012-06-01 04:42:45

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

Re: BYOB 3 - Discussion Thread

I can package Snap! as a standalone Mac application, down to the icon and top menu bar. In fact, if Jens wishes, the menu on top of the Snap! application can be a native Mac menu bar! Also, native help menus, custom file saving with .snap extensions and a logo with Alonzo The Gobo... I can also make an iOS app with the Snap! application, though you can simulate the results unofficially by clicking the share icon, then "add to home screen" (which reminds me, you need a favicon urgently).  big_smile

@bharvey: I'm almost done with a complete Scheme interpreter, I just need to file in a legitimate Scheme environment. It's written in Objective-C so you can only run it on a Mac, hence the question. My issues now are dynamic environments; if this was JS I'd use an object with key-lambda pairs, but Obj-C isn't very Lambda-friendly so I still need to figure that out. Using a bunch of

Code:

if (token == @"+" && [check for syntax errors]) {return (value)}

constructs seems ugly, and it doesn't allow for adding new variables like you would with define or lambdahmm

EDIT: I figured out how to use a lambda-like thing in Obj-C, but now I can't figure out how to actually implement lambda  tongue . I'm using applicative-order evaluation, so it tries to evaluate the arguments to any expression before evaluating the expression. Unfortunately, in lambda you don't want the arguments evaluated. How would one go about that?

Last edited by Hardmath123 (2012-06-01 05:58:08)


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

Offline

 

#5317 2012-06-01 10:47:14

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

Re: BYOB 3 - Discussion Thread

I think the long-forgotten iOS Scratch app proves that Apple isn't open to the idea of programming in their store.

Offline

 

#5318 2012-06-01 11:02:22

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

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

I think the long-forgotten iOS Scratch app proves that Apple isn't open to the idea of programming in their store.

...

Things changed. If you look in the App Store, you'll find an app called JS Anywhere, which allows you to code and test JavaScript.  hmm


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

Offline

 

#5319 2012-06-01 11:41:18

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

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Don't be overinfluenced by the fact that Scratch calls them "lists."  Scratch lists are really dynamic (resizable) arrays, so indexing them is constant time.  So are BYOB lists.  But Snap! lists are hybrid; under the hood, we have both dynamic arrays and linked lists.  If you cons (IN FRONT OF) together a list, you get a linked list; if you build it imperatively (ADD TO LIST), you get a dynamic array.  You can cons onto a dynamic array and it works -- the user never has to know that there are two implementations -- but your program runs a lot faster if you are consistent about how you use any one list.

But wouldn't it be possible to implement the imperative functions in terms of the functional functions, like

set [mylist v] to <(an item to insert) in front of (mylist)>
and similar scripts for other functions?

Last edited by joefarebrother (2012-06-01 11:43:32)


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

 

#5320 2012-06-01 12:32:07

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

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

Though I did wonder if theta always means one in computer science or...? I wikipediad it and found its numeric value is usually 9.

I think you found the wrong Wikipedia article.  This Theta (capital) is a function, not a number; it takes another function as argument and its value is the set of all functions whose computation time is within a constant factor of the argument function.  So for example, all the obvious sort algorithms are in Theta(n^2), but the good ones are in Theta(n log n).  So Theta(1) means that it takes a constant time to compute regardless of the size of the list.

As for a platform for a standalone application, I may have found an alternative. Titanium looks promising.

Hmm, maybe, although I'd rather have really free software if we can find it.


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

Offline

 

#5321 2012-06-01 13:50:38

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

Re: BYOB 3 - Discussion Thread

Snap is
Not an
Acronym for a
Program


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

 

#5322 2012-06-01 14:26:18

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I can package Snap! as a standalone Mac application, down to the icon and top menu bar.

Does this mean wrapping a .app folder around a browser, or do you have a standalone HTML5 canvas thingy?

(which reminds me, you need a favicon urgently).  big_smile

http://snap.berkeley.edu/favicon.png

I'm using applicative-order evaluation, so it tries to evaluate the arguments to any expression before evaluating the expression. Unfortunately, in lambda you don't want the arguments evaluated. How would one go about that?

If you're using applicative order evaluation, then you need special forms -- expressions that are exceptions to the evaluation rule and effectively use normal order.  LAMBDA is one of these, along with IF, COND, DEFINE, SET!, LET, etc.

The explicit control evaluator builds each special form into the code explicitly, the way you don't like.  But this exercise hints about how to use a table of special form keywords ("lambda," etc.) instead.

If this isn't helpful, you'll have to tell me more about what your evaluator looks like overall.


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

Offline

 

#5323 2012-06-01 14:28:05

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

If you look in the App Store, you'll find an app called JS Anywhere, which allows you to code and test JavaScript.  hmm

I think they're okay with Javascript because of its security restrictions.  Still no Flash, so no Scratch 2.0, unless they change their policy.


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

Offline

 

#5324 2012-06-01 14:31:31

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

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

set [mylist v] to <(an item to insert) in front of (mylist)>

Yes, that's fine, because you're not mutating the list; instead you're making a new list and mutating the variable that was bound to the list.

Basically you want imperative style if you're jumping around in the list a lot.  For example, some sort algorithms (e.g. Quicksort) require you to swap two list elements that are in basically unpredictable positions.  Imperative style can do all that in Theta(1) time per swap.  (By contrast, Mergesort is easier done functionally, with linked lists.)


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

Offline

 

#5325 2012-06-01 14:35:53

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

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

Snap is
Not an
Acronym for a
Program

Cute.

We often tell people it's the Software for the New Advanced Placement course.  smile


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

Offline

 

Board footer