[comp.lang.perl] Icon or Perl?

nall@sun8.scri.fsu.edu (John Nall) (07/17/90)

A friend of mine looked at some of the stuff which I was
attempting to do with Perl (involving primarily the manip-
ulation of words) and opined that I could do it with Icon
much easier.

Before I go charging off in a new direction: has anyone
done any comparisons of the two?  (Let me hasten to add
that I'm only talking about processing symbolic data, and
*not* system administration things).  

I've glanced at the Icon book (The Icon Programming Language)
and it looks good.  But my knowledge of how to really get
top performance out of either Perl or Icon is pretty low.  So
the question is whether or not someone who DOEs know how to
do these things has compared the two.




--
John W. Nall		| Supercomputation Computations Research Institute
nall@sun8.scri.fsu.edu  | Florida State University, Tallahassee, FL 32306
     "Los dioses eran computadores.  ?Que otra cosa podian ser??"

merlyn@iwarp.intel.com (Randal Schwartz) (07/17/90)

In article <263@sun13.scri.fsu.edu>, nall@sun8 (John Nall) writes:
| A friend of mine looked at some of the stuff which I was
| attempting to do with Perl (involving primarily the manip-
| ulation of words) and opined that I could do it with Icon
| much easier.

I was an Icon expert, although I'm a bit rusty at it now.  (One of my
contributions made it into the standard library, for example.)

Icon excels at what it was written for... munging strings, lists,
structured data types, and so on.  The I/O was pretty limited to
Pascal-like I/O (we're talking early Pascal here... basically fetch
sequential and store sequential).  It doesn't have regexps, but you
can build them *very* easily.

Perl excels at what it was written for... except we are still trying
to figure out what that is. :-) But seriously, Perl has some of the
hackery of attacking and munging strings and simple lists down pretty
well.  Structured data (as someone pointed out a few weeks ago) has to
be handled by forcing the data to be viewed a string or a list.  Perl
has about a third of Icon's string-handling capability, about the same
control structures (OK, so there's no equivalent to generators or
failing expressions), and about three times the amount of I/O and
process management.

IMHO, of course. :-)

They're both good at separate tasks.  I haven't had time or motivation
to fire up Icon on my current "day job", but have occasionaly noted
that "this part would be better in Icon".  I have never said that
about an entire task... just some crafty (crufty? :-) text
manipulation or structured data mangling.  Overall, for hacking away
at data inside a UNIX environment, if I was stuck with one tool, I'd
pick Perl over Icon.  (And not because I am now Perl adept... I've
really had time to play with both on a fair basis.)

A true toolsmith can use a both a Swiss Army Chainsaw and a
Sledge-o-matic, however, so I'd recommend learning both.  I find
myself sometimes thinking Icon-like while writing Perl, and I come up
with some new idiom to express some particular trick in a
straightforward way.  You can never learn too many computer languages.
(I list over 50 on my resume now.)

Just another Swiss Army Chainsaw Wielder,
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/

worley@compass.com (Dale Worley) (07/19/90)

   X-Name: Randal Schwartz

   Icon excels at what it was written for... munging strings, lists,
   structured data types, and so on.

One major feature is that Icon directly handles "backtrack and retry"
types of control flow, which is a real pain to code in a language that
doesn't have it built in.  Icon uses this to provide a truly awesome
pattern matching facility (much more general than regexps).  It can
also be used to provide a short and clear program to exhaustively
solve the "eight queens" problem.

Interestingly, both Perl and Icon by default pattern match against a
string supplied by the context.  In Perl, it's $_, in Icon, it is
declared by an operator (which I forget at the moment).

For you language hackers, Icon can be directly translated into Scheme
(pass around continuations to record resume points in operations that
can be resumed).  I don't think any less general control flow
mechanism can translate Icon directly.

Dale Worley		Compass, Inc.			worley@compass.com
--
Klein bottle for sale ... inquire within.