Saturday 9 February 2013

Scratch - A great programming environment

Scratch is a programming language/environment which was developed in 2006 at the MIT Media Lab.

It was designed to help kids to learn to program by allowing them to get results fast. It supports "Sprites" and when you launch the program it starts with this sprite already loaded:

In Scratch you don't write code by typing it in. Instead you drag "blocks" from the "Block palette" into the "Script area" and you join them with other blocks.

Here are some very simple examples of how easy it is to get your sprite to do something. The one on the left is the classic "Hello World". The one on the right will simply move your sprite to the right. Both are triggered by clicking on the sprite:

The great things about Scratch in my opinion are:
  • It is easy to create and manipulate sprites, and to respond to events
  • Because you are dragging in code blocks, you can't really make syntax errors (although you can still have bugs of course!)
  • It is easy to integrate sound (audio files, drums, and other instruments)
  • The development environment is very good
  • You can get results quickly
  • It's fun!

But that's not all. The third item in the drop-down menu (after File and Edit) is "Share". Scratch is designed to allow you to share your projects with other people and to run the programs which they have written. You can search for other programs and you can even run them directly on the web page (thanks to Flash and Java players). And if you see a program that you think you could learn something from, then you can download it and see how it works. And you are free to enhance the program which you have downloaded and to upload your own version. Genius!

Scratch can be used to create interactive stories, animations, games, music, and art. You can do simple things with it, and you can also do complex things. Here are links to some classic games written in Scratch which you can run directly from the web page with no download:
Pacman
Space Invaders
Asteroids

To finish up this posting, here's a little piece of code which should make sense even if you don't know Scratch: