Episode 1 : Starting From Scratch

Episode 1 : Starting From Scratch

CS50 Week 0: Scratch

I love puns. The person at MIT (Massachusetts Institute of Technology) who named the language 'Scratch' deserves a medal. In a minute you'll see why 'Starting from Scratch' is a perfect title but before that, let me introduce my less technical readers to one of the key principles taught in week 0's lecture:

Binary

You have probably heard it said that computers can only understand zeros (0) and ones (1), right? A computer's processor is made up of billions of transistors which are tiny switches activated by electronic signals. The digits 1 and 0 represent the on/off states of the transistor.

David J. Malan teaches that computer science can essentially be represented as follows:

input_output.png

When you write a computer program, you are simply giving the computer a set of instructions in the middle box on how to solve a particular problem and return meaningful output. It doesn't matter what language you use to give the instructions, in the end, it will have to be converted to binary instructions that the computer can understand and execute.

Binary numbers are expressed in base-2 as opposed to base-10 that we are more accustomed to in the decimal system. We don't even realize it, but when you see a number like 255, your brain instinctively goes back to lower primary math where you learned about place values. 2 is in the hundreds (2 x 100 = 200), 5 is in the tens (5 x 10 = 50) and 5 is in the ones (5 x 1 = 5) so the total value of the number is 255. 'Ones', 'tens', 'hundreds'; their values are based on the number 10 being raised to an increasing power. The table below should refresh your memory:

whole-numbers.png

Binary works in the same way, only that the base number is 2 instead of 10. Makes sense? See if you can better understand it from this illustration:

Binary Picture.png

Everything on a computer (data) is represented as a series of binary numbers. These numbers are encoded in different data formats to give them meaning, e.g the 8-bit pattern 01000001 could be the number 65, the character 'A', or a colour in an image depending on the context.

Capiche? Good

Scratch

Week 0's problem set was to implement your own Scratch project. Scratch is a coding language with a friendly user interface where you can create games, stories or animations by stacking little blocks of code together. It was developed by MIT and is apparently designed for kids between the ages of 8 and 16 but is useful for people of all ages.

Scratch takes away all the complexities of syntax and allows you to learn how to think like a programmer, how to code if you like. It's very easy to use and you will have lots of fun making the projects. If you have never written a line of computer code in your life before, why don't you head out to scratch.mit.edu on your PC where you can get inspiration from other people's projects as you try your own. Your coding journey can start from scratch.

Mitch Resnick, one of the makers of scratch says:

When you learn to read, you can then read to learn. It's the same thing with coding. If you learn to code, you can then code to learn...

Beyond being a form of literacy in the world today, one of the great benefits of learning to code is understanding the process of design; to start with a simple idea and build up on it or how to take a complex idea and break it down to smaller steps.

(# A friend told me that Scratch was introduced as part of the new competence based curriculum in Kenya? That's definitely a plus)

To end this article, let me paste a link to the simple game I made for my problem set submission: scratch.mit.edu/projects/660856945 Use the arrow keys to move the dragon up and down to avoid being hit by the asteroids. If you can survive for 12 seconds, you successfully save the dragons from extinction and help them get to the 21st century!

Best of Luck!