# KS3 Computing/Programming
## What is programming?

Programming is the process of designing and writing a set of instructions (a program) for a computer in a language it can understand. This can be really simple, such as the program to make a robot toy trace out a square; or it can be incredibly sophisticated, such as the software used to forecast the weather or to generate a set of ranked search results.

## Programming is a two-step process

First, you need to analyse the problem or system and design a solution. This process will use logical reasoning, decomposition, abstraction and patterns to design algorithms to solve the problem or model the system. Secondly, you need to express these ideas in a particular programming language on a computer. This is called coding, and we can refer to the set of instructions that make up the program as ‘code’. Programming provides the motivation for learning computer science – there’s a great sense of achievement when a computer does just what you ask it, because you’ve written the precise set of instructions necessary to make something happen. Programming also provides the opportunity to test out ideas and get immediate feedback on whether something works or not.

## Programming Concepts

There are a number of programming concepts these include:
* Sequence
* Selection
* Iteration
* Variables

## Programming Languages

Computer hardware only responds to the electronic pulses created when binary (0's and 1's) data is loaded into memory and treated as program instructions. As a side note this means that a computer program is data, which is an important concept for certain types of program. However having to write a program using only binary 1's and 0's is not a realistic choice as it's very time consuming and easy to make mistakes. For this reson computer engineers quickly developed the concept of programming languages.
A programming language allows a programmer to write their program as a piece of text using symbols and words that make it easier for humans to understand. Before the program can be executed it must be translated from the text to the binary needed by the computer.
Here is an example of a simple program written in the Python programming language
and the same program written in the C programming language

### Types of Programming Languages

There are many different ways to categorise programming languages. There are the imported ones:
* High level vs Low level
* Interpreted vs Compiled
* Style of programming supported (e.g. Object-Oriented, Functional or Block). It is possible for languages to support more than one style of programming.

#### High level vs Low level

When hardware designers create the control unit of CPU they decide which sets of instructions the processor will support. These instructions will cover areas such as arithmetic; flow of control (to allow the program to perform jumps in loops etc) and; storage and retrieval of data from memory. Depending on the hardware capabilities of the processor some of these instructions might be implemented to provide complex operations, tuned for multi-media for instance.
In a low level programming the application programmer is given direct access to these low level commands that are implemented in hardware. However rather than write in binary, programmers typically write in a macro-assembler language. The program is then translated to binary using an assembler tool. Here is an example program for a simple Z80 processor (all the text after ';' are comments)
As you can see it's not a very programmer friendly way to write and maintain code. This example does exactly the same as the previous "Hello World" examples. and this highlights the difference between the low level assembler code and the high level languages such as Python and C.

#### Interpreted vs Compiled

All computer languages require a translation program (assembler, compiler or interpreter) to translate the computer program into a form that can be run on a computer hardware, ultimately these are binary 1's and 0's.
A compiler is program that takes a program written in a high level computer language and generates the same program in the correct format using binary for the target computer. The target computer is where the program will run.
If the program needs to be run on target machine with different hardware then often the compiler will need to be modified to generate the different binary code needed. Compilers are complex programs and there is a large body of computer science knowledge. As well

## Further Resources

Barefoot Computing - Concepts - Programming