Compilers

By Martin McBride, 2017-05-17
Tags: none
Categories: none

High level languages are designed to be easier for humans to read, write and understand. This makes it faster to develop programs, especially complex programs. It also tends to result in fewer bugs in the code, and it is generally quicker to find them when they do occur.

Another advantage of higher level languages is that the programs you write can run on different types of computers, with little or no change. We say that the languages are portable - the programs can be moved from one computer to another. This compares with assembly language programs which usually need to be completely rewritten to run on a different type of CPU.

We call these higher level languages 3rd generation because they are more advanced than assembly language. A 3rd generation language needs to be translated before a CPU can execute the code. There are 2 different ways of translating code - we can use a compiler (as described in this section) or we can use an interpreter.

Example of high level code

Here is some code, written in C, that calculates the nth Fibonacci number:

int fibonacci(int n)
{
   int first = 0, second = 1, next, i;

   for (i = 0 ; i < n ; i++ )
   {
      if ( i <= 1 )
         next = i;
      else
      {
         next = first + second;
         first = second;
         second = next;
      }
   }

   return next;
}

Don't worry if you don't know how to program in C. The important things to notice are that the language is written in terms that humans can understand - for loops, if statements, variables (rather than branch instructions, registers and memory locations that you find in assembly language).

Compilers

See also

Sign up to the Creative Coding Newletter

Join my newsletter to receive occasional emails when new content is added, using the form below:

Popular tags

555 timer abstract data type abstraction addition algorithm and gate array ascii ascii85 base32 base64 battery binary binary encoding binary search bit block cipher block padding byte canvas colour coming soon computer music condition cryptographic attacks cryptography decomposition decryption deduplication dictionary attack encryption file server flash memory hard drive hashing hexadecimal hmac html image insertion sort ip address key derivation lamp linear search list mac mac address mesh network message authentication code music nand gate network storage none nor gate not gate op-amp or gate pixel private key python quantisation queue raid ram relational operator resources rgb rom search sort sound synthesis ssd star network supercollider svg switch symmetric encryption truth table turtle graphics yenc