What is the difference between compiling and transpiling?

When talking about TypeScript, we often come across the word transpile. In this post, let’s try to understand what is transpiling and how is it different from compiling.

Transpiling is a specific kind of compiling. Compiling is the general term for taking source code written in one language and transforming into another. Transpiling is a specific term for taking source code written in one language and transforming into another language that has a similar level of abstraction.

transpile-vs-compile

So when you compile say C# or Java, your method bodies are transformed by the compiler into IL/Bytecode. This cannot be called transpiling because the two languages are at very different levels of abstraction. But, when you compile TypeScript, it is transformed by the compiler into JavaScript. TypeScript and JavaScript are at very similar levels of abstraction, so you could call this transpiling.

Other common combinations that can be dubbed as transpiling include C++ to C, CoffeeScript to JavaScript, Dart to JavaScript and PHP to C++.

I have also created video tutorials on learning Angular using TypeScript. You can subscribe to my channel here.

The following video explains the difference between transpiling and compiling in detail.

Top