Re: A Few Noob Questions [message #175170 is a reply to message #175164] |
Thu, 18 August 2011 17:44 |
A.Reader
Messages: 15 Registered: December 2010
Karma:
|
Junior Member |
|
|
On Fri, 19 Aug 2011 00:40:26 +0800,
Man-wai Chang <toylet(dot)toylet(at)gmail(dot)com> wrote:
>>> In the old days, "Programs" were compiled into binary codes for direct
>>> execution by the CPU. "Scripts" were not compiled, but interpreted by a
>>> program called intepreter.
>>
>> Contrary to popular belief, scripts, i. e. programs written in a scripting
>> language, are compiled, too. They are *JIT-compiled* *at runtime*.
>
> Is this real compilation? :)
How do you define "real compilation"?
The principle of compilation, as of assembly, is translate once
(because translation is slow and was costly), and ever after just
run the product of the assembly/compilation process.
So, given that definition, compiling to p(seudo)-code is just as
much compilation as compiling to machine code.
Only the execution environment is different: pcode runs on a
pmachine, a virtual chip implemented in software rather than
hardware and thus potentially able to be run on any hardware to
which that pmachine has been ported. Machine code runs directly
on the hardware -- but only the specific type of hardware for
which it was written. Machine-code programs are fast, pcode
programs are slower, source-interpreted programs are slowest.
PHP, like Java, JavaScript, and quite a few other languages,
compiles to pcode, and the programs run on a pmachine.
>
>> PHP 4+ scripts are compiled by the Zend Engine (a virtual machine, currently
>> Zend Engine II), to Zend Opcode, a platform-independent byte code (much like
>> with Java). That byte code is interpreted by that VM.
>
> So is PHP still a script?
Of course you can call a php program a "script" if you like, but
the traditional name for any coherent, task-oriented set of
computer instructions, regardless of how or whether they are
compiled, is "program".
I've never seen the point of inventing new names for existing
concepts; all it seems to do is add confusion. But some people
profit from confusion, so I'm sure that explains at least part of
it.
|
|
|