Re: what is difference in C prog and shell prog?
From: Josef Moellers (josef.moellers_at_fujitsu-siemens.com)
Date: 08/24/05
- Next message: Kasper Dupont: "Re: what is difference in C prog and shell prog?"
- Previous message: rahul8143_at_gmail.com: "what is difference in C prog and shell prog?"
- In reply to: rahul8143_at_gmail.com: "what is difference in C prog and shell prog?"
- Next in thread: Kasper Dupont: "Re: what is difference in C prog and shell prog?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 24 Aug 2005 09:10:26 +0200
rahul8143@gmail.com wrote:
> hello,
> i want to know what is difference between C prog. and shell
> prog.? which is richer in functionality, speed on linux OS?
> regards,
A C program is written in C, then compiled into machine language and
then run.
A shell script (they are not usually referred to as programs) is
interpreted by the shell every time it is run, even each statement is
interpreted every time it is seen during interpretation of the script as
a whole (other interpreters might keep some intermediate form of
statements already handled to speed up execution).
The functionality of a C program is limited only by the functions
provided by the underlying operating system kernel (the remaining
functionality is provided by some libraries which are usually written in
C, too, so the use of these could be precluded by including the relevant
functions in your C program), while a shell script actually only adds
some flow control and some variable handling but for the rest has to
rely on the utilities available on the system.
Although a C program can be written to be highly portable, the compiled
program will run on only a certain class of machine (a program compiled
for an Intel CPU will not run on a PowerPC), sometimes even restricted
to a (certain flavour of) OS (a program compiled for Linux will
definitely not run on Windows) while shell scripts will run on any
machine that has the shell and the commands used by the script.
From a theoretic point of view, you could (probably) rewrite any C
program as a shell script (there is a theorem postulated by someone,
Alonso Church?, that claims this), but it would be quite clumsy and run
orders of magnitude slower.
-- Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize -- T. Pratchett
- Next message: Kasper Dupont: "Re: what is difference in C prog and shell prog?"
- Previous message: rahul8143_at_gmail.com: "what is difference in C prog and shell prog?"
- In reply to: rahul8143_at_gmail.com: "what is difference in C prog and shell prog?"
- Next in thread: Kasper Dupont: "Re: what is difference in C prog and shell prog?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|