DEV Community

Loralighte
Loralighte

Posted on

Fun Compiler Facts

I want to write a short article on compilers, simply because I am gonna be gone for SEVERAL hours because of... well you read Ubuntu Lumina - Devlog 1.2 right? Well anyways let me tell you a few cool facts that I learned about compilers.

1 - Interpreters are compilers
So I can see people disagreeing here but give me a moment to explain. Interpreters still compile to byte code but do not compile into a file, rather running automatically. Some say there is a "translation step", this is known as compiling. Compiling in short means takes the crap you threw into a file and turn it into executable 1's and 0's. Anyways cool.

2 - Languages that have compilers made with themselves...
Well, this one is hard to put in a short title. What I mean is that languages like V and Crystal for example, which use their language to make the compiler originate from a... let's call it prototype compiler. This prototype compiles the "new" compiler into byte code. That then gets used to make new features into the byte code, by running the new binaries. Let's put it into example.

Language x is born in someone's mind, and they want to use it to make the language x compiler. What they do is then take an existing language, let's say C++, to create the prototype compiler, they then rewrite that compiler the exact same way with language x. Then the developer tests to get the same results. After completing the basic compiler in the new language, they then start adding features using language X, and to change the existing code changes what is written in language X and compile it with the existing binary.

3 - Compilers don't always translate to byte code.
They can also translate to other languages, where their compiler/interpreter can then run it. Cool.

4 - I might be wrong?
If I messed any of this up, please tell me, I am always open to talk about my stupid mistakes.

Top comments (0)