184

Can Javascript be called a pure interpreted language? Or does it also have some compiled flavor to it? Could someone guide at the reasons behind both the things whichever being true.

rene
  • 41,474
  • 78
  • 114
  • 152
netemp
  • 4,115
  • 12
  • 43
  • 63
  • 49
    Please consider adding a comment when voting down so that the question can be improved. Thanks. – netemp Mar 08 '12 at 19:51
  • I wonder what you believe a 'compiled' language is. Even exe's are interpreted by the OS, or else linux binaries would be interchangeable with windows ones for instance. – Blindy Mar 08 '12 at 19:54
  • 3
    @Blindy: are you mentioning that the distinction between compiled and interpreted shouldn't be there at all? – netemp Mar 08 '12 at 19:57
  • Of course; what difference does it make? – Blindy Mar 08 '12 at 19:58
  • @Blindy: But isn't this one of the very common way of classifying languages as? – netemp Mar 08 '12 at 19:59
  • 2
    It may be a common way of classifying languages, but that doesn't make it any more useful. –  Mar 08 '12 at 20:36
  • 1
    @NetEmp (note I havent downvoted - but have voted to migrate to programmers) This is the wrong place to ask this type of question - read the [FAQ](http://stackoverflow.com/faq) on what questions to ask here - this should be in the programming section of StackExchange – Manse Mar 28 '12 at 15:29
  • 1
    @ManseUK: Thanks for sharing this. Will take care in the future. – netemp Mar 28 '12 at 15:32

2 Answers2

89

Go and read the answers to this question

https://softwareengineering.stackexchange.com/questions/138521/is-javascript-interpreted-by-design

The answer I accepted is excellent and should help answer your question.

For me personally, I am somewhat cautious of the idea of calling a language interpreted or compiled. It's an implementation decision, not part of the language specification. If you want to talk about compiled or interpreted JavaScript, ask it in the context of an actual implementation of the language specification.

Robert
  • 1,899
  • 1
  • 17
  • 24
Matt Esch
  • 22,661
  • 8
  • 53
  • 51
21

JavaScript is interpreted at runtime by the client browser. There is a tool called the Rhino JavaScript Compiler that supposedly compiles JavaScript into Java class files, though.

HellaMad
  • 5,294
  • 6
  • 31
  • 53
  • 7
    What about V8 and the like? –  Mar 08 '12 at 20:35
  • 32
    V8 never included anything like an interpreter, and most major JS engines feature JIT compilers by now. Thus, saying that "JavaScript is interpreted" is obviously wrong (or maybe your definition of interpreter/compiler is). –  Mar 10 '12 at 08:26
  • 1
    @delnan: Thanks for the insight at V8. Thus, JS is not a purely interpreted language. – netemp Mar 28 '12 at 14:14
  • 2
    Rhino JavaScript Compiler. You know, if you want your interpreted language to be interpreted by a different interpreted language. – Trevor Hickey Jun 05 '14 at 03:10
  • Spidermonkey and Trident both use JIT compilers for JavaScript in the browser as well. – bigtunacan Jul 17 '15 at 16:56
  • "JavaScript is interpreted at runtime by the client browser". No, unless you're talking about some personal browser you wrote that uses an interpreter. – Abhinav Gauniyal Sep 25 '16 at 13:00
  • 1
    As others have said, this has no longer been true for some time now. Yes, in the *early days* you could say Javascript was interpreted, but it has come a *very long way* since then. – John Weisz Oct 31 '16 at 10:11
  • Javascript is compiled by v8 engine using JIT compiler. The difference between v8 compiler and c/c++ compiler is that v8 doesn't create intermediate bytecodes. – Prem May 08 '18 at 17:05