What is a program?
A computer program is a piece of software that instructs the computer to do some task. When we write a program, we are in effect putting together a set of instructions for our computer.
At its very core, computers represent everything as a series of binary values. A binary value is a number in base 2. That is, each digit can be either a 0 or a 1.
base 10 | base 2 |
---|---|
0 | 0 |
1 | 1 |
2 | 10 |
3 | 11 |
4 | 100 |
Every instruction, every piece of data is just a binary value to the computer. We call the language of 0's and 1's that a computer understands, machine language. Furthermore different types of hardware will have different instruction codes. Thus, programs are not typically written at the machine language level.
The closest language to machine language is assembly. Assembly language uses human readable mnemonics. A mnemonic uses an instruction word like "add" instead of the machine specific numeric code for addition. Assembly instructions are typically 1 to 1 translations to machine language. That is one line of assembly is one line of machine code.
As assembly code is extremely close to the machine, the amount of details needed to produce a program is extremely high. Furthermore, assembly code is not typically transferable to different hardware platforms, which means that if you wanted your program to work on a different platform you would have to rewrite your assembly code in a completely new way.
Thus, assembly is rarely used except in cases where performance tuning is necessary. Instead, we use a high level computer programming language. There are many such languages that exist. C, Java, C++, C#, python, perl, javascript, lisp,... and many many more. Each language has their own benefits and is used for different types of applications. For example, in the web, you use javascript (and html, and css).
Once a program is written, it can then be translated into the 0's and 1's that a computer understands. This translation is done through either a compiler or an interpreter. A compiler will translate a program once, and store the results in an executable. When you want to run a program you do not need to translate it again. An interpreter will translate a program as it runs the program.
C is a compiled language. That is after you write your program in C, you use a C compiler to translate your program into an executable which you can then run. You can run this executable as often as you like without having to compile your program again.