One Program, Four Languages

The same trivial program in C++, JavaScript, TypeScript and Python — and four genuinely different routes from source to behavior. Their pipelines are not the same shape, and this page refuses to pretend they are.

Here is the program. It adds two numbers and prints the result, and it is deliberately too small to be about anything except the pipeline. Every version produces 5.

What follows is not a ranking, and it is not a demonstration that the four are secretly the same. They are not the same. The routes differ in when checking happens, in what information survives to run time, in whether native code exists at all, in when it is produced, and in what must be present on the machine for the program to run. Those differences are the whole point, and the temptation to flatten them into "some are compiled and some are interpreted" is exactly what this module exists to remove — see [[compiler-vs-interpreter]] and [[execution-strategies]].

One thing genuinely is shared: all four compile. Every one of these routes builds at least one intermediate representation before anything executes, and three of the four generate native code at some point. The difference is *where each one stops, and when*.

The questions each pipeline answers differently

  • What is checked before execution?
  • What is retained at run time?
  • What is compiled ahead of time?
  • What may be optimized dynamically?
  • What runtime is required?