|Execution of a program in scripting language? email@example.com (Peng Yu) (2010-01-18)|
|Re: Execution of a program in scripting language? firstname.lastname@example.org (Tony Finch) (2010-01-19)|
|Re: Execution of a program in scripting language? email@example.com (Robin Holmes) (2010-01-20)|
|Re: Execution of a program in scripting language? firstname.lastname@example.org (BGB / cr88192) (2010-01-21)|
|Re: Execution of a program in scripting language? email@example.com (2010-01-21)|
|Re: Execution of a program in scripting language? firstname.lastname@example.org (kamal) (2010-02-08)|
|Re: Execution of a program in scripting language? email@example.com (glen herrmannsfeldt) (2010-02-10)|
|Date:||Mon, 8 Feb 2010 02:25:46 -0800 (PST)|
|Posted-Date:||10 Feb 2010 11:02:55 EST|
On Jan 18, 8:23 pm, Peng Yu <pengyu...@gmail.com> wrote:
> I'm looking for some references on how a scripting program run so that
> I can understand the runtime behavior better. But I don't find such a
> reference. For example, I checked Programming Language Pragmatics by
> Michael L. Scott. It seems only mentioned the programming language
> that needs compilation.
> Could somebody pointing me some reference on how a script is executed
> so that I can understand the runtime behavior better?
a shell script is typically interpreted line-by-line by the
interpreter. the first line
in a script will say that /usr/bin/sh is the interpreter that needs
to be executed to interpret the contents of this script -1 line at a
time starting from the top. The interpreter usually maintains a list
of global variables which one can modify withina script. The command-
line arguments get stored in special variables which a script can
access. Initially scripts were premitive in nature i.e. not-procedural
in nature, but over time all of the facilities of a procedural
language were added to them. The most powerful interpreter that I know
of is perl -which will do a lot of things almost as well as C can do
with v few trade-offs.
> Also, why the compiled code in java and perl are in general slower
> than the equivalent code in C or C++?
As regards java, the output of compling a java program is a byte-code -
which needs to be translated to machine code (that is not known at the
time the code is compiled). So, you could compile java on x86 and run
it on sparc and the JVM will map the bytecode to sparc when it is
actually run. There is also something called JIT which will speed this
up by compiling the bytecode to machine code the first time you run
it. Also, memory management in java requires the VM to be present as
in execute while a java bytecode is executed. In contrast -the C
runtime doesn't do much activity when a C program is running.
Perl has lots of pre-compiled libraries (as efficient as C) and the
user-generated compiled perl code isn't exactly inefficient by a huge
factor. The memory management within perl also requires a lot more
work at runtime. There are no lists in C to manage, and if you were to
use STL instead of perl lists -I think you will find it equally slow.
Return to the
Search the comp.compilers archives again.