AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Languages for robots

Week 26 · Unit 11: Autonomous robots · 3 lessons
1

Blocks or typed words

Computing 6: Unit 11, pp. 150–161
GoalCompare block-based and text-based programming languages and say when each one is a good choice.
New words
block-based language · a language in which a program is built by dragging blocks togethertext-based language · a language in which a program is written by typing codesyntax · the rules for how a text-based language must be writtenprogramming environment · the tool in which programs are written and run
Explanation

Humans give instructions to computers and robots with programs, and there are many programming languages. The two main kinds are block-based and text-based. In a block-based language, such as Scratch, we drag blocks and snap them together. We do not need to remember the commands or type them, and we can use a touchscreen. The blocks limit what we can do, so block languages are mostly used to learn. In a text-based language we type the program and save it as a text file. We must follow the syntax exactly. Text languages are more powerful, and professional programmers use them for big and advanced projects. Python is a popular example. Both kinds use the same ideas: sequence, selection, loops and variables.

FeatureBlock-basedText-based
how we writedrag and drop blockstype the code
syntax to remembernoyes
touchscreenworks wellhard to use
powerlimited to the blockscan do much more
mostly used forlearning to programadvanced and professional work
Worked examples
whenclickedsayHello!for1secondsrepeat3
Here is a block program that says Hello! three times. The loop repeats the say block, so we do not need to write it three times.
Python
1for i in range(3):
2    print("Hello!")
Output
Hello!
Hello!
Hello!
This is the same idea in a text-based language. The word for starts the loop. The words print and the quotation marks follow the syntax of the language. The computer prints three lines.
SituationBetter choiceWhy
a first project on a school tabletblock-basedno typing, and it works with touch
a team building a large websitetext-basedmore powerful and more flexible
a quick game to test an ideablock-basedfast to build and change
a program with thousands of linestext-basedeasier to organise and share as files
Different people have different needs, so the best language is the one that suits the job and the person.
Class activity

Language swap (no computer): act as a robot with two ways of receiving instructions. Way 1, blocks: a friend gives you cards with ‘step forward’, ‘turn right’ and ‘repeat 3’ on them and arranges them on the floor. Way 2, typing: the friend must write each command by hand in capital letters on one line, for example FORWARD 2, and you refuse any line with a spelling mistake. Which way was faster? Which way made more mistakes? Which would you give to a 6-year-old? If you have a computer or tablet, look at a block program and a text program side by side with an adult.

Practice
1
Look at the two programs in examples 1 and 2. Name two things that are the same and two things that are different.
2
Choose the better type of language for each job and say why. (a) A child who cannot type yet builds a story. (b) A company builds a banking system.
(a) a child who cannot type yet(b) a banking system
3
What does syntax mean?
4
Which column of the table describes Scratch, and which describes Python?
FeatureAB
we type the codeyesno
we drag blocksnoyes
has strict syntaxyesno