Michael Littman is University Professor of Computer Science at Brown University and Division Director of Information and Intelligent Systems at the National Science Foundation. Littman is a Fellow of both the Association for the Advancement of Artificial Intelligence and the Association for Computing Machinery. He was selected by the American Association for the Advancement of Science as a Leadership Fellow for public engagement with science in Artificial Intelligence.
Below, Michael shares five key insights from his new book, Code to Joy: Why Everyone Should Learn a Little Programming, Listen to the audio version read by Michael himself in the Next Big Idea app.
1. There are only a few types of bricks.
One amazing fact about computers is that they are “universal.” A single box of circuits can serve as a calculator, camera, phone, TV, book and tool for creating equations, pictures, sounds, animations and text. How do they do that? Programmability. The main job a computer does is to follow the instructions you give it that tell it what task to perform. Very meta.
You usually give instructions to the computer by pointing it at instructions written by someone else. This is what you are doing when you download software and then click on it to run it. But computers give you much finer control than that. You can write specific instructions yourself. Given that computers can do practically anything, it seems like you’d have to learn a lot of instructions. But there are really only a handful. Just like a LEGO™ Master Model Builder can build anything using a small set of bricks, you only need a few programming concepts to create simple or complex programs.
The building blocks are commands, conditionals, variables, loops, and functions. Each is important because each is useful and powerful in its own right. But the real superpower comes when you learn how to combine these units in creative ways. By learning about each of these pieces individually, you have a great foundation to build on.
2. You’re already drowning in it.
The building blocks are sufficient to compose any written program and express any imaginable function. So, you would think they would be pretty high-tech. But, the truth is that we use these ideas all the time. They entered human culture long before the invention of computers. When you’re telling a computer what to do, it’s not so different from how you might explain to another person how to accomplish a particular task.
Orders are simply individual steps that can be linked together into a sequence. You see this idea in a movie script, which is a sequence of lines to read; Or a piece of piano music, which is a sequence of notes to play.
“When you’re telling a computer what to do, it’s not much different from how you might explain to another person how to accomplish a particular task.”
There are conditional branch points that specify when it is appropriate to follow particular orders. We often convey this idea to each other using the word “if.” For example, Homeland Security emphasizes: “If you see something, say something.” Tony Orlando sang: “Knock three times on the roof if you want me.” And Winston, in Ghost BustersSaid: “When someone asks you if you are God, you say yes!”
Variables are stand-ins for other values. but coming back Ghost Busters Quote, the word “any” is playing the role of a variable. This may be useful to anyone who asks you questions. In the film, it was Gozar the Gozerian. But the instructions say that no matter who asks the question, the same treatment should be given. Words act as variables all the time. If I challenge you to a contest and say, “The winner takes all,” what does “winner” mean? Of course, the one who wins wins. So, “winner” stands for that person and is therefore acting like a variable.
Loops ask us to follow the same set of instructions multiple times. “Drop it and give me twenty!” “Drop”, “do a pushup”, “do a pushup”, “do a pushup”, “do a pushup” is a short way of saying. The word “twenty” acts as a loop statement that tells us to repeat the underlying activity twenty times.
Functions provide a way to pack a set of instructions and give them a name for later reference. I remember bringing my kids to Chuck E. Cheese for a birthday party. Chuck E. would say, “When I say happy, you say ‘Birthday.’ happy Happy….” After every “Happy” he wishes us “Birthday!” Would pause to give him a chance to shout. Here, “happy” is acting as a function, asking us to shout “Birthday.” If functions sound a bit like variables, that’s because they are. They are essentially variables that represent instructions.
3. You can start today itself.
Given that the basic programming blocks are already familiar, there’s nothing stopping you from trying them out. Of course, writing large complex programs requires a lot of practice, but there are plenty of examples of simple systems that let you do practical things almost instantly with just one programming building block at a time. Using blocks in concert is a superpower that will significantly increase your abilities.
Creating online questionnaires, and defining keyboard macros in the Emacs text editor can help you practice sequencing commands.
Trigger-action programming using the interactive fiction authoring tool Twine and if-this-then-that or Alexa routines are good ways to get comfortable thinking about breaking down into different behaviors using conditionals.
“Using blocks in concert is a superpower that will significantly increase your abilities.”
Defining formulas in a spreadsheet or creating your own BuzzFeed quizzes provides the opportunity to store information in variables.
Google Calendar, Apple Calendar, Yahoo! Experimenting with repeating calendar events in! Designing your own video games with Calendar, and its like, or low-code online tools gives you an on-ramp to integrating instructions into loops.
Finally, the grouping functionality can reveal the value of defined actions in building programs and creating new behaviors in Google Apps Script.
4. AI is a brick maker.
There is a saying that says: A mediocre teacher tells. A good teacher explains. Shows the best teacher. Great teachers inspire.
These four verbs—tell, explain, demonstrate, and motivate—represent well the four major methods we have for delivering tasks to computers. “Telling” corresponds to coding, with ideas like loops and variables mentioned earlier. But the other three are all forms of machine learning that are making great strides in artificial intelligence and promise to expand the ability of all people to make computers more powerful and useful for themselves.
The idea of explaining involves telling the computer what its purpose is rather than the specific steps required to accomplish that purpose. They essentially help people create loops to solve a task. This type of machine learning is known as “reinforcement learning” because it typically involves setting rewards and punishments for the machine and letting it behave accordingly. Sophisticated programs for playing board games and video games use this idea, as do some business applications that keep data centers cool while minimizing power and maximizing throughput. They’re also trading stocks and optimizing supply chains, problems where it’s easier for people to explain what success looks like, rather than specific steps to achieve it.
“These four verbs—tell, explain, demonstrate, and inspire—map well onto the four major ways we have for delivering tasks to computers.”
Performance also plays an important role in modern computer systems. The branch of machine learning, known as “supervised learning”, produces high-performance software, for example. Programs that decode speech and translate between languages are now routinely created by giving the computer vast collections of inputs and their corresponding outputs. Supervised machine learning approaches create sequences of instructions to make this happen. One type of supervised learning solves problems by generating a collection of conditional branches known as a “decision tree”. Another intermediate organizes the calculations into values of a set of variables known as a “neural network”. These variables themselves can be organized into units analogous to the function definitions.
It is much less common to tell a machine what to do through “stimulation”, but several important applications of this idea are emerging. A recent example is that of preparing driving directions. It is difficult to tell the computer which route to take for each possible location and destination. It’s even harder to explain what the purpose is—most people prefer shorter routes, but they’ll sometimes go a little further if a route has fewer turns. How much less? I don’t know. You can display routes for computers, but how do they generalize to new or rare place-destination pairs? Engineers are starting to use a combination of demonstration and interpretation: basically, use the demonstration of routes that people choose to derive a rule that explains why they chose those routes relative to other possibilities. Once the computer figures out that rule, it can apply the learned interpretation to new routes. I consider it inspiration because our examples serve as a source for the machine to do new and exciting things.
5. Mashups are the way to go.
Chatbots are great and they can even help us program them. But at the end of the day, it’s still up to us to understand what we want the machine to do and convey that message. The programming of the future may be much easier, but it will still involve the same skills we use today. We already use these skills when dealing with other people, so this is a good start. But actively developing these skills will remain necessary, perhaps even more so, in the age of AI.
Machine learning has made it easier for people to tell machines what to do. But, generally, systems work by telling, explaining, demonstrating, or motivating. In contrast, when we ask other people to do something for us, we typically describe the task using these ideas, especially a combination of description and examples. This is because descriptions can be abstract and vague without examples. And examples without details leave you guessing the intent. Both are error prone.
For example, Carl Sagan said, “The nitrogen in our DNA, the calcium in our teeth, the iron in our blood, the carbon in our apple pie were made in the interiors of collapsing stars. We are made of starstuff.
They told us we were made of starstuff. But he also gave some examples to make sure we understood exactly what he was saying. Similarly, the combination of rules and examples will be game-changing in terms of telling machines what we want them to do. Making it easy and reliable to guide computers to carry out our desires is where we really see AI reach its full potential.
I hope you will be inspired to use computers more thoughtfully and with a sense of self-efficacy and empowerment. After all, computers are machines to which we can submit our will. Surrendering our will sounds pretty profound, and I think Carl Sagan would be proud.
To hear the audio version read by author Michael Littman, download the Next Big Idea app today: