comp.lang.ada
 help / color / mirror / Atom feed
From: blaak@infomatch.com
Subject: Re: scripting/extension language for Ada (was : Re: tagged types extensions)
Date: 2000/02/05
Date: 2000-02-05T00:00:00+00:00	[thread overview]
Message-ID: <87gvdl$qsp$1@nnrp1.deja.com> (raw)
In-Reply-To: wcc4sborclg.fsf@world.std.com



Robert A Duff <bobduff@world.std.com> wrote:
> Ray Blaak <blaak@infomatch.com> writes:
> > Scripting languages, on the other hand, tend to be used for
> > small, quickly written programs, and good ones tend to have a
> > succinct powerful notation.
>
> I've seen way too much long-lived software written in Perl,
> csh, awk, make, etc.

There is always room for a better language. Is Ada right for a
scripting language, though?

> Anyway, "quickly written" is irrelevant.  The only time it can
> possibly make sense to use languages that are difficult to
> maintain is when you're going to quickly throw away the code
> after writing it.

Nobody (at least not me) is advocating the use of scripting
languages that are difficult to maintain.

The usefulness of a good scripting language is that it is well
designed for invoking OS services (expressing the piping of a
chain of processes, for example), interactive and easy to debug,
and tends to have small programs.  E.g. a few K at most for a
reasonably complex script -- that's it! No build steps, object
files, link times. Just run it.

One tends to use scripting languages to implement small little
tasks (munge a few files, spit out some email, walk a few
websites,...)

Scripting languages should encourage programs that are easy to
write, easy to understand, and easy to change.

Most scripting languages are atrocious (esp. sh and
friends). They don't have to be.

What I like about scsh is that one has a real programming
language (Scheme) focused on tasks such that the limitations of
Scheme don't apply (i.e. the lack of a module or package system
for programming "in the large").

Now Ada is a fine language, and my language of choice for real
software systems. The problem with Ada for scripting purposes,
however, is that there is too much declarative infrastructure
needed to do simple tasks. Ada's strong static typing requires
ones abstractions to be carefully specified. Dynamic typing in a
scripting language, on the other hand, allows one to just "whip
off" a solution, and yet still have strong type checking for good
runtime error detection.

Consider this scsh snippet:

  ;; Mail myself files matching some criteria
  (with-cwd "~/myfiles"
    (for-each (lambda (file)
                (if (run (grep "some pattern" ,file))
                    (run (mail -s "found it" blaak@home) (< ,file))))
              (directory-files)))

Boom! That's it. A few lines and the job is done.

The equivalent Ada, even assuming a reasonable high-level API to
OS services, is more tedious to set up. Perhaps:

  with AdaScript; use AdaScript;
  program Main is
    files : FileList := DirectoryFilesOf("~/myfiles");
  begin
    for i in FirstOf(files) .. LastOf(files) loop
      if Run (("grep", "some pattern", FileNameAt(files, i)))
         = Success
      then
        Run (Args => ("mail", "-s", "found it", "blaak@home"),
             Stdin => FileAt(files, i));
      end if;
    end loop;
  end;

Not too bad, but a little noisy. Or perhaps:

  with AdaScript; use AdaScript;
  package ThisJob is
    -- Objects (tagged types) can only be declared in packages. Pain
pain!
    type FileVisitor is new AdaScript.FileVisitor;

    procedure Visit
      (withVisitor : in out FileVisitor; theFile : in out File);
  end ThisJob;

  package body ThisJob is
    procedure Visit
      (withVisitor : in out FileVisitor; theFile : in out File) is
    begin
      if Run (("grep", "some pattern", FileNameOf(theFile)))
         = Success
      then
        Run (Args => ("mail", "-s", "found it", "blaak@home"),
             Stdin => theFile);
      end if;
    end;
  end ThisJob;

  with AdaScript; use AdaScript;
  with ThisJob;
  program Main is
    visitor : ThisJob.FileVisitor;
    files : FileList := DirectoryFilesOf("~/myfiles");
  begin
    Traverse(files, withVisitor => visitor); -- dispatches on visitor
  end;

The latter example I include to show the tediousness of setting
up a mapping function in Ada. In a real system, tedious
declarations are lost in the noise of the actual solution. Also,
in a real system, the declarations give much valuable information
to the compiler, allowing for good error checking and efficient
code generation.  In a real system I am a firm believer in
tedious declarations.

In the kinds of programs one needs scripting languages for,
however, these declarations will often tend to dominate, and just
make things, well, tedious.

In short: Ada is too much of a general purpose language to serve
as a scripting language. Use one designed for the purpose.

Cheers,                                        The Rhythm is around me,
                                               The Rhythm has control.
Ray Blaak                                      The Rhythm is inside me,
blaak@infomatch.com                            The Rhythm has my soul.


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-02-05  0:00 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-27  0:00 tagged types extensions - language design question Vladimir Olensky
2000-01-27  0:00 ` Fraser
2000-01-27  0:00 ` Matthew Heaney
2000-01-27  0:00   ` Charles Hixson
2000-01-28  0:00   ` Vladimir Olensky
2000-01-28  0:00     ` Matthew Heaney
2000-01-28  0:00       ` Charles Hixson
2000-01-28  0:00         ` Matthew Heaney
2000-02-01  0:00           ` Charles Hixson
2000-02-01  0:00             ` Matthew Heaney
2000-01-29  0:00       ` Vladimir Olensky
2000-01-29  0:00         ` Matthew Heaney
2000-01-29  0:00         ` Matthew Heaney
2000-01-31  0:00           ` Vladimir Olensky
2000-01-31  0:00             ` Matthew Heaney
2000-01-31  0:00               ` Vladimir Olensky
2000-01-27  0:00 ` Laurent Guerby
2000-01-28  0:00   ` Vladimir Olensky
2000-01-28  0:00     ` Andy
2000-01-28  0:00       ` Vladimir Olensky
2000-01-29  0:00         ` Andy
2000-01-31  0:00           ` Vladimir Olensky
2000-01-28  0:00 ` Tucker Taft
2000-01-31  0:00   ` Vladimir Olensky
2000-02-01  0:00   ` Charles Hixson
2000-02-01  0:00     ` Matthew Heaney
2000-02-01  0:00       ` Brian Rogoff
2000-02-03  0:00         ` scripting/extension language for Ada (was : Re: tagged types extensions) root
2000-02-03  0:00           ` Brian Rogoff
2000-02-04  0:00             ` Ray Blaak
2000-02-04  0:00               ` Stanley R. Allen
2000-02-04  0:00                 ` Samuel T. Harris
2000-02-05  0:00                   ` Lionel Draghi
2000-02-05  0:00                     ` Samuel T. Harris
2000-02-06  0:00                       ` Lionel Draghi
2000-02-06  0:00                       ` Bryce Bardin
2000-02-08  0:00                         ` Samuel T. Harris
2000-02-05  0:00                 ` Lionel Draghi
2000-02-05  0:00                 ` Ray Blaak
2000-02-04  0:00               ` Robert A Duff
2000-02-05  0:00                 ` blaak [this message]
2000-02-05  0:00                   ` Brian Rogoff
2000-02-09  0:00                   ` Robert A Duff
2000-02-09  0:00                     ` Ted Dennison
2000-02-10  0:00                       ` Samuel T. Harris
2000-02-05  0:00                 ` Ehud Lamm
2000-02-10  0:00                 ` Pascal Martin
2000-02-10  0:00                   ` Ray Blaak
2000-02-11  0:00                     ` scripting/extension language for Ada (we have an opportunity here) Tarjei T. Jensen
2000-02-11  0:00                       ` Robert I. Eachus
2000-02-12  0:00                         ` Pascal Martin
2000-02-13  0:00                           ` Robert I. Eachus
2000-02-16  0:00                             ` scripting/extension ... [off topic] Nick Roberts
2000-02-16  0:00                               ` Ray Blaak
2000-02-12  0:00                         ` scripting/extension language for Ada (we have an opportunity here) Tarjei Tj�stheim Jensen
2000-02-12  0:00                           ` root
2000-02-12  0:00                           ` Samuel T. Harris
2000-02-14  0:00                             ` Robert A Duff
2000-02-15  0:00                               ` Samuel T. Harris
2000-02-16  0:00                                 ` Robert A Duff
2000-02-16  0:00                                   ` Samuel T. Harris
2000-02-16  0:00                                     ` Robert A Duff
2000-02-17  0:00                                       ` Samuel T. Harris
2000-02-12  0:00                         ` blaak
2000-02-12  0:00                         ` Samuel T. Harris
2000-02-11  0:00                     ` scripting/extension language for Ada (was : Re: tagged types extensions) David Starner
2000-02-12  0:00                       ` blaak
2000-02-15  0:00                         ` Brian Rogoff
2000-02-12  0:00                       ` Pascal Martin
2000-02-14  0:00                     ` Robert A Duff
2000-02-05  0:00             ` scripting/extension language for Ada (was : Re: tagged typesextensions) Lionel Draghi
2000-02-05  0:00           ` scripting/extension language for Ada (was : Re: tagged types extensions) Ehud Lamm
2000-02-06  0:00             ` Lionel Draghi
2000-02-06  0:00               ` scripting/extension language for Ada Terry Westley
2000-02-06  0:00               ` scripting/extension language for Ada (was : Re: tagged types extensions) Ehud Lamm
2000-02-09  0:00               ` Robert A Duff
2000-01-31  0:00 ` tagged types extensions - language design question Mark Lundquist
2000-02-01  0:00   ` Vladimir Olensky
2000-02-01  0:00   ` Simon Wright
2000-02-01  0:00   ` Ehud Lamm
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox