Compiler VS Transpiler

Compiler VS Transpiler

Hi guys, in this blog we are going to discuss about Compiler and Transpiler terms and their basic differences. We will also look for some examples of each to get better visualization. Happy reading:)

What is Compiler?

Compiler is a program which translates the program written in a high level language into computer readable machine language (binary form).

A compiler is a computer program that translates instructions into machine code or lower level language form so that they can be read and executed in some machines.

Know Compiler

  • It scans entire program and then translates into machine language.

Capture3311.png

  • Execution time is faster.
  • Generates intermediate object code which further requires linking, hence requires more memory.
  • It generates the error message only after scanning the whole program.
  • Programming languages like C, C++, java use compilers.

h982p-RyK.jpg

What is Transpiler?

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.

Know Transpiler

  • we write our code in ES6+ and let the transpiler converts it to some different version (ES5/ES3, that works in every browser).
  • converting one higher level language to another higher level language.
  • Typescript is a high level language but after it’s transpiled it’s turned into JavaScript (another high level language). Or Babel for example can transpile ES6 JavaScript code into ES5 JavaScript.
  • That's why Transpilers are sometimes referred to as “source to source compilers”.
  • There are lots of transpilers for JS but the popular ones are Babel, TypeScript and CoffeeScript. ClojureScript transpiles from Clojure to JS . JSweet transpiles from Java to TypeScript or JS .

transpilerssourcetosource-compilers-11-638.webp

Main difference between Compiler and Transpiler:

Converting one higher level language to another higher level language is Transpiling and conversion of higher level language to readable(machine) language is Compiler.

End note

I hope you are now clear with the basics of compiler and transpiler! Would love to know your feedbacks in the comments!