Many people who read these boards may know somebody who programs or writes code, but they may not know exactly what that means. This is intended as an explanation to those non technical people what a programmer is doing when he writes code.
Computers basically work on mathematics. They do not understand English commands. In order to tell the computer what to do, we use special languages that are understandable by both humans and machines. For human readability, these languages include English keywords and lots of white space. For computer readability, these languages are almost always context free languages with a simple grammar and syntax.
What context free, grammar and syntax mean is not too relevant to this discussion. What is important is that these languages need to be simple so that computers can understand them. Computers are very fast, but only as smart as a human can program them. That is why understanding English is so difficult for them - you might not be aware of it, but it is a really complex language!
Using these computer languages, programmers write statements that instruct the computer what actions it needs to perform. These actions can be reading input from the mouse or keyboard, writing to a hard drive, updating a graphical user interface, or outputting a web page. These are but a few of millions of examples. All of these actions are either manipulating the memory of the machine, or interacting with a resource that the machine has access to, such as a hard drive, or printer, or the Internet.
Programs almost always execute from top to bottom. The computer starts on the first line, carries out the command, and then moves to the second line, until it is finished.
I'll illustrate this with pseudocode. Pseudocode is not a real programming language, but is really simple English used to illustrate ideas and program flow. So if we were to write pseudocode that would tell a tea making machine how to make tea, this is how it might look.
While this pseudocode may be enough for a human to understand, it is not quite good enough for a computer. If this were a computer program, it would not work without control statements. Control statements affect what actions the computer does next. They come in the form of Condition->Action. Some of them are loops, meaning the Action will be repeated until the Condition is false. Some loops perform multiple actions at a time (always one after another). Another example of a control statement is an if statement. An If Statement executes an Action only if the Condition is true. They can also execute statements if the condition is false.
So, if we were to rewrite the above pseudocode using control statements, it would look like this:
Real programs are far more complicated than this single example. They can contain hundreds of thousands of lines of code, written in different languages. For the program to work, all of these lines need to be correct. This is why large projects have several programmers working on them, as well as a project manager.
This is a very basic primer on what programming is. I hope it makes sense!
Computers basically work on mathematics. They do not understand English commands. In order to tell the computer what to do, we use special languages that are understandable by both humans and machines. For human readability, these languages include English keywords and lots of white space. For computer readability, these languages are almost always context free languages with a simple grammar and syntax.
What context free, grammar and syntax mean is not too relevant to this discussion. What is important is that these languages need to be simple so that computers can understand them. Computers are very fast, but only as smart as a human can program them. That is why understanding English is so difficult for them - you might not be aware of it, but it is a really complex language!
Using these computer languages, programmers write statements that instruct the computer what actions it needs to perform. These actions can be reading input from the mouse or keyboard, writing to a hard drive, updating a graphical user interface, or outputting a web page. These are but a few of millions of examples. All of these actions are either manipulating the memory of the machine, or interacting with a resource that the machine has access to, such as a hard drive, or printer, or the Internet.
Programs almost always execute from top to bottom. The computer starts on the first line, carries out the command, and then moves to the second line, until it is finished.
I'll illustrate this with pseudocode. Pseudocode is not a real programming language, but is really simple English used to illustrate ideas and program flow. So if we were to write pseudocode that would tell a tea making machine how to make tea, this is how it might look.
Pour water in the kettle until the kettle is full.
Switch the kettle on.
Grab a mug from the cupboard.
Place one teabag in the mug.
Place one sugar in the mug.
Place a teaspoon in the mug.
Wait until the water in the kettle has boiled.
Pour the water into the mug until the mug is 80% full.
Stir the tea using the teaspoon until the water is dark.
Remove the teabag using the teaspoon.
Add milk to the mug until the mug is 95% full of liquid.
Remove the teaspoon.
While this pseudocode may be enough for a human to understand, it is not quite good enough for a computer. If this were a computer program, it would not work without control statements. Control statements affect what actions the computer does next. They come in the form of Condition->Action. Some of them are loops, meaning the Action will be repeated until the Condition is false. Some loops perform multiple actions at a time (always one after another). Another example of a control statement is an if statement. An If Statement executes an Action only if the Condition is true. They can also execute statements if the condition is false.
So, if we were to rewrite the above pseudocode using control statements, it would look like this:
While the kettle is not full of water
Pour water into the kettle
Repeat until the kettle is full.
Switch the kettle on.
Grab a mug from the cupboard.
Place one teabag in the mug.
Place one sugar in the mug.
Place a teaspoon in the mug.
While the kettle is boiling
Wait for the kettle to boil
Repeat while the kettle is boiling
While the mug is not yet 80% full
Pour water from the kettle into the mug
Repeat while the kettle is not yet 80% full.
While the water is not yet dark
Stir the tea using the teaspoon
Repeat while the water is not yet dark
Remove the teabag using the teaspoon.
While the mug is not yet 95% full
Add milk to the mug
Repeat while the mug is not yet 95% full.
Remove the teaspoon.
Real programs are far more complicated than this single example. They can contain hundreds of thousands of lines of code, written in different languages. For the program to work, all of these lines need to be correct. This is why large projects have several programmers working on them, as well as a project manager.
This is a very basic primer on what programming is. I hope it makes sense!