HomeProjectsBlog

Transpiling vs Compiling code

May 15, 2025

🔁 Transpiling vs 🧱 Compiling

🔁 Transpiling

Converting code from one language (or version) to another at the same level of abstraction.

  • 📥 Input: Source code (e.g., modern JavaScript - ES6)
  • 📤 Output: Equivalent source code (e.g., older JavaScript - ES5)
  • 💡 Use Case: Compatibility. Browsers may not support modern JS, so tools like Babel transpile it to older versions.

Examples:

  • TypeScript → JavaScript
  • ES6 → ES5 (via Babel)
  • SASS → CSS
💬
Note: SASS is technically a preprocessor, but often referred to as being "transpiled" into CSS.

🧱 Compiling

Translating high-level code into a lower-level form, usually machine code or bytecode.

  • 📥 Input: High-level source code (e.g., C, Java)
  • 📤 Output: Machine code or bytecode (e.g., .exe, JVM bytecode)
  • 💡 Use Case: To run the program efficiently on hardware or in a runtime (like JVM or CLR)

Examples:

  • C → Assembly → Machine code
  • Java → Bytecode (.class files for JVM)
  • Go → Native binary executable

🧠 Summary

FeatureTranspilingCompiling
LevelSource code → Source codeSource code → Lower-level code
AbstractionSame levelLower level
OutputHuman-readable (usually)Often binary or bytecode
Example ToolBabel, TypeScript compiler (tsc)GCC, java, Go compiler
GoalCompatibility or feature supportExecution