jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.5k stars 745 forks source link

stop timer, start timer blocks #423

Closed marwahaha closed 10 years ago

marwahaha commented 10 years ago

Talked to a CS10 student who suggested we have these blocks. Thoughts?

brianharvey commented 10 years ago

Not needed as primitive:

timer

stoptimer

And similarly for the other timer operations. Besides start and stop, this gives you multiple independent timers. (I haven't actually debugged it, so maybe I got the arithmetic wrong somewhere.) The only disadvantage is that you can't easily have a watcher for the value, but watching the timer is pretty hopeless anyway.

So, on the principle that we shouldn't preempt good programming projects by making them primitives, I vote no on this.

khotchkiss13 commented 10 years ago

I agree with @brianharvey While I think that these would make some projects easier, I think that unless this is something that comes up a lot, that we can allow the user to create them themselves. That is why we have custom blocks.

cycomachead commented 10 years ago

I was waiting for @brianharvey to share that example. Though it is something students often ask about. Perhaps we should create a new way of sharing libraries and blocks.

brianharvey commented 10 years ago

On 5/7/14 11:05 PM, Michael Ball wrote:

I was waiting for @brianharvey to share that example.

http://snap.berkeley.edu/snapsource/snap.html#present:Username=bh&ProjectName=timers

xtitter commented 10 years ago

Nice solution. (although I'd recommend renaming (timer []) to (current time of []) or something)

This certainly isn't something we should expect CS10 or high school BJC students to write for themselves, however!

jmoenig commented 10 years ago

But it's really beautiful, very much the kind of stuff I love Snap for!

xtitter commented 10 years ago

closure-based oop ftw! I'd be a big proponent of including it in snap by default, so the BJCers can make use of it, and keeping it as 'written in snap' so it can be inspected and learned from.

Two issues: (a) the watcher for a variable that stores a timer is pretty horrible; there should be a way to make a watcher of a closure more reasonable (maybe the return value of passing in 'default' or something? ug. Or, a local-variable named 'documentation' or 'watcher' that can store a message of some sort).

(b) The same instructional benefit of having advanced blocks written in snap rather than javascript is true for all the libraries. More impetus for the rumored dual javascript/snap implementation that will speed up loading. Or, some ability to pre-compile these snap blocks to quicken the load time.

brianharvey commented 10 years ago

< offtopic=curriculum>You think it's too hard for BJC students because you're imagining that they would have to _invent_ closure-based OOP. But I didn't have to invent it for this project; it's in my repertoire of programming conventions. And the actual timer part of the project is trivial. So, imagine that we _taught_ closure-based OOP. Would this still be beyond the capabilities of a high schooler?< /offtopic>

cycomachead commented 10 years ago

I guess this whole discussion is a bit off-topic, but I think it'd be nice to develop a better way of sharing libraries + blocks.

khotchkiss13 commented 10 years ago

Would it be possible to, once the new website is up, for students to have projects, as well as some of their custom blocks, on their accounts? I think it would be cool if users could showcase some of the cool custom blocks that they have made. For example, someone made this timer block, and then could have it show up on their profile, so other users can see how such a block is accomplished.

I think another cool idea is to allow users to create their own libraries of blocks. if one user really likes making time related blocks, like a timer, calendar, or anything else that is related, they could put all of these blocks into a library called "(username)'s time library", and then whenever they need those blocks for a project, they can just import it, and poof, they have all of those blocks.

brianharvey commented 10 years ago

On 5/8/14 4:29 PM, Kyle Hotchkiss wrote:

Would it be possible to, once the new website is up, for students to have projects, as well as some of their custom blocks, on their accounts?

Yes, certainly. It's the back end that needs improvement for this; right now you can only store projects, not libraries.

@Jens: Can a library include notes, like the project notes? Then we could have a more useful library browser.

xtitter commented 10 years ago
This is fun, sorry for highjacking this issue! With tender care, a good fraction of novice high school students can get basic HOFs - named functions gets passed as little machines to map and the like. I'd like to point out that I am a decided minority in the CS ed community for believing this! Anonymous functions that have magic state just hanging around that you've stuffed into a variable, next to the one you keep "3" in, that come out of a factory-like thing... I think most students would http://i.imgur.com/EMrknJP.gif
khotchkiss13 commented 10 years ago

@xtitter :+1: for the amazing gif!

jmoenig commented 10 years ago

libraries can include comments for blocks. No project notes or examples. But you can put as much example code as you want into the block editor for each block, and as many comments as you want. But it's not a cloud issue, just about adding a field to the file format. We don't need to change the cloud for this, since it's all a big serialized XML string anyway.

So, as an aside, I'm a little sad to notice that the original - somewhat modest - promise that Snap lets you "Build Your Own Blocks" in Scratch itself is increasingly turning into a rally cry for "Snap - There's A Block For That!", adding "... and here's a Google field to find it". I have not the slightest expertise about pedagogy, but it makes me nervous to shift the focus from "tell a story" to "go visit the library".

Sure, if you have powerful blocks out of some box just using them lets you experience a feeling of power, which might also convey please and joy for some. But I always feel that the higher you climb this intense feeling of "wow" decreases. Using just two fingers of your left hand to strum your very first e-minor chord on all six strings of a guitar is one of those beautiful, earth-shaking, life-changing things I remember well when I was a kid. Adding my first three-finger D-chord to that really propelled my imagination into outer space, because it let me accompany myself madly singing "Lady in Black" and set up a rock band with my friends. Plenty of hard things to learn followed after that, many of them rewarding, but none ever matched the magic of that first chord progression.

In part that's how I feel about building your own block. The transformative beauty lies in the first two steps, building a block, and building your own C-shaped control structure, or your first own MAP. If that doesn't change your life chances are what comes later won't either.

So, yeah, most music teachers I know feel that strumming e-minor and D-major in a guitar doesn't a musician make. And they're right. But believe it or not, I personally know at least two professional guitarist who can't do it, or won't even try because they feel that they're somehow above it. So they're asking me to play the guitar at their kids' party or their dad's funeral. But I know many more professional programmers who have never written recursive code or created a control structure. They're claiming they don't have to because there's an approved library for everything they'd ever need. And, of course, once you start thinking that way the next issues to worry about will be how to comply to "standards", "best practices" and APIs. None of that is bad in any way, and I bet most software is done that way today, just as most of Hans Zimmer's music comes out of his factory. It's right to point out, that re-using what's already there is a great way to accomplish something. But I also believe that letting kids ride a bicycle for themselves cannot be compensated by placing them behind a car's steering wheel first.

Just sayin' :)

brianharvey commented 10 years ago

Yeah, you're right, it's better if they make the blocks. Maybe we can figure out how to build a community expectation that you don't use a library until you've written it yourself. :-)

But the reason I asked about project notes is that they'd appear in a library browser before you've decided to open the library. Comments in the block definitions don't help until you've imported it.

I feel torn about the library business. The alleged reason why Berkeley fucked up the best computer science course ever was that Python has cool libraries. (Particularly galling since Scheme has cool libraries too, we just don't emphasize them in a course on fundamentals.) At their best, libraries encourage beginners to _read the code_ in the library. (As Alan Kay says, you can't have computer literacy until you have a literature for people to read and learn from. We should bug code.org to add code-reading to their emphasis on code-writing.)

jmoenig commented 10 years ago

Okay, so we should add some fields to libraries, such as notes, and maybe examples.

xtitter commented 10 years ago

@Jens very nice. "magic" is a nice place to focus; the formal classroom, while constrained in so many different ways, could do a much better job encouraging it.

jens commented 10 years ago

I think you meant to mention @jmoenig :-)

khotchkiss13 commented 10 years ago

I agree that we should encourage users to learn to make their own instead of rely on libraries. One of my favorite things about programming is that if I need to be able to do something, I (provided I have proficient knowledge of the task) can write a program to do it. If it turns out I need some smaller programs to complete different tasks, I can write those too. The great thing about libraries is that if someone also needed this same function and wrote it, I can use it too, which makes things easier on me. The not so great thing about this is it makes it so that I am thinking less about how that part works, I just assume that it does. I think a good practice in programming is to always write your own code whenever possible, so that you can make sure it works as you intend it to. If you need a library, you should look through it and decide whether you think it will be a good addition to your code. I agree with @brianharvey that the users should read be able to read the code that is in the libraries, or at least be able to see how it works, as it can allow them to get an idea of where to start.

studej commented 10 years ago

Close this? There is nothing to solve.