[0.2] Compiler vs Transpiler
05/05/2021 • 10 minutes to read
Last updated
Was this helpful?
05/05/2021 • 10 minutes to read
Last updated
Was this helpful?
Before I start any wars on the subject of compilers vs transpilers (just in case there are any technical nerds out there reading), I'll provide the official definition of them
- A source-to-source translator, source-to-source compiler (S2S compiler), transcompiler, or transpiler is a type of translator that takes the source code of a program written in a programming language as its input and produces an equivalent source code in the same or a different programming language.
- In computing, a compiler is a computer program that translates computer code written in one programming language into another language. The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower-level language to create an executable program.
If you didn't understand those definitions, don't feel bad, official definitions of these things are often really wordy and quite a handful, so let's break it apart piece by piece. We'll start with transpilers. Transpiling is simply the act of turning one source code, into another language, like TypeScript into JavaScript. If you've ever used TypeScript then you're using a transpiler and you (may not have) even known it, yep! that's right, TypeScript simply "translates" to JavaScript.
Compilers are where the line starts to get all fuzzy and gray, you see, a compiler is technically "translating" your source code into another language, it just happens to be a really low-level language, such as Assembly, or Common Intermediate Language (CIL) for the .NET runtime. The key fact to remember about compilers vs transpilers is that compilers usually produce some form of "binary" or "executable" on your machine, while transpilers merely translate the source code into another language.
For the sake of this book, we're going to be sticking to the term "compiler", because we'll be building a language that outputs an executable binary to disk. If you don't fully understand it's okay. In the next lesson, we'll be getting into more about compilers and translators.