[comp.software-eng] grep vs. SEARCH

igp@camcon.co.uk (Ian Phillipps) (04/21/89)

session@uncw.UUCP (Zack Sessions) writes:

>I am very familiar with SEARCH, and have read the manual page on grep
>in preparation of porting it to OS9. I didn't see anything in grep that
>SEARCH couldn't do. Did I miss something?

Well, there are these quite useful things called regular expressions.

How do you tell SEARCH to search for the equivalent of

egrep '^[a-z0-9_]([a-z_0-9]*[ 	])*([a-z_0-9]+)[ 	]*\([a-z_0-9 	,]*\)[ 	]*{?[ 	]*(\/\*.*)?$' "$@"

which locates (sanely laid out) C procedure definitions?
(The r.e.s in grep would be a little different, but I had the egrep version to
hand)

(Sorry if the mailer garbles this - the spaces in the square brackets really
mean "any whitespace" which vanilla [ef]+grep doesn't support directly.)
-- 
UUCP:  igp@camcon.co.uk   | Cambridge Consultants Ltd  |  Ian Phillipps
or:    igp@camcon.uucp    | Science Park, Milton Road  |-----------------
Phone: +44 223 420024     | Cambridge CB4 4DW, England |

rsd@sei.cmu.edu (Richard S D'Ippolito) (04/21/89)

In article <2797@titan.camcon.co.uk> igp@camcon.co.uk (Ian Phillipps) writes:

>How do you tell SEARCH to search for the equivalent of
> [line deleted]
>which locates (sanely laid out) C procedure definitions?

This is getting a bit out of hand.  Software engineering inplies a different
way of thinking about code and procedures.  Without getting into the the
question of whether one even tries to engineer software in "C", why would
your software be so disorganized that you'd even need to do such a thing?
Why do you accept a development platform that requires such tools?

It's asking the masons to make the bricks from mud and straw at the job
site, like the old days.

Rich

-- 
---------------------------------------------------------------------------
Ideas have consequences.                                    RSD@sei.cmu.edu
Richard Weaver
---------------------------------------------------------------------------

perry@apollo.COM (Jim Perry) (04/21/89)

In article <2797@titan.camcon.co.uk> igp@camcon.co.uk (Ian Phillipps) writes:
>
>egrep '^[a-z0-9_]([a-z_0-9]*[ 	])*([a-z_0-9]+)[ 	]*\([a-z_0-9 	,]*\)[ 	]*{?[ 	]*(\/\*.*)?$' "$@"
>
This was great, but you left out the :-).

Seriously, why do these discussions always come down to trying to compare
two systems (grep/search, vms/unix...) as if there were a binary answer to
which is better?  How about acknowledging that we've still got a long way
to go in this business and comparing good and bad features for the next
spin?  (If you think the above incantation is the best, or even a good and
useful, way of finding C function definitions, nevermind).  
-- 
Jim Perry   perry@apollo.com    Apollo Computer, Chelmsford MA
This particularly rapid unintelligible patter isn't generally heard
and if it is it doesn't matter.

ech@pegasus.ATT.COM (Edward C Horvath) (04/21/89)

In article <2797@titan.camcon.co.uk> igp@camcon.co.uk (Ian Phillipps) writes:
>How do you tell SEARCH to search for ... C procedure definitions?

From article <3210@ae.sei.cmu.edu>, by rsd@sei.cmu.edu (Richard S D'Ippolito):
> ...Without getting into the the
> question of whether one even tries to engineer software in "C", why would
> your software be so disorganized that you'd even need to do such a thing?
> Why do you accept a development platform that requires such tools?

Amazing.  You managed to miss the point and demonstrate your callousness
at the same time.  Grow up, and listen up:

In any given environment, one may have occasion to search for strings which
do NOT correspond to entities directly supported by that environment.
When that occasion arises, you may want the power of a regular-expression
matcher.

=Ned Horvath=

Disclaimer: I don't speak for the company, I'm just speaking my mind.

leichter@CS.YALE.EDU (Jerry Leichter (LEICHTER-JERRY@CS.YALE.EDU)) (04/23/89)

The thing that is so silly about this debate is that it misses the obvious
answer:  When I want to search for simple text strings on VMS, I use SEARCH;
it's fast and has some nice features (like marking the found string in reverse
video and displaying some context around it if I want that).  When I want to
search for regular expressions, I use grep.  What, grep on a VMS system?
Sure; I've had it on every VMS system I've used since V2.3 or so, and before
that I used it on RSTS and RSX systems.

No, it doesn't happen to come with any of the OS tapes.  But it's available
for a trivial amount - often for nothing - from a variety of sources.  There
are several grep's available from DECUS, plus it's generally easy to port any
of the fancy ones you see distributed for Unix systems.

It happens that grep was written by the original Unix developers and has been
"part of the OS" for a long time.  Many other things on the Unix tapes were
contributed by random hackers over the years.  Because Unix was for years an
academic toy, it was no big deal to dump a bunch of stuff on the tape with
essentially the comment "Use it if you like it, if it doesn't work - that's
your problem".  You can't get away with that if you are selling a commercial
OS - which these days Unix is as much as VMS is.

People's views change very slowly.  For some reason, anything ever stuck on
any Unix tape anywhere is "part of Unix".  Anything posted to the network is
"part of Unix", and demonstrates what a broad library of useful things "come
with Unix".  On the other hand, if it isn't "on the VMS tape", exactly as it
comes from DEC - it's not "part of VMS", and its lack can be used to demon-
strate how "feature poor" VMS is.

If I were to follow similar flawed reasoning with respect to Unix, I could
assert that Unix has no usable FORTRAN or Pascal compiler, and a buggy, non-
optimizing C compiler.  After all, the only compilers that are part of *Unix*,
as opposed to someone's proprietary port to their own hardware, are f77, pc
(or whatever the excuse for a Pascal system is called), and pcc.

							-- Jerry

dhesi@bsu-cs.bsu.edu (Rahul Dhesi) (04/25/89)

In article <58080@yale-celray.yale.UUCP> leichter@CS.YALE.EDU (Jerry Leichter
(LEICHTER-JERRY@CS.YALE.EDU)) writes:
     The thing that is so silly about this debate is that it misses the
     obvious answer...Sure; I've had [grep] on every VMS system I've
     used since V2.3 or so, and before that I used it on RSTS and RSX
     systems

thus making the point that if it's available for VMS from somewhere, it
should not be considered a deficiency in VMS.

If we buy this reasoning, then it is almost meaningless to compare two
operating systems.  For just about anything you want to do, there's a
software package available to do it on your favorite OS.

I don't buy this reasoning.  Jerry Leichter's system may have grep.
But I may want to distribute software that needs grep to run, and I
can't assume the most VMS sites will have it.

Can I reasonably assume that the user will have make ("MMS" on VMS
systems)?  Or must I supply a tedious COM file to do the compilation or
expect the installer to do it by hand?  Can I assume the user has
*some* standard high-level language compiler on his VMS system so I may
write portable software?

These are the questions that matter.

I'm sure you can find UNIX commands that not every UNIX system has, so
the debate will continue, but please don't use the quoted reasoning to
justify either side of the debate.
-- 
Rahul Dhesi <dhesi@bsu-cs.bsu.edu>
UUCP:    ...!{iuvax,pur-ee}!bsu-cs!dhesi

leichter@CS.YALE.EDU (Jerry Leichter (LEICHTER-JERRY@CS.YALE.EDU)) (04/25/89)

In article <6914@bsu-cs.bsu.edu>, dhesi@bsu-cs.bsu.edu (Rahul Dhesi) writes...
>In article <58080@yale-celray.yale.UUCP> leichter@CS.YALE.EDU (Jerry Leichter
>(LEICHTER-JERRY@CS.YALE.EDU)) writes:
>     The thing that is so silly about this debate is that it misses the
>     obvious answer...Sure; I've had [grep] on every VMS system I've
>     used since V2.3 or so, and before that I used it on RSTS and RSX
>     systems
> 
>thus making the point that if it's available for VMS from somewhere, it
>should not be considered a deficiency in VMS....
> 
>Can I reasonably assume that the user will have make ("MMS" on VMS
>systems)?

Can I reasonably assume that a user on a Unix system has access, somehow, to a
usable Pascal compiler?  Don Knuth made the assumption that Pascal would be
universally available when he developed TeX.  Unix versions of TeX took longer
to arrive and stabilize than those for almost any other system!  Hell, it was
easily available on PC's with good old MSDOS before it could be found for many
Unix systems - and in fact it is available today only because a couple of
people made a major investment of their own time to do WEB2C, which converts
the TeX WEB source to C.

Oh, BTW, can I assume that any Unix system has WEB2C?

The same argument can be made for FORTRAN - and, for that matter, for any
programming language you can name with the exception of C and, to an extent,
C++.  (At least for C++ you know where to get a copy if you want it, even if
you don't have it.)

If you start out designing things in the Unix mold, of course they will be
easily portable to Unix systems, not so easily portable to other systems.
So what?  I can create things for VMS using very handy features - e.g., the
ability to CALL a decent help interface from within my own code and not have
to worry about the details - which no "baseline" Unix system can handle.  I'll
argue that that's as important an ability as the presence of grep on the
standard distribution tape.
							-- Jerry

dhesi@bsu-cs.bsu.edu (Rahul Dhesi) (04/25/89)

In article <58236@yale-celray.yale.UUCP> leichter@CS.YALE.EDU (Jerry Leichter
(LEICHTER-JERRY@CS.YALE.EDU)) writes:
>Can I reasonably assume that a user on a Unix system has access, somehow, to a
>usable Pascal compiler?  Don Knuth made the assumption that Pascal would be
>universally available when he developed TeX.

Knuth made a wrong assumption:  That the use of an otherwise clause in
the case statement was portable.

This has little to do with the UNIX versus VMS debate.  It does have
something to do with how not to write portable code.
-- 
Rahul Dhesi <dhesi@bsu-cs.bsu.edu>
UUCP:    ...!{iuvax,pur-ee}!bsu-cs!dhesi

jeffa@hpmwtd.HP.COM (Jeff Aguilera) (05/03/89)

>>Knuth made a wrong assumption:  That the use of an otherwise clause in
>>the case statement was portable.

    "(Of course, if no default mechanism is available, the case statements
    of TeX will have to be laboriously extended by listing all remaining
    cases.  People who are stuck with such Pascals have, in fact, done this,
    successfully but not happily!)"

            --- Donald Knuth
                "TeX: The Program"

--------
j "is Pascal dead yet?" a