Most compiled languages read a source code file, process it into native machine code (called object code) and then can also sometimes link the object code with system libraries to create machine-dependent native executable program files. C, C++, and many other languages work this way. Interpreted languages do not have directly executable files, but have a language interpreter that loads the source file and executes the statements therein. Python is an example of an interpreted language. JavaScript is a scripting language, and is closer to an interpreted language, but isn't quite, as it is not designed to be used on its own, but from within another environment equipped with a JavaScript scripting engine, such as a web browser. Java is a little different yet. It is not interpreted, it is a compiled language. However, it is not compiled to native executable code like C or C++. Instead, it is compiled to a bytecode file that is used by the Java Virtual Machine to convert the bytecode into native executable code. It does this so that the Java program is platform agnostic and can run on any system that supports a JVM without needing modifications. You can compare this with running a game console emulator on your computer. The emulator creates a simulated gaming console that runs files containing compiled images of the games (ROM files) and converts that code to run on its host. The important takeaway is that the JVM is not an interpreter or translator; it creates an emulated environment that is always the same, regardless of its host machine or host operating system, so that it can be seemingly platform independent. From a programmer's perspective, there is little difference working with an interpreted language, a compiled language, or a scripting language. The process is the same. You write human-readable code, and it gets executed on a machine. It is only the parts in-between those two that differ. Historically, languages that compile to native code allow the programmer the most flexibility because they can take advantage of every aspect of the machine they are programming. Interpreted languages strip away some of that flexibility in order to have a "least common denominator" approach to running the programs, and scripting languages are the most restrictive still, usually removing any ability whatsoever to directly access the host machine or its operating system and/or working with a limited set of features. Answer from caphill7 on reddit.com
🌐
Reddit
reddit.com › r/learnjava › in actual practice, what does it mean to say that a language is "interpreted" vs. "compiled", and how does java relate to both?
r/learnjava on Reddit: In actual practice, what does it mean to say that a language is "interpreted" vs. "compiled", and how does Java relate to both?
June 20, 2022 -

I am in my third programing class in college, and we have only done C++ up to this point. My current class is on Java, and we are learning about how C++ is compiled and Java has a mixture of both compilation and interpretation. Some people are having a lot of difficulty with this idea, especially coming from JavaScript.

I understand that for a language to be interpreted, it means it is read line-by-line, converted, and executed right away; for a langauge to be compiled, it means that the entire source code is translated and the entire file is executed.

My questions:

  • But in practice (i.e. as in actual writing code and developing software), how are compiled languages and interpreted languages different?

  • Also, how is Java both? I haven't noticed any differences from using Java to using C++.

Top answer
1 of 4
65
Most compiled languages read a source code file, process it into native machine code (called object code) and then can also sometimes link the object code with system libraries to create machine-dependent native executable program files. C, C++, and many other languages work this way. Interpreted languages do not have directly executable files, but have a language interpreter that loads the source file and executes the statements therein. Python is an example of an interpreted language. JavaScript is a scripting language, and is closer to an interpreted language, but isn't quite, as it is not designed to be used on its own, but from within another environment equipped with a JavaScript scripting engine, such as a web browser. Java is a little different yet. It is not interpreted, it is a compiled language. However, it is not compiled to native executable code like C or C++. Instead, it is compiled to a bytecode file that is used by the Java Virtual Machine to convert the bytecode into native executable code. It does this so that the Java program is platform agnostic and can run on any system that supports a JVM without needing modifications. You can compare this with running a game console emulator on your computer. The emulator creates a simulated gaming console that runs files containing compiled images of the games (ROM files) and converts that code to run on its host. The important takeaway is that the JVM is not an interpreter or translator; it creates an emulated environment that is always the same, regardless of its host machine or host operating system, so that it can be seemingly platform independent. From a programmer's perspective, there is little difference working with an interpreted language, a compiled language, or a scripting language. The process is the same. You write human-readable code, and it gets executed on a machine. It is only the parts in-between those two that differ. Historically, languages that compile to native code allow the programmer the most flexibility because they can take advantage of every aspect of the machine they are programming. Interpreted languages strip away some of that flexibility in order to have a "least common denominator" approach to running the programs, and scripting languages are the most restrictive still, usually removing any ability whatsoever to directly access the host machine or its operating system and/or working with a limited set of features.
2 of 4
3
This will overlap with u/caphill7 's response a little. for a language to be compiled, it means that the entire source code is translated and the entire file is executed. for a language to be interpreted, it means it is read line-by-line, converted, and executed right away. There are several nuances to the definitions of interpreted and compiled and neither of the statements above are quite right. Compilation is the act of translating one language into another. Some compilers actually do this conversion through multiple language stages (from source, to an intermediate representation language, to a final language). The final output language may or may not be native-code. A unit of 'native' code is not necessarily executed in its entirety (eg some code path may not be used) and not of all the code executed is necessarily in a single file (the code may be one of several libraries dynamically loaded). Executing a 'scripting language' isn't really 'line-by-line. The interpreted/compiled distinction doesn't hold as well as it used to. Let's call one group of languages 'native code languages'. These use a compiler whose final output stage is native code (machine object code). C, C++, pascal, rust and many others fall into this group. most often, these produce a single unit of execution (an executable file). Another group of languages are 'scripting languages'. These languages use an 'interpreter' that reads source at runtime. However it is not true that all (or even many) of these execute the source directly, many employing one or more tokenisation and compilation steps first (sometimes) to produce either an intermediate language or native code to execute (but usually without outputting an executable file). Python, JavaScript and many others fall into this group. It should be noted that JavaScript, where the interpreter is built into the browser, is often compiled 'just in time', to native-code, before execution. Other scripting languages do this too - the trade off is the execution delay (while compilation happens) vs the performance improvements of native-code (where low-level optimisation can take place). Another group of languages are 'portable compiled languages'. These are compiled languages whose compiler output is an intermediate language. They require a 'runtime' on the target platform to execute the application, but execution may or may not execute the intermediate language directly - several include one or more 'just in time' compilers than selectively compile the intermediate language to native code. Java falls into this last group. Java source is compiled by the Java compiler to byte-code Byte-code is loaded by the Java Virtual Machine (JVM) - one unit per class/type but often packaged into a file per archive or module. The JVM May use an interpreter to execute byte-code May use one or more Just-in-time compilers to compile byte-code to native code with varying degrees of optimisation. May choose to recompile code if it looks like different optimisations should apply. Java uses statistics, of how the code is run, to guide the native-code optimisation. This means that running the same application with two very different data-sets, might choose to compile to native-code very differently. Languages like C/C++/Rust can do a similar thing with something called 'profile-guided optimisation' - but they have to choose a representative dataset, which may not match the data actually used. And newer releases of the Java Virtual Machine can improve the optimisation and execution of older byte-code. On the other-hand, Java optimisation has to be fast, and exist within the resource constraints of the execution environment. It has a much more limited time and space budget than a C++/Rust optimising compiler. Additionally the 'runtime' itself, just by its presence, takes up resources that the application could use to solve the applications computational exercise. In practice, most of the code you run in Java, for any long-running process, will be native-code produced by the fast C1 HotSpot Just In Time compiler, or native-code produced by the more aggressively optimising C2 JIT compiler. The interpreter will be used until C1 has compiled the code in question, or if code is de-optimised (to allow C2 to re-optimise it to respond to changing execution statistics).
🌐
GeeksforGeeks
geeksforgeeks.org › compiler design › difference-between-compiled-and-interpreted-language
Difference between Compiled and Interpreted Language - GeeksforGeeks
July 12, 2025 - A compiled language is a programming language that is generally compiled and not interpreted. It is one where the program, once compiled, is expressed in the instructions of the target machine; this machine code is undecipherable by humans.
Discussions

Definitions of “interpreted language” and “compiled language” with explanations of why Python and Java are or are not such languages - Python in Education - Discussions on Python.org
i’m not sure whether this belongs in the education category or a more general category. i’m dissatisfied with the definitions of “interpreted language” and “compiled language” that i have seen. as an educator, i need to explain these concepts to students. many people classify the ... More on discuss.python.org
🌐 discuss.python.org
2
September 6, 2024
Examples of when we'll use interpreted language over compiled language? - Software Engineering Stack Exchange
I understand the differences between interpreted and compiled languages, but if someone could provide some examples of situations when one is likely to use interpreted languages over compiled langu... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
November 6, 2012
programming languages - Interpreted vs Compiled: A useful distinction? - Software Engineering Stack Exchange
A lot of questions get asked here about interpreted vs compiled language implements. I'm wondering whether the distinction actually makes any sense. (Actually the questions are usually about langua... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
February 26, 2012
java - What's the difference between compiled and interpreted language? - Stack Overflow
After reading some material on this subject I'm still not sure what the difference between a compiled language and an interpreted language is. I was told this is one of the differences between Java... More on stackoverflow.com
🌐 stackoverflow.com
Top answer
1 of 13
525

A compiled language is one where the program, once compiled, is expressed in the instructions of the target machine. For example, an addition "+" operation in your source code could be translated directly to the "ADD" instruction in machine code.

An interpreted language is one where the instructions are not directly executed by the target machine, but instead read and executed by some other program (which normally is written in the language of the native machine). For example, the same "+" operation would be recognised by the interpreter at run time, which would then call its own "add(a,b)" function with the appropriate arguments, which would then execute the machine code "ADD" instruction.

You can do anything that you can do in an interpreted language in a compiled language and vice-versa - they are both Turing complete. Both however have advantages and disadvantages for implementation and use.

I'm going to completely generalise (purists forgive me!) but, roughly, here are the advantages of compiled languages:

  • Faster performance by directly using the native code of the target machine
  • Opportunity to apply quite powerful optimisations during the compile stage

And here are the advantages of interpreted languages:

  • Easier to implement (writing good compilers is very hard!!)
  • No need to run a compilation stage: can execute code directly "on the fly"
  • Can be more convenient for dynamic languages

Note that modern techniques such as bytecode compilation add some extra complexity - what happens here is that the compiler targets a "virtual machine" which is not the same as the underlying hardware. These virtual machine instructions can then be compiled again at a later stage to get native code (e.g. as done by the Java JVM JIT compiler).

2 of 13
114

A language itself is neither compiled nor interpreted, only a specific implementation of a language is. Java is a perfect example. There is a bytecode-based platform (the JVM), a native compiler (gcj) and an interpeter for a superset of Java (bsh). So what is Java now? Bytecode-compiled, native-compiled or interpreted?

Other languages, which are compiled as well as interpreted, are Scala, Haskell or Ocaml. Each of these languages has an interactive interpreter, as well as a compiler to byte-code or native machine code.

So generally categorizing languages by "compiled" and "interpreted" doesn't make much sense.

🌐
freeCodeCamp
freecodecamp.org › news › compiled-versus-interpreted-languages
Interpreted vs Compiled Programming Languages: What's the Difference?
January 10, 2020 - Every program is a set of instructions, ... code and convert it to computer-readable machine code. In a compiled language, the target machine directly translates the program....
🌐
DEV Community
dev.to › gridou › interpreted-vs-compiled-languages-understanding-the-difference-4ak8
Interpreted vs. Compiled Languages: Understanding the Difference - DEV Community
March 13, 2025 - An interpreted language executes code line by line, translating it into machine instructions at runtime. This means that the program does not need to be compiled beforehand—it is directly executed by an interpreter.
🌐
Python.org
discuss.python.org › python in education
Definitions of “interpreted language” and “compiled language” with explanations of why Python and Java are or are not such languages - Python in Education - Discussions on Python.org
September 6, 2024 - i’m not sure whether this belongs in the education category or a more general category. i’m dissatisfied with the definitions of “interpreted language” and “compiled language” that i have seen. as an educator, i need to explain these concepts to students. many people classify the programming languages python and java differently for these two terms. often java is classed as compiled but not interpreted and python as interpreted but not compiled. for me, this seems to require splitting hairs...
🌐
IBM
ibm.com › docs › en › zos-basic-skills
Compiled versus interpreted languages
During the design of an application, you might need to decide whether to use a compiled language or an interpreted language for the application source code.
Find elsewhere
Top answer
1 of 6
12

There's (to my knowledge) no such thing as an interpretted "language" or a compiled "language".

Languages specify the syntax and meaning of the code's keywords, flow constructs and various other things, but I am aware of no language which specifies whether or not it must be compiled or interpreted in the language spec.

Now if you're question is when you use a language compiler vs a language interpreter, it really comes down to the pro's/con's of the compiler vs. the interpreter and the purpose of project.

For instance, you may use the JRuby compiler for easier integration with java libraries instead of the MRI ruby interpreter. There are likely also reasons to use the MRI ruby interpreter over JRuby, I'm unfamiliar with the language though and can't speak to this.

Touted benefits of interpreters:

  • No compilation means the time from editing code to testing the app can be diminished
  • No need to generate binaries for multiple architectures because the interpreter will manage the architecture abstraction (though you may need to still worry about the scripts handling integer sizes correctly, just not the binary distribution)

Touted benefits of compilers:

  • Compiled native code does not have the overhead of an interpreter and is therefore usually more efficient on time and space
  • Interoperability is usually better, the only way for in-proc interoperation with scripts is via an interpreter rather than a standard FFI
  • Ability to support architectures the interpreter hasn't been compiled for (such as embedded systems)

However, I would bet in 90% of cases it goes something more like this: I want to write this software in blub because I know it well and it should do a good job. I'll use the blub interpreter (or compiler) because it is the generally accepted canonical method for writing software in blub.

So TL;DR is basically, on a case by case basis comparison of the interpreters vs the compilers for your particular use case.

Also, FFI: Foreign Function Interface, in other words interface for interoperating with other languages. More reading at wikipedia

2 of 6
8

An important point here is that many language implementations actually do some sort of hybrid of both. Many commonly used languages today work by compiling a program into a intermediate format such as bytecode, and then executing that in an interpreter. This is how Java, C#, Python, Ruby, and Lua are typically implemented. In fact, this is arguably how most language in use today are implemented. So, the fact is, language today both interpret and compile their code. Some of these languages have an additional JIT compiler to convert the bytecode to native code for execution.

In my opinion, we should stop talking about interpreted and compiled languages because they are no longer useful categories for distinguishing the complexities of today's language implementations.

When you ask about the merits of interpreted and compiled languages, you probably mean something else. You may be asking about the merit of static/dynamic typing, the merits of distributing native executables, the relative advantages of JIT and AOT compilation. These are all issues which get conflated with interpretation/compilation but are different issues.

🌐
Medium
muratakkan.medium.com › decoding-the-debate-interpreted-vs-compiled-programming-languages-b5551c2f0770
Decoding the Debate: Interpreted vs. Compiled Programming Languages
August 9, 2023 - They offer flexibility and faster ... Compiled Languages: In contrast, compiled languages are transformed entirely into machine code or an intermediate representation before execution....
🌐
LinkedIn
linkedin.com › pulse › what-difference-between-compiled-interpreted-programming-language
What is the difference between a compiled and interpreted programming language?
March 13, 2023 - In conclusion, the main difference ... processed. Compiled languages are translated into machine code before they are executed, while interpreted languages are translated into machine code at runtime by an interpreter....
🌐
TheServerSide
theserverside.com › answer › Interpreted-vs-compiled-languages-Whats-the-difference
Interpreted vs. compiled languages: What's the difference? | TheServerSide
April 15, 2021 - Compiled code can run faster, but, unlike interpreted code in Java, it is not platform agnostic. The code written in a compiled language is converted directly into machine code that is specific to the targeted runtime architecture.
🌐
Educative
educative.io › blog › compiled-vs-interpreted-language
Compiled vs interpreted language: Basics for beginning devs
March 10, 2026 - Compiled languages favor speed: A compiler converts the full program to native machine code ahead of time, producing fast, platform-dependent executables (e.g., C, Go, and Rust). Interpreted languages favor flexibility: An interpreter translates and runs each instruction during execution, making ...
🌐
Baeldung
baeldung.com › home › core concepts › programming › compiled vs. interpreted programming languages
Compiled vs. Interpreted Programming Languages | Baeldung on Computer Science
October 16, 2025 - On the other hand, unlike the compilers, the interpreters catch all the errors at runtime. Python is an example of an interpreted language.
🌐
TutorialsPoint
tutorialspoint.com › difference-between-interpreted-and-compiled-languages
Difference between Interpreted and Compiled Languages
Programming languages can either ... code is compiled and converted into the machine language before execution. Interpreted languages are executed line by line and there is no need to compile the code....
🌐
BYJUS
byjus.com › gate › difference-between-compiled-and-interpreted-language
Difference between Compiled and Interpreted Language
November 9, 2022 - Both compiled and interpreted are programming languages. When it comes to compiled languages, they are usually compiled, not interpreted. While on the other hand, an interpreted language is commonly interpreted.
Top answer
1 of 7
25

It's important to remember that interpreting and compiling are not just alternatives to each other. In the end, any program that you write (including one compiled to machine code) gets interpreted. Interpreting code simply means taking a set of instructions and returning an answer.

Compiling, on the other hand, means converting a program in one language to another language. Usually it is assumed that when compilation takes place, the code is compiled to a "lower-level" language (eg. machine code, some kind of VM bytecode, etc.). This compiled code is still interpreted later on.

With regards to your question of whether there is a useful distinction between interpreted and compiled languages, my personal opinion is that everyone should have a basic understanding of what is happening to the code they write during interpretation. So, if their code is being JIT compiled, or bytecode-cached, etc., the programmer should at least have a basic understanding of what that means.

2 of 7
11

The distinction is deeply meaningful because compiled languages restrict the semantics in ways that interpreted languages do not necessarily. Some interpretive techniques are very hard (practically impossible) to compile.

Interpreted code can do things like generate code at run time, and give that code visibility into lexical bindings of an existing scope. That's one example. Another is that interpreters can be extended with interpreted code which can control how code is evaluated. This is the basis for ancient Lisp "fexprs": functions that are called with unevaluated arguments and decide what to do with them (having full access to the necessary environment to walk the code and evaluate variables, etc). In compiled languages, you can't really use that technique; you use macros instead: functions that are called at compile time with unevaluated arguments, and translate the code rather than interpreting.

Some language implementations are built around these techniques; their authors reject compiling as being an important goal, and rather embrace this kind of flexibility.

Interpreting will always be useful as a technique for bootstrapping a compiler. For a concrete example, look at CLISP (a popular implementation of Common Lisp). CLISP has a compiler that is written in itself. When you build CLISP, that compiler is being interpreted during the early building steps. It is used to compile itself, and then once it is compiled, compiling is then done using the compiled compiler.

Without an interpreter kernel, you would need to bootstrap with some existing Lisp, like SBCL does.

With interpretation, you can develop a language from absolute scratch, starting with assembly language. Develop the basic I/O and core routines, then write an eval, still machine language. Once you have eval, write in the high level language; the machine code kernel does the evaluating. Use this facility to extend the library with many more routines and write a compiler also. Use the compiler to compile those routines and the compiler itself.

Interpretation: an important stepping stone in the path leading to compilation!

🌐
LinkedIn
linkedin.com › all › engineering › programming
Interpreted vs Compiled Languages: A Programmer's Guide
December 8, 2023 - However, this behaviour also makes ... of computer on which they were compiled. Interpreted Language on the other hand, are executed line by line in an interpreted program....
🌐
AlgoCademy
algocademy.com › blog › understanding-the-difference-between-compiled-and-interpreted-languages
Understanding the Difference Between Compiled and Interpreted Languages – AlgoCademy Blog
Less Flexible: Making changes requires recompiling the entire program or affected modules. Interpreted languages are programming languages where the source code is executed line by line by an interpreter at runtime, without the need for prior compilation into machine code.
Top answer
1 of 7
169

What’s the difference between compiled and interpreted language?

The difference is not in the language; it is in the implementation.

Having got that out of my system, here's an answer:

  • In a compiled implementation, the original program is translated into native machine instructions, which are executed directly by the hardware.

  • In an interpreted implementation, the original program is translated into something else. Another program, called "the interpreter", then examines "something else" and performs whatever actions are called for. Depending on the language and its implementation, there are a variety of forms of "something else". From more popular to less popular, "something else" might be

    • Binary instructions for a virtual machine, often called bytecode, as is done in Lua, Python, Ruby, Smalltalk, and many other systems (the approach was popularized in the 1970s by the UCSD P-system and UCSD Pascal)

    • A tree-like representation of the original program, such as an abstract-syntax tree, as is done for many prototype or educational interpreters

    • A tokenized representation of the source program, similar to Tcl

    • The characters of the source program, as was done in MINT and TRAC

One thing that complicates the issue is that it is possible to translate (compile) bytecode into native machine instructions. Thus, a successful intepreted implementation might eventually acquire a compiler. If the compiler runs dynamically, behind the scenes, it is often called a just-in-time compiler or JIT compiler. JITs have been developed for Java, JavaScript, Lua, and I daresay many other languages. At that point you can have a hybrid implementation in which some code is interpreted and some code is compiled.

2 of 7
58

Java and JavaScript are a fairly bad example to demonstrate this difference, because both are interpreted languages. Java (interpreted) and C (or C++) (compiled) might have been a better example.

Why the striked-through text? As this answer correctly points out, interpreted/compiled is about a concrete implementation of a language, not about the language per se. While statements like "C is a compiled language" are generally true, there's nothing to stop someone from writing a C language interpreter. In fact, interpreters for C do exist.

Basically, compiled code can be executed directly by the computer's CPU. That is, the executable code is specified in the CPU's "native" language (assembly language).

The code of interpreted languages however must be translated at run-time from any format to CPU machine instructions. This translation is done by an interpreter.

Another way of putting it is that interpreted languages are code is translated to machine instructions step-by-step while the program is being executed, while compiled languages have code has been translated before program execution.