[Fwd: Re: [Discuss] Interpreters vs Compilers]

John Blomfield jabfield at shaw.ca
Thu Mar 13 16:23:01 PDT 2008


pw wrote:
> John Blomfield wrote:
>>
>> I don't have anything more authoritative to add than I did last 
>> night, except to say again, that Python and Java for example compile 
>> their source code into "bytecode" which is slightly optimized code 
>> but it is not machine code. A byte code file still has to be 
>> interpreted, which means translated into machine code instructions 
>> line by line by the so called "Virtual Machine".  Each platform needs 
>> the Virtual Machine running to run a bytecode file.  In the case of a 
>> loop, the loop is in bytecode and must be interpreted line by line 
>> every time through the loop, into possibly many many machine 
>> instructions.  In the case of a compiled C program the binary is in 
>> machine instructions that the CPU understands without interpretation, 
>> hence the speed.  The optimization in C is very very good, so good 
>> that it is almost impossible for the average programmer to do better 
>> using Assembler.  I once did some programming of micro-controllers, 
>> which are quite slow compared to the typical PC, in both Microchip 
>> Assembler and Microchip C and the C compiler always won.  This one of 
>> the reasons most hardware is programmed in C, including Linux and 
>> Python I think.  Python certainly uses a lot of built in mathematical 
>> functions that are written in C to help speed its execution.
>>
>> Its all a question of horses for courses!  Scripting languages like 
>> Perl and Python are often referred to as the "glue" that sticks the C 
>> and C++ modules together.  So if you want Zoom Zoom go C!
>>
>> John Blomfield
>
> byte code is a type of pseudo machine code.
> This code is run in a virtual machine much like
> emulating the operation of a microprocessor.
>
> The java virtual machine, for example, is merely a
> microprocessor/toolkit  architecture that has been defined
> to use a machine language of java byte code. The virtual machine
> is compiled for various computers to provide java system emulation.
>
> The speed of this emulation is related to the optimizations built
> into the virtual machine as compiled for your particular system.
>
> (ie: system meaning I86 or PPC or sparc or etc..)
>
> Hence, the byte code process is not exactly akin to
> 'interpretation'. The interpretation has already been
> done in the compilation from source code to byte code.
>
> In theory byte code processing can be as fast as
> machine code since the virtual machine can directly
> transfer the values of byte code to applicable machine
> level instructions prior to running the application,
> thus running the application in 'native' machine code.
>
Are you saying that the Python Virtual Machine reads all the pyc 
bytecode file and converts it to binary and then runs it?  If so this is 
contrary to my understanding.  About Java I am not sure.
 John

> Peter
>
>
> _______________________________________________
> Discuss mailing list
> Discuss at vlug.org
> http://ladybug.vlug.org/cgi-bin/mailman/listinfo/discuss
>



More information about the Discuss mailing list