Skip to Content

What a Seasoned Professional has to Learn from Scratch

« Reflections
14 replies [Last post]
Toby Farley
Member

Todays modern programming platforms generally hand you the world on a silver platter. Typically all you have to do is peice all the right components together logically to create a solution to a problem.

When creating complex solutions in Scratch, I have had to create my own data structures.

Examples:

  • Using a one dimensional list like a two dimensional list to create a matrix
  • Using a list as a stack to store and idententies and locations of sprites which are shooting in a game
  • Using variables to store a unique identifiers so that a sprit can be identifed and dynamic messages can be created to manipulate a groups of sprites
  • Using list to store a ID's of active and inacvtive sprites

Working in Scratch also demonstrates the difficulties in working with and syncronizing multiple threads of execution and the issues involved with variable access from multiple threads of execution.

The limited (while at the same time powerful) nature of Scratch forces one to examine the solution to a problem in fine detail and to create many things from scratch (no pun intended). For the first time in years I have found myself programming for pleasure. It is the challenge of finding solutions to complex problems and being able to examine the solutions that others have created in solving similar problems, that make working in Scratch so enjoyable.

I am looking forward to a workshop that I am giving to GT students on April 24th, 2010 and hope that at least one of my students gets the programming bug after their experience in my workshop. I have pushed Scratch and my own skills to the limit to prepare myself to be able to answer all of their questions accurately and intellegently.

Replies
Bruce Cichowlas
Member

Passing parameters (sometimes called arguments):  In mathematics, this would resemble in many ways a function call.  I'll try to do a Scratch-like example:

 

Let's say we had a project with some fish in an aquarium and we wanted to tell them to change their color.  In Scratch now, we could make up broadcast messages such as "Fish turn green", "Fish turn red", "Fish turn blue", etc.  We'd have a different broadcast message for each color.  If there were lots of colors that we wanted to have the fish become, we'd have a lot of messages.  And if there was a situation where we couldn't anticipate what color we wanted for the fish, we'd be in trouble because we can't just define a new broadcast message "on the fly".

 

But both of these problems would go away if we could attach "parameters" to a broadcast message.  I'm inventing syntax here, but for instance perhaps Scratch could let us say: Broadcast "Fish change color" with "green" or Broadcast "Fish change color" with "blue".  or even better Broadcast "Fish change color" with "Variable: Favorite Color".  Then we need only one broadcast message and we are able to create variations of the same message by using parameters.

 

Now you can simulate this to a large degree now by having a variable that hold the new fish color and making the broadcast message say:  "Fish, look at the new fish color now".  That has much the same effect, but it is a two step process and in some ways is harder to follow in the code.

 

Creating objects "on the fly":  Let's say that we made a project where we asked the player "How many lightning bugs would you like to see flying around randomly?".  They'd say some number and then what would we do?  Well, if we had made enough lighting bug sprites to match their largest possible number, we could just "show" the appropriate number and "hide" the others.  But that is sort of a pain because we have to make a large number of sprites and set up a script for each one.  It would be much easier if we could just say, in effect, "Clone a new lighting bug sprite just like (the original Sprite name goes here)."  In object-oriented programming, we would call this an "instance" of the "lightning bug sprite object".  So now the number of sprites that we have on the screen is no longer limited to the number that we define before running our project.

Toby Farley
Member

From what I've read, cloning was intentionally left out due to either the intentional or unintentional create of a Sorcerer's Apprentice project that create a large number of sprites and the side effect being using up all availiable ram.

Bruce Cichowlas
Member

I do lots and lots and lots of JavaScript at my "real" job.  I also do quite a bit of Java and C#, too.

 

Java and C# are enough alike that if you write Java code with a "C"-like syntax, it will probably become C#, more or less.  (Sure, I'm skipping over some differences such as delegates and anonymous functions, etc.)

 

Javascript (more properly ECMAScript these days) is very different in practice than either of those.  It's more interpretive and less strongly-typed.  Javascript is easy to write and hard to debug, which I think is the opposite of what beginners need (and even often us pros, I think).  In my opinion, there aren't any really effective debuggers for Javascript.  The closest ones are Firebug and MyEclipse, but it is still not like the relevant, right-on-top-of-it, debugging of Visual Studio for C# and Visual Basic or Eclipse for Java.

 

I'm sure there are several interesting environments around like Scala and the ones you mention that I haven't really checked out.  But if you want to have fun learning programming with an accepted "professional" langauge, I think one viable possibility is to use Microsoft's C#/XNA.  It's free and you can even run your code on the XBox (with XBox membership cost).  There's even a community.  Tutorials abound.  Just Google a phrase like:  C# XNA tutorial .  Some are for those with experience.  Some video tutorials are for beginners and most are oriented around making games.  And if you don't like being in the Microsoft world, remember that nearly all of your C# skills transfer very well to Java.  That said, C#/XNA is an adventure more for an interested high-schooler than the casual 2nd-5th grade Scratchers that I teach.

 

Regarding an earlier discussion, I personally don't worry much about whether one learns recursion, but I think that object-oriented programming is an important concept.  Some of that comes through in Scratch, partly from its SmallTalk heritage.  I miss things like creating objects on the fly more than I miss recursion.  I even miss such niceties as passing parameters or being able to direct a "broadcast" to a more specific audience of listeners.  I think that these latter two features, though, could be added to Scratch in an optional, structured way that would not hurt the simplicity and clarity of Scratch as we know it.

Karen Randall
Member

Help me understand more of the programming concepts you mention:

What are passing parameters, and how is "creating an object on the fly" different than programming a sprite?

Toby Farley
Member

Parameters are a fairly fundamental facility in almost all computer languages. An example of a parameter is the values that a block takes to decribe what it does, like turn <n> degrees (<n> being a parameter). It would be nice to be able to send parameters in messages broadcasts or by some other facility.

 

Creating an object on the fly would be defining say "Sprite 1" and then having blocks in the program that says make me another sprite just like "Sprite 1". This would create a new sprite that acts just like the old sprite but is an entirely new sprite.  Unfortunately this would open up a Sorcerer's Apprentice situation where a large number of sprites could be created which would crash the Java Applet  and comsume a large amount of availiable ram.

Toby Farley
Member

 I agree that in naming missing elements that are missing from Scratch, recursion is probably a poor choice. That being said. BYOB is really cool.  It definitely addresses additional computing concepts without adding a huge number of new language elements. They have a "video" that demonstrates what BYOB 3 does and it is well worth a look. Even if these elements never make it into the official Scratch, BYOB is still there.The only real drawback is students lose the ability to publish to the web.

 

I totally agree that Scratch is a real programming environment. I have not had this much fun creating software in years ! Now if I could only figure out a way to make a living teaching Scratch to students or educators, I'd be set !

John Maloney
Member

To add to Toby's list, I'd suggest looking at Greenfoot. It's a Java programming environment that provides a framework with a stage and sprites ("actors") so you can quickly build interactive games or stories like those can build in Scratch. But the code is real Java -- complex syntax and all -- and you can use all the Java API's.

 

Another cool language is JavaScript. It's interactive, fairly simple, and it's built into most browsers. I haven't looked for any step-by-step tutorials, but I'm sure they must exist.

 

By the way, Scratch *is* programming. While Scratch doesn't require that you master the syntax of a text-based programming language, the program logic is exactly the same as C, Java, Python. In fact, Scratch is used in courses at Harvard, The College of New Jersey, and elsewhere as an introduction to those languages. From all reports, Scratch works very well in these courses because its constructs *are* so similar to other languages.

-- John

 

Bruce Cichowlas
Member

On the subject of other learning environments, I've recently heard about Scala ( http://www.scala-lang.org/ ), but I don't know much about it.

 

Regarding the need to use Scratch in ingenious ways to simulate features that are available in some other computer programming systems, yes, that is a fact.  However, to include most of these features on a par with other Scratch features would, I think, be giving beginners to much to worry about and sort through.  Perhaps some of these could be present, but if so, I think it is really important that the complexity introduced be carefully structured such that the environment offered to Scratch beginners remains easy, natural and fairly complete.

 

One of the things that Scratch encourages is combining efforts.  Yet with the features within Scratch, it can be hard to just throw projects together and have something that works and is understandable.  The skill and perception required to combine projects can be much higher than that required to write the individual projects.  Perhaps there are some clever integration techniques that could be added, since community projects seems to be an important aspect of the Scratch message.

Toby Farley
Member

What I really wish Scratch had is the features in the BYOB 2 version of Scratch www.chirp.scratchr.org/blog/ or better yet the features of  BYOB 3 byob.berkeley.edu/. I think with the features availiable in BYOB the jump to higher languages would be easier and could be delayed because there would enough there to teach some of the higher concepts of computing (like recursion). I really, really like Scratch but I think some of the emphasis areas in 2.0 are off the mark. I don't think we need connectivity to Facebook and Twitter (egads !), I think we need a slight improved environment to teach CS concepts. But then being a computer scientist, I am a little biased.

 

Toby Farley
Member

On Saturday April 24, 2010 I gave a short (3 hr) Scratch workshop to GT students in Grand Junction, CO. Unfortunately, due to the short notice give out about the class, I only had two students plus my own daughter. After delivering my first Scratch workshop I noted serveral items about the students experience in the class.

  • Scratch seemed natural to them. They immediately had a graps on dragging the language elements into a script. Occasionally we had an bug which we all had fun trying to track down due to placement of a language element in the wrong location. Sometimes with quite humorous results.
  • I had to double my time alotted to looking at the Scratch website because the students wanted to see as much as possible of what was out there. We did not have time to see all 1,000,000 projects :-)
  • Both or my students indicated that they would continue using with Scratch at home.

We used scratch to build an aquarium simulator in a somewhat guided fashion and then the students were let go to either create their own project or remix another project from the Scratch website. The topics covered were.

  • The Scratch interface
  • Creating and loading sprites
  • Changing the background
  • When <green flag> clicked
  • forever loops
  • if and if else
  • touching <edge>
  • touching <sprite>
  • random 1 to 2
  • move <x> steps
  • turn <x> degrees
  • say <somthing> for 2 seconds
  • play sound until done
  • change y by <x>
  • publishing to the Scratch website

It was not possible in the time alotted to work with variables and messages although messaging was demonstrated and variables discussed at a high level. The students were given a three ring binder with the Scratch manual and the Scratch cards in hope of giving them enough tools to continue their exploration. I am currently looking within my school district for opportunities to either teach Scratch to other students over an extended period of time or to educators in a workshop setting.

Toby Farley
Member

  

Ai Boon Tan
Member

Dear Toby,

I wish you success in your coming workshop.  May I find out from you what the next step should be for a student of Scratch who wants to move on to programming? If a student were to tell me that he or she  would like to learn to write code, what should I suggest to him or her? 

I am teaching young Scratchers (ages 8 -11) and beyond what I know of Scratch, I have very little knowledge of computer programming.

Any advice from you and other Scratchers will be very welcome. Thank you.

 

Best regards,

Ai Boon

Toby Farley
Member

I've thought long and hard about this question and I find easy answers hard to come by. I personally am biased towards a number of computer languages and I think if you asked a truely random sample of people the same question you would get a number of different answers. Here are some of my picks.

 

Squeak - www.squeak.org/ - Smalltalk is one of the earliest of the OO family and it's what Scratch was created with

 

Ruby - www.ruby-lang.org/en/ - Newer OO languages. Not created in a lab.

 

Python - www.python.org

 

And then the politically incorrect choice that I prefer.

 

VB.NET - www.microsoft.com/express/Default.aspx - VB Express is free. Easy and Powerful but quite proprietary and Windows only

 

Some people may notice a lack of languages with { } (C, C++, Java, C#) because some of them are truly flawed (C, C++)  and the others I just don't like. I am bracist.

 

Many people would recommend Java and it would probably be a good choice as well. java.sun.com/

Ai Boon Tan
Member

Thank you very much for your suggestions.  I have printed them out and will certainly look into them. Your help is truly appreciated. : )