You’ve surely heard about the compiler or about compiled and interpreted languages . . . But what really is a compiler ?

Daring Statement

If i were to say :

Interpreted languages are compiled languages

You’d jump at me trying to pull out a mingled concept from my brain explaining to me :

Compiled and interpreted languages are not the same . . .  yet i maintain what i say : Interpreted languages are compiled languages !

The real meaning of the compiler 

A compiler is nothing but a program that converts one code format into another. Simple !

Look,

let us say that i want to make my own language called newmoon.muberry whatever that means, well it does not exist . . .

// newmoon.muberry fake language syntax

push string test test test

x equals 2

Well the computer won’t make any sense out of it .  .  . so, to make it understand those phrases (really, a machine does not understand english), to make it understand, we use what he already understands and converts our instructions to what it understands

really, we are just printing to the console and assigning a variable, whatever the syntax might be.

So we have to see what the computer understand then we see how to translate it to that !

It is more fun by begining to see what a computer means

The computer

A computer is any machine that can do calculations. The abacus is a sort of computer. Getting aids to do calculations help matters a lot. No wonder, Charles Babbage was a mathematics Professor.

To summerise, a computer does calculation stuffs. Getting it to do that automatically is a plus. Directly integrating an output scheme is a plus . . .

Now, storing information in a form it could use later is better. Punched cards were used as a way of making the computer do the desired operations … that is what programming is, finding a way of making the computer perform the desired operations.

The History of Programming

Electric computers, how do they work ? By electricity, of course.

At first, to regulate the flow of electricity to do what programmers wanted, they soldered wired into the board.

But that was cumbersome, soldering, resolder  … , so the wires were made easily pluggable

After that it was found that the number of holes were too few, like connecting

X X X X X

|__

|

X X X X X

afforded restricted possibilities

So they put

0 O O O

1 O O O

2 O O O

so numbers like 412 etc were given meanings and the wires were plugged into the required holes

so programmers were essentially hardware guys

Dual state

The current flowing through a circuit has one state : if it is flowing, counting inexistance as existing, we get a second state, the dual states of on and off, of 1 and 0, of binary . . .

So, in the digital age, machine code involving 0 and 1 was used to program the machine directly. This came out to be difficult as errors crept in the instructions and the management of bytes and bits became complex. So, assembly language was invented

Assembly language was nothing but something used to represent machine code, it was a great improvement (also look at plankalkul)!

Now, how to make sense of full english phrases? By converting them to assembly language and executing them ! simple

From one code format to another

That’s what a compiler does, just translates . . .

mylanguage -> compiler -> desired code representation

so both an interpreted and compiled language use a compiler to transform instructions

____ Let us take cpython for example. It is the case of translating python code into bytecodes the c interpreter then interpretes the bytecodes. this is done for efficiency.

You can also just directly translate python code to c codes and then executes it normally. This is what a compiler does

____ Let us have a look at what we call compiled languages like C . The whole program is called a compiler but that is not the case. It is only part of the software that is called a compiler

compiler

linker etc until code executes

A compiler just recognises commands and translate them into another set of instructions that’s all, A game of text.

Functions of a compiler

A compiler :

Scans the instructions – using a lexical analyser

Recognises instructions – using a parser

Translate and / or execute the instructions in case of interpreted lang

 
In need of managing bookmarks online? Try the awesome Bookmark Ninja

Advertisements