You may already have a good idea of what computer programming is. Computer programming (or programming for short) is basically the process of telling a computer what to do, in a language it can understand.
A computer program is a set of instructions for a computer to perform a specific task - and programming is just the process of writing these instructions.
Let's look at our first example. Throughout this website, we'll be telling a computer how to draw stuff on the screen. We'll start with a classic example: showing the text "Hello world!" on the screen. The thing you see below this text is an example of a computer program!
$text("Hello world!");
In the block above, you'll see some text that reads $text('Hello world!');
and a "canvas" (or "drawing area") below it. The $text('Hello world!');
part is our instructions to the computer, and the "Hello world!" text drawn in the white rectangle is what the computer produces after executing our instructions!
You should go play around with this example - so that you too can be an official "programmer"! Replace the world world
with your own name in the computer instructions above, and then press the Play button to run your program. After doing this, you should see something your own name showing up on the canvas!
At this point, you might be thinking to yourself, "what's the big deal?". Our first example wasn't all that interesting. However, I want to point out a few important things:
Picture yourself having a conversation with your friend. You are both just making weird noises with your mouth. However, you both know how to make sense of these weird noises! Therefore, you two can communicate ideas to one another. This is what we call a language: a structured method of communicating ideas.
If you're reading this book, chances are you speak English - a language that you and I both understand and can use to communicate. However, computers don't speak in English (yet)! We can't just yell words at our computer and expect it to do things for us (although that'd be funny if we could). We need a way of communicating with the computers so that we know how to tell the computer what to do, and the computer knows how to make sense of the instructions we're giving it. We need a language!
A programming language is a language that humans can write and computers can make sense of.
There are a lot of programming languages out there already! Each language has its own strengths and weaknesses, and is generally used for some specific set of tasks. In this book, we're going to be using a programming language called JavaScript, which we'll learn about in the next chapter!