Sunday, November 6, 2016

Overview of the Compilation Process and Programming Languages

First, some definitions are in order.

Programming language: set of rules to govern communication with a computer.
-Just like many different languages have different ways to express a greeting ("Hello", "Bonjour", etc), the different programming languages have different syntaxes to express certain commands (print a word to the screen, save a variable, etc.)

Compiler: a program that translates the human-readable code into code the machine can understand.

With that out of the way, here's a big scary diagram:

Don't worry, I'll go over each part.

The pre-processor doesn't do too much. It simply takes away parts of the program that are exclusively for human-readability, a.k.a. useless to the computer.

The compiler is where the heavy lifting takes place. Here, the syntax of the language is applied, as the compiler gradually breaks down the code into smaller snippets to analyze its purpose and effect. Once that happens, the compiler finally creates low-level assembly code that follows the source code.

The assembler takes the assembly code and converts it to machine code. The difference between the two is assembly code uses words for commands while machine code uses numbers to represent commands. The conversion is simply replacement in this case.

The linker takes the machine code and combines it with other machine code essential to run a program, creating an executable file that you can double click and run.

The loader and memory are mainly associated with running the program, which I am not concerned with.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This year, I hope to create my own programming language and write a compiler for it.

With designing a language, I can be very creative - this is a programming language in which the code shown will display the words "Hello World!"
brainfuck.JPG
Neat, huh?

While I won't make something this weird, I'll definitely try to put my own twist or quirk in my language.

Sources:
Arora, Himanshu. "Journey of a C Program to Linux Executable in 4 Stages." 
The Geek Stuff. N.p., 05 Oct. 2011. Web. 26 Sept. 2016.
"Compiler Design - Overview." www.tutorialspoint.com. Tutorials Point, n.d. Web. 25 Sept. 2016.
Various Articles. Esolang, the Esoteric Programming Languages Wiki. N.p., n.d. Web. 26 Sept. 2016.


No comments:

Post a Comment