Both interpreters and compilers translate your code in a high-level language to machine instructions that can be executed on an actual CPU. Compilers do it all at once, so you get an executable program (an .exe file on Windows) that contains the machine code of the whole program. Interpreters, on the other hand, execute one line at a time, as they come to it. Java has aspects of both. It's compiled, but it compiles to Java bytecode, not native machine instructions. The bytecode is then interpreted, but this is a much simpler kind of interpretation. C# is like this as well - it compiles to .NET IL ("Intermediate Language") instead of native code. Both Java and .NET also have JIT ("Just In Time") compilation, meaning the most performance-critical parts of bytecode or IL can be turned into real native machine code when needed. Answer from ghjm on reddit.com
🌐
Reddit
reddit.com › r/askcomputerscience › interpreted vs compiled
r/AskComputerScience on Reddit: Interpreted vs Compiled
September 12, 2021 -

What is the difference between Interpreted and Compiled languages. Why C++ is said to be platform dependent but Java is not. If both these languages require certain set of applications for running why is the distinction made on the basis of environment?

Top answer
1 of 4
8
Both interpreters and compilers translate your code in a high-level language to machine instructions that can be executed on an actual CPU. Compilers do it all at once, so you get an executable program (an .exe file on Windows) that contains the machine code of the whole program. Interpreters, on the other hand, execute one line at a time, as they come to it. Java has aspects of both. It's compiled, but it compiles to Java bytecode, not native machine instructions. The bytecode is then interpreted, but this is a much simpler kind of interpretation. C# is like this as well - it compiles to .NET IL ("Intermediate Language") instead of native code. Both Java and .NET also have JIT ("Just In Time") compilation, meaning the most performance-critical parts of bytecode or IL can be turned into real native machine code when needed.
2 of 4
3
What is the difference between Interpreted and Compiled languages. A compiled language is one that's typically converted from human-readable text to binary data that can be directly executed by a specific family of processors on a specific OS. An interpreted language is one that's typically run through an "interpreter". Through one technique or another, it runs the program without compiling it ahead of time. Some languages can be compiled or interpreted, or kind of a mix. Modern Javascript engines do a mixture of interpretation and "just-in-time" compilation, where sections of the program are compiled into native code while it's running. Java is ahead-of-time compiled, but into a simple "bytecode", kind of like pseudo-machine code. A Java Virtual Machine is required to execute it (because it's not code that's native to any specific CPU or OS). Python can be transformed from text into a binary format that's easier for the interpreter to run. If both these languages require certain set of applications for running why is the distinction made on the basis of environment? C++ needs a compiler to transform it into an executable file, after which it can run directly on the CPU (after being loaded into memory by the OS). You'd need to compile C++ with an appropriate compiler for every platform you want it to run on. Java needs a compiler to transform it into Java bytecode, then a JVM on any computer that you'll run the code on. The JVM will be different for every platform, but the same compiled Java bytecode will run on each of the platforms.
🌐
Reddit
reddit.com › r/learnpython › difference between interpreted languages and compiled languages
r/learnpython on Reddit: Difference between interpreted languages and compiled languages
August 7, 2023 -

Hey fellow Redditors,I'm currently learning Python and I've come across the terms "interpreted" and "compiled" languages. I'm a bit confused about what exactly these terms mean and how they impact the way code is executed.Could someone please explain the key differences between interpreted and compiled languages? What are the pros and cons of each approach? Are there any real-world examples that can help me grasp the concept better? Also, how does Python fit into this picture?I'd greatly appreciate any insights, resources, or explanations you can provide. As a beginner, understanding these fundamental concepts would be a big step forward in my programming journey.

As an aerospace engineer, I feel like if I can learn to how make planes fly, it shouldn't be too hard to learn how to do a small machine like a computer to work properly.

Thanks in advance for your help!Happy coding,

Mr. Throw Away Account, Esquire

🌐
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).
🌐
Reddit
reddit.com › r/explainlikeimfive › eli5 what is the difference between a compiled language and an interpreted language in programming
r/explainlikeimfive on Reddit: eli5 What is the difference between a compiled language and an interpreted language in programming
December 30, 2022 - With a compiled language, the human ... understand. Interpreted languages don't get compiled, their code gets translated on the fly between the human friendly code and and what the machine can understand....
🌐
Reddit
reddit.com › r/learnprogramming › still having a hard time understanding compiled vs interpreted languages.
r/learnprogramming on Reddit: Still having a hard time understanding compiled vs interpreted languages.
January 22, 2023 -

What is Interpreted Language? An interpreted language is a programming language that is generally interpreted, without compiling a program into machine instructions. It is one where the instructions are not directly executed by the target machine, but instead, read and executed by some other program.

This is the first answer google comes up with. Java is considered a compiled language (right?) and it is also first translated into Java bytecode (so not directly executed by the target machine).
What's the difference?

Top answer
1 of 5
5
Java is compiled into machine code just like C or C++, but the machine code it's compiled into is for a made up machine called the "Java Virtual Machine." Any kind of computer or operating system or whatever that wants to run Java code writes a little emulator that pretends to be such a machine, much like an NES emulator, and then it uses that emulator to run Java programs. This is pretty neat because the Java will run on any machine with an emulator, whereas something compiled for, say, an Intel x86 CPU will need to be recompiled to run on some other sort of computer. (nit: technically, the JVM isn't really an emulator, and some other stuff happens to make Java fast, but it's a good way to think about it).
2 of 5
3
Java is compiled to an intermediate language called Java bytecode. Or it can be AOT-compiled directly to native code. In the case with Java bytecode, it is executed by another program - JVM. the JVM can interpret the bytecode, and can optionally JIT-compile it (generate native code on-the-fly). So the bytecode itself is an interpreted language, with optional JIT compiling. JIT compiling itself can be considered a mix between interpreting and compiling techniques. Actually any language can have both a compiler or interpreter implementation (or multistage mixing of those in the case of process VMs like JVM), although some are more fitted for one of the two options. You can differentiate compilation and interpretation in terms of how the program is distributed (in source or compiled code). The compiler is a program that translates source code to lower level code. The interpreter executes some source code on-the-fly. VMs can combine techniques from both.
🌐
Reddit
reddit.com › r/learnprogramming › in actual practice, what does it mean to say that a language is "interpreted" vs. "compiled", and how does java relate to both?
r/learnprogramming 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 5
5
In a compiled language, I bake a cake (compile my code), then hand it over to you. It's a little more difficult for me (the programmer), since I have to spend some extra time baking. It's faster for you (the user), since you get to just dig into a cake. In an interpreted language, I get all the ingredients for a cake together, then hand them to you, along with an automatic cake-baking robot (the interpreter). It's a little easier on me, since I don't have to actually bake the thing, but it's slower for you, since you have to wait for the robot to finish baking your cake. Of course, nowadays, automatic cake baking robots are getting so smart and fast, that for most practical purposes, there's actually very little speed difference on the user end. Compiled languages are still the top-choice when you want to eek out every last bit of performance, but in most cases, interpreters have gotten so good at their job that there's often very little difference in performance (and computers are so fast nowadays that most programs just don't need to worry about performance to that level of detail)
2 of 5
3
This is a common homework question, so I encourage you to read a lot more than this ELI5 post. If you're at this phase of a programming class, things are going to get much, much harder very quickly. The computer's CPU has to work with "bits". Those are the "0s" and "1s" we imagine or more specifically, patterns of high and low voltage sent to it over its pins. Some patterns of those 0s and 1s indicate "instructions" that tell the CPU to do work and "data", the information it does work on. So if we want to say, "What does 2 + 2 equal?", for an imaginary CPU we might say: STA 2 STB 2 ADD That's "Store 2 in the location A". "Store 2 in the location B". "Add A and B". But if we break it down to 0s and 1s, the CPU wil just see this as a stream of data: 10 2 11 2 14 That is, maybe "STA" is instruction number 10, "STB" is instruction number 11, and "ADD" is instruction number 14. The goal of both compilers and interpreters is to take a programming language, something that humans can read, and turn it into those numbers, because it's easy to turn numbers into the electrical patterns the CPU can work with. An interpreter does it one line at a time. That means it starts with "STA 2", converts it to "10 2", then sends those numbers to the CPU immediately. Then it looks at "STB 2", converts it to "11 2", then sends THAT to the CPU. Then it sees "ADD", converts it to 14, sends it to the CPU, and probably puts the result on the screen for you. A compiler has to do it all at once. Instead of sending each instruction to the CPU after seeing it, it generates the whole stream "10 2 11 2 14" and saves that as a "program". When you run the program all of the instructions will execute, but there's not a way to run them one at a time like the interpreter did. Interpreters are faster to start. They only need to see one instruction before they can start sending commands to the CPU. But they only "see" one instruction at a time, so if they have to repeat parts of the file it's harder for them to notice that and try to optimize it. Interpreters can make it easier for code to run on lots of different computers, because it's the interpreter's job to understand the right instructions for the CPU and if you run your interpreted program on a different CPU, you have to use a different interpreter. Compilers usually take longer to produce their output files, but it's because they can look at the whole program and try to notice if parts of it can be reused or optimized. The program they produce usually runs faster than it would if an interpreter ran it. Compilers have to output specific CPU instructions, so the program they create may not work as-is on all computers. But those are very loose advantages and costs. There are ways interpreters can try to do optimizations and be faster. There are ways compilers can try to output code that works well on many machines. They are good at different things, and honestly neither is bad at many things. For an analogy, imagine if a program itself is like a recipe for cookies. An interpreter is like hiring a baker. They will look at the recipe, follow its instructions, and you will get cookies when they are finished. A compiler is like calling a bakery. They've probably already made a batch of cookies so they can ship those to you.
🌐
Reddit
reddit.com › r/learnprogramming › is compiled vs interpreted still a meaningful distinction worth teaching?
r/learnprogramming on Reddit: Is compiled vs interpreted still a meaningful distinction worth teaching?
March 23, 2019 -

In the days of C vs BASIC, maybe it was a lot clearer, but now most of the main languages are bytecode compiled that's either or both interpreted or compiled at run time. Include the variability in language runtime complexity and everything you might say about the distinction from performance to portability becomes weak "tends to" assertions.

EDIT: since everything is worth teaching in some context, let's say teaching as part of a first programming class (where it's usually in the first lecture) versus an advanced comparison-of- programming-languages type class.

Find elsewhere
🌐
Reddit
reddit.com › r/learnprogramming › confused about interpreted vs compiled. and then there is jit..
r/learnprogramming on Reddit: Confused about Interpreted vs Compiled. And then there is JIT..
January 25, 2025 -

You often read that Python is an interpreted language and Java is a compiled language.
In reality, neither is completely true: both get compiled down to an intermediate code (bytecode).

If I understand correctly, the difference is that Python is compiled and the bytecode is interpreted "on the fly", while Java is compiled into bytecode files which can be executed (interpreted by the JVM).

But then there is JIT (Just In Time) compilation for Java too, which to my understanding does the same thing as I already described for Python?

I also heard that the reason for the categorization for both languages is that Java bytecode is lower level (closer to machine code) than Python bytecode. So the compile part is bigger than the interpretation part and therefore it's named a compiled language.

The lines are fuzzy. Even a language like PHP is broken down in the Zend engine into some intermediate code before being interpreted.

I feel like I should know this by now, but it's still something that confuses me and I'd be thankful for any clarification.

🌐
Reddit
reddit.com › r/programming › interpreted vs compiled programming languages
r/programming on Reddit: Interpreted vs Compiled Programming Languages
September 27, 2019 -

Can anyone help me out with this question?

Why are the two most popular data science languages (Python and R) interpreted languages rather than compiled languages? Compare the advantages and disadvantages of interpreted and compiled languages for data science / business analytics.

Top answer
1 of 5
3
Consider common libraries used in Python for data science: Numpy, SciPy, and pandas. All three have bindings and high-level interfaces written in Python, but the low level stuff in C, C++, Cython, and even Fortran, all compiled languages. So, you get to write pretty, high-level Python code, but get the performance of higher-speed compiled libraries behind the scenes. That's seen as the value here.
2 of 5
2
Maybe you mean dynamic vs static? Python can be compiled through pypy for example, and Julia (Python/R most recent competidor in this area) doesn't even have an interpreter outside of the debugger (in fact Julia has comparable performance to C++ in numerical processing while being a dynamic language). Being a dynamic language doesn't necessarily mean it's slower. And data science / business analytics is mostly exploratory and iterative work, people don't know what they want when they start and they'll rewrite things a lot until they are satisfied, with the need for instant feedback. If I'm using a language like an advanced calculator I don't want to compile the program at every change, deal with type checking restricting what I can give to a function (which would not be any trouble in a dynamic duck typed language) and I don't want to see variables by printing. In comparison you'd be in the REPL/Jupyter notebook of a dynamic language where you can evaluate/change/plot anything at any point and get instant feedback. Of course, there are static languages with REPL and type inference to help, but they can't achieve the level of dynamism in the same way gradual typing can't reach a static language in compile time guarantees. That said there are more than exploration to data science, and in the end most of the code is actually written in static languages for a reason (better safety, speed in some cases, easier to maintain for larger teams, better optimizations potencial), like most of the large Python/R libraries and frameworks such as Spark. For those C++, Java, Scala and Fortran are very popular.
🌐
Reddit
reddit.com › r/algorithms › compiled vs interpreted languages
r/algorithms on Reddit: Compiled Vs Interpreted languages
September 12, 2017 -

I'm hoping I can get some first-hand experience. In my algorithms class, we are working on testing bubble sort vs merge sort. I've been having trouble implementing it in C++ due to my limited experience in it. We are working with files that are around 100 million unsorted integers.

We can use any language, so I was wondering if I implemented it in node.js will its really take 5x to 10x longer? I'm asking just because I don't have a lot of time to test and implement my self and don't want to go down that rabbit hole if it's not worth the trouble. Thanks for the feed back.

edit: for those wondering I went with js using node for merge sort since I was having a problem with vectors in c++. I wrote bubble sort in c++. Thanks for all the great responses.

Top answer
1 of 4
8
Unless you're running this on an actual potato I don't think you will see much of a difference in runtime. Interpreted languages will typically run much slower than their compiled counterparts but usually the tasks you are trying to perform are so short (time-wise) that the time difference is negligible. 100 million may seem like a big number but its really not that large computationally speaking (especially when talking about an array of ints). My quick rough math says thats like 4mb of data (don't quote me on that, I just woke up). I don't think you'll see much of a time difference. Maybe at most a few seconds. If time to complete the algorithm is an issue you should be fine going with whatever you're more comfortable with. However, I do recommend stepping outside of your comfort zone and trying out new languages when you can. C++ is a powerful language to know. If you do decide to try out C++ check out this Stack Overflow post before you do. Good luck!
2 of 4
3
"Compiled vs Interpreted" is generally not an inherent property of languages, but of language implementations. For some languages, there is only one implementation, so this is a pointless distinction, but there are, for example, interpreters for the C language and compilers for Javascript. And speaking of which, node.js is not really a language but an implementation of Javascript along with a core set of libraries. And the implementation includes both an interpreter and a compiler (actually compilers targeting both machine code and the intermediate representation that the interpreter works on). Depending on the sort of code you throw at it, the compiler can generate code that competes well with other compiled language implementations. The distinction that really matters for your question, at least in the realm of languages, is how straightforward it is for a compiler to translate programs in the language to a form that can be executed efficiently. Many modern languages (like Javascript) allow you to write programs without saying anything about specific details of in-memory representations or where memory is allocated and freed. Often, you don't even have to give details about what kinds of data you'll be passing--it'll have to check and look up the right implementations of the operations you perform when the information is available, which is often not until the program is running! These languages are often interpreted, and those details get handled by the interpreter. You could compile programs in these languages to machine code, but a lot of the time would be spent running the same checking, dispatch, and memory management code that an interpreter would run, so there's not much point in writing a simple compiler. Languages like C and C++ tend to be very explicit about all the details, and they require the programmer to specify things with enough detail that a compiler can figure out all the questions of representation, operation choice, and memory allocation before the program runs. A fairly simple compiler (for the case of C, anyway; C++ itself is complex enough that it's hard to write any implementation at all for it) can make pretty efficient code for a language like this, because the details are spelled out. So these languages typically have machine code compilers. For a long time it's been known that you can get performance of the less-explicit languages a lot closer to the more-explicit languages in the case that the programs they run could have been given a simple explicit definition. You do this by monitoring the execution of your interpreter and figuring out based on the checks it makes and dispatch decisions driven by the data it's running on and thus figuring out the details that would have been given in an explicit language. You can then either shortcut things in the interpreter to avoid running checks over and over, or you can invoke a compiler while the program is running to create an efficient specific routine based on the information that's been discovered. Once the compile is done, there's a new "instruction" in the interpreter that gets called for the compiled code path whenever it comes up. So, why did I explain all this? Well, node.js has the sort of compiler I was talking about which will compile bits of code while it's running. And to answer the question of whether it'll be able to compile to efficient code for your algorithm, you'll need to know whether your code is going to run like an explicitly-described program over the data you're going to give it, or whether it is doing a lot of operations that will vary based on aspects of the data that are going to change while the program runs. You also don't get to be explicit about how data is stored, and sometimes just changing data representation in a language that lets you be specific about it can make a huge difference in how long an otherwise identical algorithm will run. Anyway, there are a lot of factors that can make a program faster or slower than another, and the language (and implementation of it) that you choose can definitely add a 5x to 10x factor. But in the realm of algorithmic study, you'll find that a 5x to 10x factor is not very relevant to the topic. If it's the sort of class that will have speed competitions, though, you will probably want to get pretty good at a language that lets you be as explicit as possible in order to be competitive with others who also pick good algorithms.
🌐
Reddit
reddit.com › r/learnpython › what is interpreted vs. compiled?
r/learnpython on Reddit: What is interpreted vs. compiled?
September 1, 2017 -

Learning python and saw a definition in the textbook of interpreted languages vs. compiled.

What do the differences mean for a programming student like me? Is one faster/better/etc?

Also, I came from Java classes in high school and always noticed a .class file along with a java file (essentially two files for every program) whereas with Python I have only seen .py files.

Is this a result of the interpreter vs compiled language properties?

Top answer
1 of 4
6

I'm gonna throw you a bit of a curve ball here.

There is no difference, assuming you're using any language that's a higher- abstraction than your processor's Assembly Language.

All interpreted languages are compiled, and all compiled languages are interpreted. The differences arise when you compare what they are compiled to, and by what they are interpreted.

And, confusingly enough, there is no Turing-complete language that cannot be either compiled or interpreted, based on how the user wishes to implement the language.

In the general sense a language that is compiled is converted before being run to a representation that is directly interpretable by the machine (i.e. Assembler), without an intervening process having to do the interpretation. And a language that is interpreted is one that requires that intervening process, which runs at the same time your program is run, and which knows how to act as a middleman between the ideas expressed in the language you wrote in and the language your machine speaks.

In other words the compiler is like someone who translated a work in a foreign language into one you understand now, and wrote it all down in book. It took time and energy for them to do that, but now you can read the book as fast as you need to. Whereas an interpreter is like someone translating a book in the foreign language to you live. The latter case is obviously slower, but is also much more useful in situations where you don't have time to wait for someone to write down and publish the whole translation.

Others will no doubt give you other, probably more useful answers, but this is an interesting point to think about; the languages themselves don't care how they're implemented. You could write an offline compiler for Python that turns it into a compiled language, and you could -- if you wanted -- write an interpreter for C to do things immediately, as you typed them. The language doesn't care, it's people that try to draw toe distinction.

2 of 4
3

Sounds like you've got the basic idea. In compiled languages, you must take the source code and compile it to an executable form. With interpreted languages like Python, you can execute code (pretty much) straight from the source thanks to the interpreter. So, an interpreter is kind of like a middle-man that makes it easy to send instructions to a computer straight from source code.

When you run .py files, there is actually a step where that is 'compiled' into .pyc files (usually stored in a __pycache__ directory) which is Python bytecode. Though, this is not the same thing really as you would think of compiling a C program, for example. The process of compiling .pyc files mainly just help your scripts get imported faster on subsequent runs when there are no changes to the code. This compilation, or conversion to bytecode, takes all of a fraction of a second, even for monstrously large amounts of source code. This is unlike compiled languages where some builds can take hours or longer to compile.

Is one faster/better/etc?

There are a lot of tradeoffs, but they are really oriented towards details of the implementation of the language, not so much the language itself. So try not to worry about it so much.

But to answer your question... It would be foolhardy to outright say in a blanket statement that one is better than the other. Put very shortly, compiled languages have the advantage that they're compiled to machine code and run very fast for that reason. Interpreted languages generally are very dynamic and more flexible (like not having to compile your code constantly), but because it doesn't compile to low level machine code, there can be performance concerns in some applications. For a more informed and in-depth answer see here

However, it's worth noting that in Python, you can take advantage of C extensions, so you can get the best of both worlds if you really need it. Many high performance numerical/scientific packages do this.

🌐
Reddit
reddit.com › r/learnprogramming › interpreted vs compiled language? why is java a compiled language?
r/learnprogramming on Reddit: Interpreted vs Compiled language? Why is Java a Compiled language?
April 10, 2015 -

This has been something I never fully understood even after reading questions and such on Stack Overflow, Google, and from textbooks about the topic....but I still don't get it.

From what I think I know...
Interpreted Language = Its translated to something else and then the machine directly reads that something else.
Compiled Language = Its translated directly to machine code.

I think I am wrong somewhere on that, because Java is considered a compiled langauge, but I thought Java translates to JavaByte code/JVM and then to machine code like a interpreted language.

Can anyone help with exactly what the difference is between all these things?

Top answer
1 of 3
5
Because the bytecode that the JVM reads is practically assembly. The JVM is therefore just a way to run this assembly on any machine. Heck, you could make a virtual machine that runs ARM programs on your x86 machine, if you wanted. Doesn't change the fact that your program was (presumably) compiled into ARM assembly. But here's the real kicker: compilation merely refers to converting a language into another. That's it. So when you convert Java into Java bytecode, you compiled it. Here's some other examples of compilation you might not have thought of: Google's Traceur compiler compiles ES6 (the newest JavaScript standard) into ES5 (the current JavaScript standard), allowing you to use new JS features in current browsers. Microsoft's TypeScript is compiled into JavaScript. Scala is also compiled into Java bytecode, allowing it to run on an unmodified JVM. Some languages don't actually compile to assembly, but instead compile to a simpler language such as C and then compile that using an existing C compiler. This can be easier to write because it's easier to read and debug C code than assembly. It also allows you to write one compiler that works on every platform (since there's a C compiler for pretty much every platform). You should also know that the difference between compiled and interpreted isn't important. Especially since the line is blurred. Internally, interpreters will often convert the code into an alternative format, such as a parse tree. This is entirely in memory, not a file thing. Further, some interpreters use Just-In Time (JIT) compilation to compile parts of the program on the fly. This improves performance for commonly executed code. All modern browsers do this with JS.
2 of 3
4
A long time ago, the difference between 'interpreted' and 'compiled' was somewhat clearer - the line has become blurred over time. An interpreted language generally only exists as source code (also called a script). The code is parsed into memory and executed every time the script is run - no machine readable code is ever produced. In essence, the interpreter itself is the executable - the script just directs the actions of the interpreter. This is different from a compiled language in which an external object (the machine-readable executable) is produced. This executable can then be distributed to other systems without the need to pass the original source code around. One of the most obvious reasons for this distinction was speed - back in the day, compilation was a really slow process. It wasn't unusual for a compile to take hours. So, it made sense to have mundane tasks handled by scripts that could be modified and run fairly quickly. Of course, these days compilation is much faster. In fact, many IDEs do continuous error checking by compiling code as you type. It happens so quickly that the user generally doesn't even notice. That has made it possible to have semi-compiled languages, like Java. Essentially, Java compiles to bytecode, not machine code. The bytecode is then interpreted by the virtual machine. It happens so quickly, of course, that you probably wouldn't even notice the difference. Just to add to the confusion, the JRE now ships with the hotspot compiler, which does actually compile the bytecode to machine code. So, the question of whether Java is compiled or not really depends on your definition of 'compiled'. It goes through the same parse and emit process as C++, but the output is not directly executable. It still needs the JRE to actually execute the bytecode. However, the JRE doesn't have to any parsing itself.
🌐
Reddit
reddit.com › r/learnprogramming › understanding the difference between interpreted and compiled languages - need help
r/learnprogramming on Reddit: Understanding the Difference between Interpreted and Compiled Languages - Need Help
August 7, 2023 -

Hey fellow Redditors,I'm currently learning Python and I've come across the terms "interpreted" and "compiled" languages. I'm a bit confused about what exactly these terms mean and how they impact the way code is executed.Could someone please explain the key differences between interpreted and compiled languages? What are the pros and cons of each approach? Are there any real-world examples that can help me grasp the concept better? Also, how does Python fit into this picture?I'd greatly appreciate any insights, resources, or explanations you can provide. As a beginner, understanding these fundamental concepts would be a big step forward in my programming journey. As an aerospace engineer, I feel like if I can learn to how make planes fly, it shouldn't be too hard to learn how to do a small machine like a computer to work properly.

Thanks in advance for your help!Happy coding,Mr. Throw Away Account, Esquire

🌐
Reddit
reddit.com › r/learnprogramming › compiled vs interpreted: how big of a deal is it?
r/learnprogramming on Reddit: Compiled vs Interpreted: How big of a deal is it?
November 16, 2022 -

We have compiled programming languages like C++ and Java, then interpreted languages like Javascript and Python.

Is it a big deal that some are compiled while some are interpreted instead?

I mean, compiling and interpreting have the same end goal of translating the code to machine language. What's the reason for some languages using compilers instead of interpreters?

Top answer
1 of 4
5
An interpreter that interprets itself isn't very useful; that would be just a test case. Double interpretation is even slower than single. But a compiler that compiles itself doesn't have any speed penalty and that's a very typical way to write a compiler. So you almost always want to use a compiler to build compilers and interpreters and similarly low-level tools. Interpreters often have the advantage of better or easier debugging tools. They might also offer features that would be really difficult in a compiled language. For example, the BEAM low-level interpreter can do soft real-time preemptive multitasking and switch between tasks extremely quickly. Usually you have to choose one (threads) or the other (async executor), BEAM gives you both. Interpreters or JIT compilers for rapid development and prototyping, applications where speed is good enough build once, run anywhere deployment like web front end or scripts Ahead of time compilers for certain programming and OS tools very consistent performance (games, multimedia) usually an easy way to get better performance Some hybrid approaches get an honorable mention for speed and ease of development. JIT compilers with relatively static types and carefully written code can compete with AOT compilers. That's the situation with Java and C# and other languages on JVM or .NET. Or you can use a slow language to control a really fast library and end up with a custom application that does lots of math behind the scenes; that would be something like Python + NumPy or JavaScript + WebGL. (JavaScript can be fast with a good JIT and care, but you shouldn't rely on that if it's running in a browser.) Finally, pure interpreters that go straight from source code to execution are rare, basically only command-line shells. There's usually a compiler layer that translates to "bytecode" and that bytecode is interpreted or JITted.
2 of 4
4
first off, Java is interpreted. it just gets compiled into something that's easier to interpret efficiently. but it's not machine code. and no, interpreters do not, in general, convert the program to machine code. they do things on behalf of the program they're running, but they don't produce machine code for the program. there is an optimisation step, just in time compilation, when some parts of an interpreted program do get compiled. this compilation still doesn't result in code as fast as, say c++ because it does a whole lot more work and uses a much faster and less optimized compiler than you would building c++ software interpreted languages are much slower than compiled.
🌐
Reddit
reddit.com › r/programminglanguages › why are languages force to be either interpreted or compiled?
r/ProgrammingLanguages on Reddit: Why are languages force to be either interpreted or compiled?
May 3, 2025 -

Why do programming language need to be interpreted or compiled? Why cant python be compiled to an exe? or C++ that can run as you go? Languages are just a bunch of rules, syntax, and keywords, why cant they both be compiled and interpreted?

Top answer
1 of 5
58
They aren't forced to. You actually 100% can write a python to machine code compiler (infact, check PyPy for example). You can write a c++ interpreter. It just so happens some languages are better suited as interpreted or compiled. If a language is super dynamic like Python, with dynamic dispatch all over the place and your interfaces, you might aswell code an interpreter alongside it. If a language is static like C++, with everything known at compile-time, you might aswell compile to machine code. Everything's already known at compile-time so it's better to compile it to a format that doesn't need to be constantly dynamically evaluated.
2 of 5
15
Nothing forces them. Take Java and C# for example. Usually, they compile to some fancy virtual machine byte code, which is interpreted by the JVM/dotnet runtime on the individual devices. But you can also natively compile both down to machine code. This usually involves running the JIT once on the virtual machine byte code ahead of time. Languages are separated into compiled vs interpreted primarily by the existence of a compiler that checks certain invariants and may reject the code. A C codebase is compiled as a whole, all type checks done before any code runs. In comparison, JS and python are usually interpreted line by line with the only checks being some IDE tooling. Compiling is faster because it can transform the code (optimizations) before anything is run. But these optimizations can only happen when the code is properly constrained. And more dynamic languages like JS and python are usually barely constrained, which limits possible optimizations, which in turn makes them better for interpretation over compilation. But runtime performance isn't everything. Dynamic languages are popular because of the low Iteration times. Try compiling a large C++ or Scala codebase before running it: it will take quite a while. Compare that to JS or python, where you can change a line and instantly run it and see if it works. So there are certainly trade-offs. But the lines are blurring. Dynamic languages such as python and Ruby are moving towards gradual typing. Languages are slowly converging at a sweet spot, which I think will be a "Scala 3 with Caprese, but with the potential for manually optimizing code better".
🌐
Reddit
reddit.com › r/programminglanguages › is a language itself compiled or interpreted?
r/ProgrammingLanguages on Reddit: Is a language itself compiled or interpreted?
March 29, 2024 -

I have seen many mainstream programming language with similar tag lines , X programming language, an interpreted language...., an compiled system language.

As far as I understand, programming language is just a specification, some fixed set of rules. On the other hand the implementation of the programming language is compiled or interpreted, thus in theory, someone can write a compiled python, or interpreted C. Isn't it?

Top answer
1 of 17
35
To add, you can compile a language designed for interpretation, but you may be forced to ship the entire interpreter machinery with the output. At that point, compilation might amount to little more than zipping the source and interpreter.
2 of 17
24
The terms compiled and interpreted themselves are not even well-defined. Generally, we take compiled to mean that code is processed and optimized ahead-of-time or just-in-time (usually per-method), before executing the result (where executing means the result runs directly on the underlying machine, which may be a VM), whereas we take interpreted to mean, code is evaluated sequentially, with one expression being evaluated before beginning the next, usually through an abstraction which is higher level than the underlying machine. The interpreter itself is often compiled. Languages are on a spectrum between these, with some features able to be compiled, and others interpreted. There is a myth that all languages can be compiled, but this of course, is a meaningless observation. If you take an language where evaluating an expression is dependant on the dynamic environment resulting from evaluating the previous expression (ie, eval : Expr, Env -> Expr, Env), then there's nothing you can really compile ahead-of-time. Some will argue that you can JIT-compile each expression, but this results in something which performs many times worse than a trivial interpreter, and in my opinion, still falls under the definition of interpretation - hence, the observation is not relevant. It is also not the case that you are compiling if you embed an interpreter into the end result - the evaluation model is still interpretation - though partial compilation may occur. Conversely, there are languages with features written specifically to enable compile-time optimizations to take place and remove overhead from the runtime. While these can be interpreted in theory, doing so completely eliminates the purpose of reducing overhead. For many languages, the choice between interpreting and compiling can be an implementation choice, but there are outliers for which this is not the case. Languages are usually categorized by the evaluation strategy of their primary implementations, or the implementations which define the specifications. For those who like to propagate the myth that it's just an implementation strategy, I like to suggest they attempt to write a compiler for Kernel , without changing the semantics of the language to suit the desired evaluation model. I can then present them a Kernel program to demonstrate that their implementation is either incorrect, or is still an interpreter in disguise.
🌐
Reddit
reddit.com › r/explainlikeimfive › eli5 the difference between interpreted and compiled computer languages?
r/explainlikeimfive on Reddit: ELI5 the difference between interpreted and compiled computer languages?
June 22, 2017 -

I'm teaching myself code right now and this subject has come up here and there. I feel like I understand general qualities of the two languages but don't have a fundamental understanding of what they truly are.

Top answer
1 of 2
23
Compiled languages are translated directly into the machine code that the processor can execute. It would be like taking a cookbook written in Greek, and getting it translated to a cookbook written in English. Once you have the translated cookbook, you can then follow the recipes (as can everyone else that reads English). Interpreted languages are translated on the fly. It would be like having a professional Greek interpreter sitting next to you, and you'd go "ok, what next?" and the Greek guy would be "Add half a cup of broth" and so on. The upside is that you didn't have to wait for him to translate the whole damn book, and if the original author makes changes to the book in Greek, you don't have to go retranslate it. The downside is that now whoever wants to use the recipe book has to have the Greek guy sitting next to them. Compiled languages are usually faster to run, but they require a "build" step which can be time consuming, and is effectively when the translation to machine code is done. Interpreted languages don't usually require a 'build' step, but they usually don't run quite as fast, because they need to have the interpreter there, translating everything as the program runs.
2 of 2
1
Humans write instructions in source code in a format that is readable to humans. Computers don't natively understand human readable source code; they only understand machine code. There needs to be a translation between source code and machine code. The difference between interpreted and compiled languages is when that translation happens. In compiled languages, the translation happens before the code is shipped off the customer. Interpreted languages postpone translation till right before the customer runs the code. There are trade-offs for compiled languages vs interpreted languages but that's a different question.
🌐
Reddit
reddit.com › r/learnprogramming › are high level languages and interpreted languages the same thing?
r/learnprogramming on Reddit: are high level languages and interpreted languages the same thing?
February 12, 2026 -

i'm a freshman with super limited programming experience and this is my first semester adding CS classes.

my professor uses high/low level to mean all source code/executable code, but online I hear people say high/low level in the context of different programming languages. are they talking about interpreted languages/languages that compile directly to a native executable or something else?