Lesson 1: The Need for Programming Languages

Overview

At the beginning of a new unit we jump right into an activity - building a small arrangement of LEGO® blocks and then creating text instructions a classmate could follow to construct the same arrangement. Groups will then trade instructions to see if they were clear enough to allow reconstruction of the original arrangement. The wrap-up discussion is used to highlight the inherent ambiguities of human language and call out the need for the creation of a programming language which leaves no room for interpretation.

Purpose

This is the first in a 3-lesson sequence in which we attempt to make connections between programming languages, the creative act of programming, and algorithms.

The main activity is a derivative of a classic strategy for beginning to learn about programming - writing precise instructions for another person to do just about anything - making a peanut butter and jelly sandwich, a simple line drawing, an arrangement of objects - is challenging. Human language is fraught with ambiguities and assumptions that machines (computers) simply cannot handle.

Thus, the first step we take is to establish the need for programming languages. Writing down a precise set of instructions to build a small lego structure, as we do in this lesson, is nearly impossible…unless you can agree on certain language constructs ahead of time, and how they will be interpreted. The main purpose of the lesson is to expose why programming languages are necessary, and how they come into being.

When you formalize language or commands that describe actions you are making a kind of code. This is also necessary for computers, which are simply machines that can perform a number of different tasks. In order to write instructions for them to do something you must agree on the “code” and each action must have a precise, unambiguous meaning. This is a programming language. Novices might think that a programming language looks like an archaic, impenetrable mass of abstract word groupings, but all programming languages are derived from the human need to concisely give instructions to a machine.

Agenda

Getting Started (2 mins)

Activity (25 mins)

Wrap Up (15 mins)

Assessment

Extended Learning

View on Code Studio

Objectives

Students will be able to:

  • Assess the clarity of a set of instructions expressed in human language.
  • Create a set of instructions in human language for building a simple LEGO block arrangement.
  • Identify connections between the ability to program and the ability to solve problems.
  • Describe the ambiguities inherent in human language and the ways programming languages seek to remove those ambiguities.

Preparation

  • Blocks for the class (~5 per team/student)
  • Paper for recording instructions

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the Students

Teaching Guide

Getting Started (2 mins)

Warm Goal

This is the beginning of a new unit. Set the tone that as a class we're embarking on a new adventure - programming - and get right into the activity. Ask students to dive into working on the problem, and assure them we'll explain things at the end.

Teaching Tip

Students may be eager to program, but recognize that the course is about "principles" of programming, and we want to establish some of the thinking habits that people who are "good" at programming seem to have "naturally." There is nothing natural about it - these ways of thinking, these insights, are learned and practiced. And this thinking capabilities start here.

Welcome to Unit 3!

Remarks

  • Welcome to Unit 3 - Introduction to Programming
  • This unit is an introduction to the principles of programming.
  • As you'll see one of the most important things you can do in programming starts well before you write any code. It's about how you think.
  • We're going to launch into an activity right now that reveals an important principle of programming.
  • Try your best, and we'll discuss at the end.

Activity (25 mins)

Distribute: Activity Guide - LEGO Instructions - Activity Guide (Non-LEGO Alternative: Building Blocks of Drawing - Activity Guide)

  • Students can record their instructions on a plain sheet of paper, poster paper, piece of construction paper, etc.

  • Students are encourged to work in groups of 2 or 3 (but can work alone)

  • Each group should be given 5-6 LEGO® blocks.

Teaching Tip

To make things interesting, strike a balance between all blocks being different colors and all blocks being the same. This forces students to be precise in identifying which block should be used in each step.

LEGO Instructions Activity

Below are the steps students are asked to complete in the activity guide.

Create a simple LEGO arrangement (and record it)

Groups should create an arrangement of their blocks in accordance with the following rules:

  • All pieces must be connected in a single arrangement.
  • Color matters: the final arrangement must be absolutely identical to the original.
  • Groups should record their arrangement by taking a picture or creating a simple drawing.

Write instructions for building your arrangement

On a separate sheet of paper, each group should write out a set of instructions, that another group could use to create the same arrangement. A couple of guidelines are below:

  • You may only use words when creating these instructions. In particular, you may not include your image or draw images of your own.
  • Try to make your instructions as clear as possible. Your classmates are about to use them!

Trade instructions and attempt to follow them

Groups should disassemble their arrangements, place their instructions next to the pieces, and hide their image or drawing of the arrangement somewhere it cannot be seen. Have groups move around the room to other groups’ instructions and try to follow them to build the desired arrangements. Have the original group check whether the solutions are correct or let groups check their solutions themselves by looking at the recorded image of the arrangement afterwards. Allow groups an opportunity to try a few of their classmates’ instructions before reconvening.

Wrap Up (15 mins)

Discussion Goal

  • Highlight the fact that ambiguity in human language led to issues or at least difficulty in creating the arrangements.
  • Motivate the need to create a well-defined set of commands that all parties can agree upon for expressing the steps of a task, or in other words, a programming language.

Discussion: Why is writing instructions hard?

Bring the class back together to reflect upon the following prompts or similar ones of your own creation. You may wish for students to record their answers in writing.

Prompts:

  • "Were you always able to create the intended arrangement? Were your instructions as clear as you thought?"

  • "Why do you think we are running into these miscommunications? Is it really the fault of your classmates or is something else going on?"

In the discussion of these prompts, ask students to mention instances where language was ambiguous or detail was not as great as students thought. Establish the fact that even when we are very careful, the very nature of human language means there is typically some room for interpretation. In day-to-day life that’s fine, but when expressing algorithms we need to do better.

Brainstorm: Transition the conversation to a more proactive response to the day’s activity. Ask students to brainstorm ways to overcome the ambiguity of human language.

Prompt:

  • If we were going to change human language to improve our odds of succeeding at this activity, what types of changes would we need to make?

Let students discuss at tables before again sharing with the class. Key ideas to bring out are:

  • So long as there are multiple ways to interpret language, we cannot have perfect precision.
  • If we rigorously define the meaning of each command we use, then we can avoid misinterpretation and confidently express algorithms.
  • This is different from the way we normally think and talk, and it might even take a while to get comfortable with communicating in this way.

Teaching Tips

Students may say things like “We could be really careful about our language” or “We could include more detail.” These are entirely true, but emphasize that if there’s room for interpretation then we can’t be certain about our results. Move towards the solution of creating a new language (a programming language!) in which we have strictly and precisely defined exactly what every word means. This is different from our normal human language, but necessary if we want perfect clarity in expressing instructions.

The Need for Programming Languages

Remarks

Today we saw how human language may not always be precise enough to express algorithms, even for something as simple as building a small LEGO arrangement. The improvements you have suggested actually create a new kind of language for expressing algorithms, which we as computer scientists call a programming language. In the coming unit we are going to learn a lot more about how we can use programming languages to express our ideas as algorithms, build new things, and solve problems.

Assessment

Prompts:

  • Consider the algorithm you designed for today’s activity. Identify two instances where there may be multiple ways to interpret your instructions and suggest improvements that could be made to improve their clarity.
  • Describe the features of a programming language that make it different from the language you are used to using in everyday life. Explain why a programming language must be created in this way.

Extended Learning

Ask students to rigorously define a small set of commands that could be used to build any arrangement of LEGO blocks. For example: “rotate”, “attach”, “detach”, “move”, etc. Feel free to let students select their own and then test out their new and more precise set of commands by repeating today’s activity using them.

  • Check Your Understanding
  • 2
  • 3
  • (click tabs to see student view)
View on Code Studio

Student Instructions

Consider the algorithm you designed for today’s activity. Identify two instances where there may be multiple ways to interpret your instructions and suggest improvements that could be made to improve their clarity.

View on Code Studio

Student Instructions

Describe the features of a programming language that make it different from the language you typically use in everyday life. Explain why a programming language must be created in this way.

  • Quick Check-In
  • 4
  • (click tabs to see student view)
View on Code Studio

Student Instructions

This level is an assessment or survey with multiple questions. To view this level click the "View on Code Studio" link.

Standards Alignment

View full course alignment

CSTA K-12 Computer Science Standards (2011)

CL - Collaboration
  • CL.L2:3 - Collaborate with peers, experts and others using collaborative practices such as pair programming, working in project teams and participating in-group active learning activities.
CPP - Computing Practice & Programming
  • CPP.L2:4 - Demonstrate an understanding of algorithms and their practical application.
  • CPP.L2:8 - Demonstrate dispositions amenable to open-ended problem solving and programming (e.g., comfort with complexity, persistence, brainstorming, adaptability, patience, propensity to tinker, creativity, accepting challenge).
CT - Computational Thinking
  • CT.L1:6-01 - Understand and use the basic steps in algorithmic problem-solving (e.g., problem statement and exploration, examination of sample instances, design, implementation and testing).
  • CT.L2:3 - Define an algorithm as a sequence of instructions that can be processed by a computer.

Computer Science Principles

4.1 - Algorithms are precise sequences of instructions for processes that can be executed by a computer and are implemented using programming languages.
4.1.2 - Express an algorithm in a language. [P5]
  • 4.1.2A - Languages for algorithms include natural language, pseudocode, and visual and textual programming languages.
  • 4.1.2B - Natural language and pseudocode describe algorithms so that humans can understand them.
  • 4.1.2C - Algorithms described in programming languages can be executed on a computer.
  • 4.1.2F - The language used to express an algorithm can affect characteristics such as clarity or readability but not whether an algorithmic solution exists.
  • 4.1.2I - Clarity and readability are important considerations when expressing an algorithm in a language.
5.2 - People write programs to execute algorithms.
5.2.1 - Explain how programs implement algorithms. [P3]
  • 5.2.1E - Program execution automates processes.

CSTA K-12 Computer Science Standards (2017)

AP - Algorithms & Programming
  • 2-AP-10 - Use flowcharts and/or pseudocode to address complex problems as algorithms.
  • 3A-AP-13 - Create prototypes that use algorithms to solve computational problems by leveraging prior student knowledge and personal interests.