DEV Community

Discussion on: What Is An "Interpreted" Language?

 
cjbrooks12 profile image
Casey Brooks

Why does it matter what it's compiled down to? The fact remains that you don't execute Java code from source, you compiled it and execute the bytecode. It doesn't compiled to the same thing as native languages, but there is an explicit compilation step.

Thread Thread
 
cjbrooks12 profile image
Casey Brooks

Perhaps the word your trying to describe is more accurately "embedded" than compiled?

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

What I find frustrating about this sort of conversation is, every time I talk to a Java developer, they have to keep moving the finish line (shuffle definitions, frequently add/remove pedantry) in an attempt to define how Java somehow "isn't interpreted." Python doesn't do this sort of dancing around the point; our language is interpreted, and there's no point in pretending it's otherwise.

Java is compiled to bytecode, which is executed by an interpreter. Without a Java interpreter on the target machine, the Java code cannot be executed. It is seldom, if ever, compiled/assembled down to machine code. This is a clear and distinct difference from C/C++, Ada, FORTRAN, COBOL, and many other languages traditionally called "compiled languages", which are compiled down to machine code and executed without the need for an additional interpreter.

Is there some sort of mass feeling in Java that identifying it as an interpreted language (in the most straightforward sense of the term) somehow delegitimizes it as a "real language" (which, it really wouldn't)? I'm really wondering at this point.

Thread Thread
 
cjbrooks12 profile image
Casey Brooks

I just fail to see how a language that has an explicit compilation step, from source to binary bytecode, could be called anything other than compiled. Your can't easily work in a REPL, your can't dynamically evaluate it from a String at runtime. Regardless of the implementation details, you use it in such a manner that once it's been compiled, you can't change it. The way you think about using it is fundamentally different from an interpreted language. In Python, PHP, Ruby, JS etc. you generally focus on including files to bring in libraries. You cannot do that in Java, or even anything like that without considerable complexity. You need to have your libraries compiled and ready to use bundled with your app at the moment it starts up, which is a fundamentally different way of thinking about dependencies, much more akin to a traditional natively compiled language.

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

All I mean by interpreted...and, actually, all I've ever known interpreted to mean...is that there's an additional software layer between the compilation result and execution.

Compiled language: Final Compilation Result => CPU
Interpreted language: Final Compilation Result => Interpreter/VM => CPU

That's all it ever means. Dependencies don't enter into it. Also, what you're describing with the REPL is an interactive language.

By the way, Python also has an explicit compilation step. It just doesn't demand the programmer invoke it. That doesn't make it any less an interpreted langauge.

...which is a fundamentally different way of thinking about dependencies, much more akin to a traditional natively compiled language.

But it still isn't a (traditional natively) compiled language. "Compiled language" needs to mean exactly what it has always meant, or we're going to confuse people. Which...is exactly what happens.

The way I see it, Java is an interpreted language for the reason stated above β€” we cannot pretend it doesn't (commonly) need that intermediate layer for the shipped result to be executed β€” but it is not an interactive language.

Thread Thread
 
cjbrooks12 profile image
Casey Brooks

Yes, I get that Java is technically "interpreted". But the semantics of the language are not the same as the semantics of Python or other more common "interpreted" languages.

Try to think of it from the perspective of a new developer, who doesn't know the difference between the two. If you tell them that Java is not compiled, then they will be extremely confused when you tell them they have to compile it before using it. That's all I'm trying to say.

While "interpreted" is a part of the underlying infrastructure of Java, it's not a common paradigm of the language, and it does not service to Java to call it interpreted.

Conversely, I don't think it does much to call native languages just compiled, because they are so much more. I think embedded is more accurate for what your describing, helps keep the purity of those native languages, and also keeps the common semantics of "compiled" vs "interpreted" to mean what people typically think of when they hear those words, even if they aren't too knowledgeable of the paradigms/runtime properties themselves.

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

I'll agree the semantics are different, but the problem is that the misconceptions surrounding "interpreted" and "compiled" are made worse by this sort of pedantry.

When this comes up with Python (again, different...but then we're different from, say, Ruby), we simply define interpreted exactly as I did above, and explicitly separate out all other concerns, including but not limited to...

  • Performance,
  • Dependency linking,
  • Packaging,

...et cetera. The confusion ceases immediately.

Maybe "embedded" would be a better term for C/C++, but then again, maybe not. That brings its own baggage, just as much as "interpreted" and "compiled" does.

In any case, the issue is probably that "compiled" is poorly defined. Maybe we should be referring to source -> bytecode as transpiling? Maybe source->machine code should only be called assembling? Is C an assembled language?

In the least, Java devs would do well to say that they're a "compiled interpreted language," and then take the time to separate out the other concerns.

Thread Thread
 
cjbrooks12 profile image
Casey Brooks

In the least, Java devs would do well to say that they're a "compiled interpreted language"

I can definitely agree with you here. These terms are murky, and Java is not purely one or the other, like Python or C++ are. Being more explicit about this in casual conversation might help to clear some of this confusion.

Thank you for such a thought-provoking thread and the good discussion!

Thread Thread
 
codemouse92 profile image
Jason C. McDonald • Edited

Back at you!

These terms are murky, and Java is not purely one or the other, like Python or C++ are.

By your logic, Python isn't really "purely" one or the other, either. Compilation does happen. Dependencies are handled differently than Java, but the interpreter doesn't just run the source any more than Java's VM does; it (implicitly) compiles it to bytecode first.

Yeah, I think it's not "interpreted" that's not clear. I think it's "compiled" that's the problem.

Thread Thread
 
cjbrooks12 profile image
Casey Brooks

Pardon my ignorance, I really know very little about Python 😁 I had no idea it converted source to bytecode internally!

 
jessekphillips profile image
Jesse Phillips

Just condense statements you've made.

'Java is an interpreted language, it is compiled'

Really the JIT is a system that confuses the definitions because this would be an accurate statement.

'Javascript is interpreted, the JIT compiles it'

Generally not every line is run through the JIT. You could even say

'D is a compiled language, it is interpreted at compile time'

But I think you are trying to bring Java into the same category as Python so you can use it to back your position that Python is a real language.

Java, as a language, is not interpreted. Byte code is not the written language.

Typescript is mixed because Javascript is valid and not compiled in Typescript. It is more analogous to the C preprocessor, which is referred to as a macro language.

Scripting languages are not well defined, I utilize D as my scripting language, but it is fully compiled to machine code. Then you through in JIT and things get more confusing.

To better understand, it is best to look at the term for the time it was emerging. You had C and Bash, Lisp and Fortran. Languages like perl and php follow closer to the style for bash, these languages start execution at the file entry and don't define a special entry (main).

As for inferiority of scripting over a real language, we need to look at the level of understanding necessary to use the language.

Bash required writing your shell commands to a file then calling bash on it. Similarly languages like visual basic would add container iteration. C required learning pointers and memory layout. While scripts could easily build the description of a task, but would be limited in performance. Today machines are resource abundant and optimization techniques are identified.

C++ was long considered a compiled language, but it wasn't until Walter that the first compiler to build machine code instead of C existed.