[net.lang.ada] What language do you use for scientific programming?

joe@petsd.UUCP (Joe Orost) (08/26/85)

As an Ada implementer, I just want to correct some technical issues in the
following article:

In article <64500002@hpislb.UUCP> gore@hpisla.UUCP (Jacob Gore) writes:
>
>Ada is quite similar to Pascal and Modula-2.  It does have double-precision
>real types.  In fact, you can pretty much specify arbitrary precision, as
>long as you keep in mind that your program will run faster if there is a
>hardware data type in your machine that can support the precision that you
>asked for (otherwise, you could be executing lots of simulation code).

No simulation code is ever required.  Ada allows operations to be performed
with more precision than the user requested.  Therefore, all operations are
done with the next better floating point type in the machine.  The
"predefined types" of the implementation should correspond with supported
types on the machine.

In addition, fixed point types are defined in the language to allow
representation of fractions on machines that have no floating point
hardware.

>
>Ada follows the philosophy that anything that can be safely put into a
>library should not be a burden to the compiler.  Following this philosophy,
>I/O is not "built into the language" (which usually means that I/O routines
>are in the library anyway, but the compiler has to parse calls to those
>routines differently from calls to user-written routines).  DoD (who set
>the requirements for the language) does require provision of library
>routines that do minimal I/O, in the manner similar to that of Modula-2,
>but slightly more convenient.

No, the compiler doesn't parse I/O calls differently than non-I/O calls.

>
>  (4) Ability to pass parameters by name (instead of just their
>      relative positions within the call) or not to pass them at all.
>      Many statistical library routines have a dozen or two of
>      arguments, most of which the user wants to default to their usual
>      values.  In most languages, the best way to do this is to pass
>      some agreed-upon value, usually 0, which will be replaced with
>      the default value by the routine.  So the call might look like
>
>	CALL FUNFNC (1985, 34, 0,0,0,0,0, -23, 0,0,0,0, 1, 0,0,0,0,0,0)
>      
>      In Ada, it would like this:
>
>	FUNNY_FUCNTION (YEAR:=1985, DISTRICT:=34,
>			PENALTY:=-23, COEFFICIENT:=1);
>
>      The order of the parameters, when passed by name, does not
>      matter.

The correct syntax is:
	FUNNY_FUNCTION (YEAR => 1985,   DISTRICT => 34,
			PENALTY => -23, COEFFICIENT => 1);

>      
>      If you were a customer, which statement would you prefer to use?
>      Well, if you do want to pass values for most of the parameters,
>      you might prefer memorizing their positions to spelling out the
>      name for each of them.  But even that is easier to do in Ada:
>
>	FUNNY_FUNCTION (1985, 34, ,,,,, -23, ,,,, 1, ,,,,,);
>
>      And there is no confusion over which parameter gets the default
>      value, and which actually gets the value of zero!

Ada does not allow this!


All in all, I agree with you in selecting Ada as your language of choice.
Unlike C, however, an efficient Ada program requires a damn-good optimizing
compiler.  This is good for programmers, because they can concentrate on the
algorithm, rather than on an efficient implementation.

				regards,
				joe

--

 ........        .........	Full-Name:  Joseph M. Orost
 .       .       .		UUCP:       ihnp4!vax135!petsd!joe
 . ......   ...  ........	ARPA:	    vax135!petsd!joe@BERKELEY
 .               .		Phone:      (201) 758-7284
 .               .........	Location:   40 19'49" N / 74 04'37" W
				US Mail:    MS 313; Perkin-Elmer; 106 Apple St
					    Tinton Falls, NJ 07724

macrakis@harvard.ARPA (Stavros Macrakis) (08/27/85)

> >[Ada] does have double-precision real.... you can ... specify
> >arbitrary precision, [but if there's no appropriate] hardware data
> >type,... you could be executing... simulation code).
> 
> No simulation code is ever required.  Ada allows operations to be
> performed with more precision than the user requested.  Therefore,
> all operations are done with the next better floating point type in
> the machine.  The "predefined types" of the implementation should
> correspond with supported types on the machine.

These two notes appear to be talking to to different issues: run-time
calculations in floating types, and calculation of `universal numbers'
at compile time.

Ada allows <specification> of the precision of floating types.  An
implementation chooses which precisions it supports, and must give an
error if a program specifies a precision it does not support.
Implementations are required to support at least one floating
precision.  Precisions are specifed by number of digits rather than
as `single' or `double' precision, increasing portability.

As for compile-time constants (`universal numbers'): "The accuracy of
the evaluation of [such numbers] is at least as good as that of the
most accurate predefined floating point type...." [Ada RM 4.10/4]
Earlier versions of Ada did apparently require arbitrary-precision
arithmetic at compile time (but never at run time).

Of course, if you want run-time multiple precision, you are free to
implement it in a package and use overloading to call its operations
`+', `*', etc.  This holds true for vector-matrix, complex, and other
types as well.

> All in all, I agree with you in selecting Ada as your language of
> choice.  Unlike C, however, an efficient Ada program requires a
> damn-good optimizing compiler.	-- Joe Orost

I also agree.  Choose Ada for numeric calculations.  This year's crop
of compilers finally seems to be fulfilling Ada's promise.

	-s