|
-
Oct 23rd, 2002, 05:18 AM
#1
Thread Starter
Fanatic Member
Unix Shell programming Vs. C programming (which is better?)
While dealing with Unix text files, I found that a lot of people prefer file manipulation writing shell scripts rather than processing using C.
My question is that, what is more efficient, shell programming or C programming?
A C program, when run compiled, works as single process, but every shell command is a process, doesn't it mean that C code is more efficient?
Thanks for any help :-)
Life is a one way journey, not a destination. Travel it with a smile and never regret anything.
Yesterday is history, tomorrow is a mystery, today is gift - that's why we call it present.
-
Oct 23rd, 2002, 06:30 AM
#2
Monday Morning Lunatic
C programming, definitely.
Although it depends what you define as "efficient". If you want to do an operation on ten million rows of a text file, C will be much faster. However, it'll take you longer to write, so in total, a shell script might be faster.
A lot of shell commands are implemented as shell builtins, so they won't spawn another process.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 23rd, 2002, 06:54 AM
#3
Frenzied Member
Also depends on the shell what is available or builtin.
Yesterday, someone needed 380,000 addresses, RIGHT NOW.
I wrote a perl script. Consider learning perl.
Efficiency is in the eye of the beholder. Compiled C is faster, but for a one-up of 40 pages of text, who cares?. If it is run 1000 times a day, use perl, C, FORTRAN, whatever. Not script.
Actually, real efficiency is cost-based. It it more expensive to have a user wait 5 seconds vs ten seconds or more efficeint to pay a programmer to work an extra hour? Depends on your shop.
Are you running the smallest unix box avaialble with 500 users? Then pay the programmer.
-
Oct 23rd, 2002, 07:07 AM
#4
Thread Starter
Fanatic Member
Yes, I agree that efficiency depends on the particular problem.
However, another advantage of using C is that, if the applications ever need to be ported to some different platform say, Windows form Unix, then changing C source code will be much easier than re-writing shell scripts.
Life is a one way journey, not a destination. Travel it with a smile and never regret anything.
Yesterday is history, tomorrow is a mystery, today is gift - that's why we call it present.
-
Oct 23rd, 2002, 07:09 AM
#5
Monday Morning Lunatic
Not necessarily. A lot of things rely on POSIX features which Windows has a very poor implementation of.
Plus, you can just run the shell program on Windows (Cygwin can do both of these, though).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 23rd, 2002, 03:53 PM
#6
Not everyone wants to install cygwin on their windows computer.
Give the programmer a little more time and he should be able to write the app in a completly portable way.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|