Compiled vs. Interpreted Languages
Programming languages generally fall into one of two categories: Compiled or Interpreted. With a compiled language, code you enter is reduced to a set of machine-specific instructions before being saved as an executable file. With interpreted languages, the code is saved in the same format that you entered. Compiled programs generally run faster than interpreted ones because interpreted programs must be reduced to machine instructions at runtime. However, with an interpreted language you can do things that cannot be done in a compiled language. For example, interpreted programs can modify themselves by adding or changing functions at runtime. It is also usually easier to develop applications in an interpreted environment because you don't have to recompile your application each time you want to test a small section.
So, which is DScript, compiled or interpreted? Actually, DScript is both. When you enter definitions in DScript, they are immediately reduced to a set of basic primitives. If you enter
DScript reduces this to
The original code you enter is discarded and only this simplified code is saved. When you open a saved application and view its node definitions, DScript decompiles the simplified code to generate a presentation that is similar to the code you originally entered.
When you execute an application, DScript interprets the reduced code at runtime. Therefore, DScript is partly an interpreted language. However, code is interpreted only the first time it is executed. Every time after that, the compiled code is executed.
For example, consider the following loop:
for(var n=0; n<1000; n++)
In executing this code, each separate expression will be evaluated 1000 times. However, DScript will interpret the code only on the first iteration and use the compiled code for the remaining 999 iterations. Since virtually all CPU time a program consumes is used inside loops, this execution strategy significantly improves performance while maintaining the flexibility of an interpreted language.