You will learn the definition of computer programming, how it is written, and the basic structure common to most computer languages. In this video in Developer and Programming Foundations, instructor Simon Allardice answers, "What is Programming?" and how computer code is understood by the computer.
- View Offline
So what exactly is programming? Well, you may have heard a phrase like this before. A computer program is a set of instructions. Here is the problem. This sounds like one of those phrases that might be technically true and is kind of useless, like the human brain is 80% water. Because you hear this phrase but then you see a complex program like Photoshop or Flash or something playing high-definition video or a 3D game and you think, "Yeah but that can't just be a set of instructions." But that's exactly what these are, all of them.
Every computer program is a series of instructions. A sequence of separate small commands, one after the other. Now there maybe five instructions contained in a program, maybe 5,000, maybe 5 million. Each instruction is telling the computer to do something very small, but very specific and the art of programming is to take a larger idea and break it apart into these individual steps. And the wonderful thing is everyone can already do this. Let's imagine that you're sitting in your house in the suburbs waiting for a visit from a friend.
Your phone rings, it's her, and she's asking for directions. She tells you she's at a nearby gas station and you know it. You pass it everyday, it's on your way home. So that journey point A to point B drops into your head as one piece, but you instantly know you can't communicate the journey the way you understand it. You have to break it down into simpler parts and you have to think about it to break it down because it's so natural to you. So you start to pull this apart and "You say you are going to need to turn right, then drive one mile, then you will turn left on Acacia Avenue, then you'll take the second right and then it's the fourth house on the left." Specific, individual, simple, clear, self-contained instructions.
Now you know that sequence here is vitally important. You mix these up, you will get very different results. "Turn right, drive 1 mile" takes you to quite a different place from "drive 1 mile, turn right." But this same level of simple instructions, turn right, turn left, go straight, could take you around the corner or it could take you on a five-year trip around the world visiting every Starbucks along the way. You'd still have instructions like turn right and left.
You'd just need a lot more of them. So with programming we are giving directions to the computer. It's breaking apart a more complex idea, a more complex task, into its smallest individual instructions and then using a programming language to write those instructions. Now, of course if you have never programmed, it's not clear right now what those instructions might be. You know it's probably not turn right and turn left. So what are those basic fundamental instruction you give a computer? Well, they are often very basic. They are things like add two numbers together, or display a letter on the screen, check to see if the user just hit the spacebar, change the color of one individual pixel. But as with driving directions, you string together enough computer instructions that will get you very far indeed.
So when it might seem difficult to see how you get from basic examples you see when beginning programming to complex games or applications, well that's what you get when you have a hundred people writing these instructions for sixty hours a week for several years, combined with the ability of the computer to process them mind-bogglingly fast, means that we could, if we wanted to, write the set of instructions that could calculate every single individual pixel on the screen thirty times a second.
Now think about that level of speed and think about why your instructions better be right. Because getting them wrong is like giving wrong directions to your friend when her car only has two speeds: 0 and 5000 miles an hour. You get those directions wrong, and the next call you get is her asking why she followed your instructions to the letter, but her car is now in the middle of a forest crashed into a tree. Computers will do exactly what you tell them, so the instructions you give them better make sense.
In programming languages we write these instructions by writing what are called statements. Statements in programming languages are kind of like sentences in English. They use words, numbers, and punctuation to express one thought, one individual piece. Most programming statements are pretty short, just a few words. Now, exactly what words, numbers, and punctuation you use depends on the programming language. Some languages want each of your statements to end with a semicolon, like ending a sentence in English with a period, and others don't. You just go to the next line and start writing the next statement.
Some languages are all uppercase, some languages are all lowercase, some languages just don't care. Now, understanding the rules of each language is understanding the syntax of a programming language. So programming is the ability to take this idea in your head, break it apart into its individual pieces, and know how to write those pieces in the programming language you are using at the time, writing your statements in the right order, using the right syntax. But what language? Well, sometimes you get to pick a language and sometimes it's kind of picked for you.
We will talk about that in a moment.
Finally, the course compares how code is written in several different languages, the libraries and frameworks that have grown around them, and the reasons to choose each one.
- Writing source code
- Understanding compiled and interpreted languages
- Requesting input
- Working with numbers, characters, strings, and operators
- Writing conditional code
- Making the code modular
- Writing loops
- Finding patterns in strings
- Working with arrays and collections
- Adopting a programming style
- Reading and writing to various locations
- Managing memory usage
- Learning about other languages