Scratch & Python Comparison

We get lots of questions around the merits of using Scratch vs. going straight into Python. At Code Ninja, our curriculum has 5 levels of which, the first 3 focus on teaching the fundamentals of coding using Scratch, a block base coding language. 

This article outlines the benefits of starting new learners on block based coding languages like Scratch to accelerate their learning journey and interest. Please reach out for questions. Enjoy!


Block-base coding

Block-based programming environments such as Scratch, micro:bit, and Lego Mindstorms & WeDo have become popular as introductory tools for learning coding. Block-based coding platforms are very popular among children ages 8 to 16, partly because they offer a programming language that is less intimidating than a text-based language such as Javascript or Python. 

Block-based coding involves dragging-and-dropping “blocks” of code to form valid and meaningful instructions to bring about the desired outcomes. These blocks differ in shape and colour to provide cues about how instructions can be assembled and to differentiate between types of blocks and programming concepts. They can be likened to jigsaw puzzles or lego blocks that can be assembled in certain rules-specific ways to create a program.

A Scratch block that generates the first 100 Fibonacci numbers.

A Python code that calculates the first 100 Fibonacci numbers.

Obstacles faced by new coders

It is widely acknowledged that programming is difficult to learn. New learners often have difficulty in basic programming tasks such as predicting the output of code, identifying the correct order of commands, and breaking down a series of instructions to carry out a task. 

Many of these tasks are challenging for new learners because:

  1. the learners are required to think about solutions in a way that is not natural to them.

  2. to write a simple program, they are required to understand both the syntax and logic of a programming language. 

  3. introductory programming tasks often fail to connect with the interests of students and are perceived to be “boring”.

 

Coding Syntax

In programming, syntax refers to the rules that specify the correct combined sequence of symbols and letters that allows a programming language to give instructions to computers. Computers, being the inflexible machines that they are, understand what you want, only if you type it in the exact form that the computer expects. That form is the syntax.

image of a page of computer syntax

Learning to program with a text-based language can be quite frustrating and requires a lot of attention to details. Programming languages are very unforgiving on simple mistakes, and there is an overwhelming amount of syntax that can go wrong: opening/- closing brackets, upper/lower case letters, semicolons, and also spelling. A tiny dot or a space character (or the lack of one) in the wrong place, will cause your program to completely break down.

 

Most English speakers can look past a few syntax errors, and can enjoy the poetry of e. e. cummings without problems.

i carry your heart with me(i carry it in

my heart)i am never without it(anywhere

i go you go,my dear;and whatever is done

by only me is your doing,my darling)

                                                      i fear

no fate(for you are my fate,my sweet)i want

no world(for beautiful you are my world,my true)

and it’s you are whatever a moon has always meant

and whatever a sun will always sing is you
— from “[i carry your heart with me(i carry it in]”
Cummings' work is associated with modernist free-form poetry with a particular idiosyncrasy of syntax.

Cummings' work is associated with modernist free-form poetry with a particular idiosyncrasy of syntax.

 

Most text-based programming languages are not so forgiving. If there is a single syntax error anywhere in your program, you will not be able to complete the execution of your program. You can expect to spend a lot of your coding career tracking down syntax errors.

Chang.jpg

For example there are at least three syntax errors in the code on the left.

Name = input("What is your name? ")
age = input("What is your age? ")
print "Hello, " + name +  " + age)
name = input("What is your name? ")
age = input("What is your age? ")
print("Hello, " + forename + " " + age)
 

Novices can spend the first few weeks or even months hunting down a stray semicolon or a double space, instead of focusing on solving computational problems and developing higher thinking skills. This often results in lost interest and the conclusion that coding is “boring”.

A major advantage of block-based coding environments is the elimination of syntax errors. The drag-and-drop interface allows for blocks of code to be placed on the screen to form syntactically correct programs, without the use of typing. If two blocks cannot be joined to produce a valid statement, then the environment prevents them from snapping together. 

In these ways, block-based programming can prevent syntax errors while still retaining the practice of designing programs by assembling statements one-by-one.

Novices are able to focus on the core concepts in computer science such as program control, conditionals and loops, without the frustration of correcting syntax error.

 

Lower Barrier of Entry

Writing a program in such a Block-based coding environment takes the form of dragging-and-dropping programming instructions which snaps together. Scratch uses its block-like structure, with different colour and shape, and a simplified “natural” language to provide cues about what blocks can be connected to form a syntactically correct program. For example, blocks that accept Boolean values are hexagonal shaped, while blocks that accept numerical values are oval shaped. Control structures are C-shaped to indicate that other blocks can be placed inside of them. The visual layout allows novices to see the order and flow of a program clearly.

Different colours and shapes help differentiate the different types of coding blocks in Scratch.

Different colours and shapes help differentiate the different types of coding blocks in Scratch.

Such Block-based programming environments have been designed for children as young as five years old but although most environments are designed for learners ages 8 to 16. 

 

Encourages experimentation and creativity

Scratch was designed to create video games and stories. In short, students will enjoy making the projects as well as playing them. Users can use their own images, music and voice recordings. It is a networked, media-rich programming environment which fosters creative and personalised projects. 

Compared to text-based coding platforms, where novices are stuck with making text-based programs, because at the start, they are the most achievable type of programs to create. It is usually really hard to create nice animations and graphics using text-based languages. In some cases, it requires some advanced mathematical concepts.

Moreover, Scratch encourages users to be social by allowing users to share their projects with the community and build on the projects of others. They can also receive feedback and thanks on their projects from other programmers. This creates additional motivation to work on and complete a project.

image1.jpg
image5.png
 

Advantages of Block-based languages

In summary, the benefits of block-based coding and why it’s a good tool for new learners: 

  1. Low frustration – With block-based coding, there’s a lack of syntax errors that come with text-based programming.

  2. Experimentation and learning – the low barrier of block-based coding makes it easy for novices to experiment and try out unique solutions. 

  3. Interest - The environments encourage novice programmers by allowing them to create personalised media-rich games and projects that are related to their own interests. 

With all its colour and blocks, it is easy to assume that Scratch is “easy” and for kids. That couldn't be further away from the truth! Scratch can be used to do a lot of really hard and really complex programs. It is a very real programming language and it’s a great way to get a firm foundation in programming without having to worry about debugging every single line of code. In fact, it’s how many major universities, like Harvard and Berkeley, teach coding in their Intro to Computer Science classes.

TLDR: Why Top Universities Teach Drag and Drop Programming?