A C program is a series of instructions that changes the state of the computer. It can be used for all kinds of purposes, from sending e-mail to showing the weather on your computer screen. And it does absolutely nothing until you tell it to do something else.
The simplest kind of C program consists of just one line of code. That line says, “Do this.” A lot of lines later, the computer will do something else. After a few more lines, you’ll see what happens next.
Programming is a bit like photography. You have to know how to do it first before you can do it well. You have to learn the rules, which are pretty simple: write your program with only one line of code.
You can see this even in the simplest type of programming you might want to do: creating a program. Imagine you want to create a program that will print “Hello, World!” on the screen, and then go away.
The first thing you’ll need is a program. What kind of program? Well, say it’s for printing “Hello, World!”. You’ll need a loop that will print: “Hello, world!”, and then go away again after printing “world!” once more.
And what kind of program will do that? It will need an input function that takes an input string as its argument and prints the string back out on the screen; and it will need an output function that takes as its argument a string printed by the input function and prints it again on the screen.
There are also some other functions you’ll probably want: one for getting things into memory (say for storing strings), another for putting things into memory (say for storing numbers), one for manipulating strings (say for inserting or deleting characters),
The first line of code you write is a program. It does something, and it doesn’t take much to figure that out. It is the simplest kind of program, because it just tells the computer what to do.
But if the first line of code you write isn’t a program, and if the first line of code you write is only one line long, what makes you think your whole program will work?
Programming is one of the most important skills for a modern workaday life. It’s not just a job, it’s a way of life.
Programming is hard to learn and even harder to do well. That’s why you need to learn how to program in order to succeed at programming. But why should you go through all that pain?
Well, if you want to be a programmer, you have to get the basic skills right; if you don’t you’ll fail at programming and be forever frustrated by those who do. So once you’ve got the basics down, it doesn’t matter so much what language or platform you use. You can use any language or platform and still be a programmer.
Programming is a lot like cooking. You can make many things with very simple ingredients. It’s all about getting the proportions right.
Programming is like chess: you have to make all the pieces move in the right way, but you can’t be so rigid that you don’t leave yourself any flexibility. To write a program, you have to know all the rules of chess, but you also have to be able to see the whole board. If you are too rigid about what your program should do, it will be hard for other people to understand how to use it. When your program doesn’t work, the cause is often something much more complicated than a simple bug in your code.
You may need special tools to get your computer to do what you want. But once you’ve got those tools working, they are much easier to use than a manual-control carpenter’s saw or a power tool that requires exotic knowledge of electricity and chemistry.
The difference between programming and carpentry is not just technical. It is also cultural: computers are different from other tools precisely because they have been designed by human beings rather than by nature.
Programming is a form of knowledge work. In the most general sense, it can be viewed as the use of computers to automate tasks that would otherwise require humans to do them by hand. In practice, there are many ways to accomplish this. Some people write computer programs to help them with their own tasks: word processors, spreadsheets and databases. Others write computer programs to help other people with those same tasks: e-mail, web browsers and search engines.
The difference between these two approaches is sometimes called “programming versus scripting.” “Scripting” refers to any program that is designed specifically to perform one or more particular tasks.
Scripting is an extremely powerful way of automating tedious work. But it’s also somewhat limited. Scripts can’t do anything you don’t want them to do (unless you write a script that does that for you), which means they’re not very useful for many types of programming; and scripts can only be used once before they have to be rewritten from scratch, which means many scripts are essentially disposable.