home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:3744 comp.unix.questions:10622
- Newsgroups: comp.unix.shell,comp.unix.questions
- Path: sparky!uunet!sun-barr!ames!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!casbah.acns.nwu.edu!navarra
- From: navarra@casbah.acns.nwu.edu (John Navarra)
- Subject: Re: Shell Scripts vs. C programs
- Message-ID: <1992Sep1.211515.24741@news.acns.nwu.edu>
- Keywords: shell script, C
- Sender: usenet@news.acns.nwu.edu (Usenet on news.acns)
- Organization: Northwestern University, Evanston Illinois.
- References: <119@steiny.com> <1992Sep1.044434.7193@news.acns.nwu.edu> <121@steiny.com>
- Date: Tue, 1 Sep 1992 21:15:15 GMT
- Lines: 75
-
- In article <121@steiny.com> root@steiny.com (Admin) writes:
- > The shell may be, but the utilities that the shell calls in order
- >to operate are not, thus, shell scripts are non-portable. Believe me,
- >I had to write a distribution package for software that runs on many machines.
- >I eventually had to re-write it in C because the shell was so non-portable.
- >Many other posters to this thread have also had this experience. The
- >only reason that you think that is because you have not had much experience
- >trying to port shell scripts.
-
- Admittedly, I have not had much experience porting complex shell
- scripts across many different architectures. I somewhat agree
- with you in that I wouldn't write really large shell, complex shell scripts
- which would need to be ported to many different architectures -- not
- because I would fear the shell is SO non-portable but that the script
- most likely would run pretty slow.
-
- >
- >>>and they have many other problems.
- >> And translating your C code using compiler X to OS Y is any
- >>easier? Perhaps you are thinking of Csh? Then, yeah, you suck.
- >
- > Are you saying that the shell runs in more environments than
- >C compilers?
-
- No, I am saying that if you take into account various C compilers
- and various OS's which your C program may have to ported to, you,
- especially as a new user, would have MUCHO difficulty accounting for all
- this. However, if you write the same code in a shell script, you can
- be reasonably sure the code will work across many architectures. The
- person who asked this question asked it from a new user standpoint. I
- certainly would not suggest to a new user that he NEVER write large
- shell scripts out of fear of non-portability.
-
- >> Even for long programs, shell scripts can be better. Yes, they
- >>will run slower but if you can saves days, weeks, or months writing
- >>the shell script, which is better then?
- >
- > Why would that be, if you did not know C? Why not use perl? It
- >is supported on more machines than the shell, it has error checking, it
- >is portable, and it so much better than the shell it boggles the mind.
-
- You don't need to convince me that perl is a great alternative. However,
- it simply is not used by as many people who use shell scripts and
- C programs. I find the for simple to moderate tasks, programming in
- the shell is a bit easier than programming in perl. And, if I want to
- let someone use my script, I can be sure it will be of use to them since
- it is written in sh. I cannot be gauranteed that person has perl (or
- wants perl). I also find that programming the shell is MUCH easier than
- programming in C (even with the better error checking in C). If I am
- not ultimately concerned about execution time, the few seconds I save
- with C is not worth the hassle of spending two, three, four times
- the time to write it.
-
- > And has the exact same semantics for all of the commands. In other
- >words, you are not trying to port a shell script from AT&T to BSD.
-
- Hopefully, as things progress, this difference will be reconciled
- and a POSIX standard will prevail. Then, I don't think you will have to
- worry much about that.
-
- > Besides, if you really know C it is as fast to write many things
- >as the shell. For text processing, use perl. The shell stinks as
- >a programming language for anything but short interactive programs.
- >
- I think that I basically argee with you , but you are much harder
- on the shell as a programming language than I.
-
- -tms
-
-
- --
- You can get further with a kind word | You can get further with a kind word
- and a gun than a kind word alone. | and a phaser than a kind word and a gun.
- --al capone | -- John Navarra
- =======From the Lab of the MaD ScIenTIst....navarra@casbah.acns.nwu.edu========
-