From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,HK_RANDOM_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1094ba,9f0bf354542633fd X-Google-Attributes: gid1094ba,public X-Google-Thread: 103376,d901a50a5adfec3c X-Google-Attributes: gid103376,public From: bglbv@my-dejanews.com Subject: Re: Fortran or Ada? Date: 1998/09/23 Message-ID: <6uan3f$7qe$1@nnrp1.dejanews.com> X-Deja-AN: 393953194 References: <36068E73.F0398C54@meca.polymtl.ca> X-Http-Proxy: 1.1 x1.dejanews.com:80 (Squid/1.1.22) for client 130.225.238.253 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Sep 23 11:46:55 1998 GMT Newsgroups: comp.lang.fortran,comp.lang.ada X-Http-User-Agent: Mozilla/5.0b1 [en] (X11; ; IRIX64 6.4 IP27; Nav) Date: 1998-09-23T00:00:00+00:00 List-Id: gisle@krake.ii.uib.no (Gisle S{lensminde) wrote: [lots of good remarks, I'll only correct a few factual errors and add a few glosses of my own] [> > lines are by Siamak Kaveh] > > 2. Packages and types can be made generic (parameterized through a > > template) to help create reusable components. > > That is also in Fortran 90/95 AFAIK. No, unfortunately Fortran 90/95 does not even have parameterized derived types (Ada: record types with discriminants), much less generic subprograms and modules. The parameterized derived types are scheduled for Fortran 2000, I believe, but generics aren't (and this fact has been bemoaned recently in comp.lang.fortran; see postings by William Clodius on this subject, as well as his papers in the J3 archive repository). > > 3. Errors can be signaled as exceptions and handled explicitly. Many > > serious errors (such as computational overflow and invalid array > > indexes) are automatically caught and handled through this exception > > mechanism, improving program reliability. > > Yes, and this detects many errors, but I think some Fortran 90 compilers > also checks indexes, if you ask them to do so. Maybe not as good > as Ada. The main difference is that Fortran does not have a good exception handling mechanism. Some drafts of Fortran 8X did have one along the lines of Ada's facilities, but it was left out of the final standard. (Don't ask me why; the ultimate answer is political, in the form of "couldn't get enough votes in favour". There are also some objective technical difficulties, though Ada's example suggests that these can be overcome.) Among other things, an Ada-like exception mechanism in Fortran would provide the ability to recover from errors in allocating storage for automatic variables, compiler-generated temporaries, etc. Currently, one can recover from errors in explicitly coded ALLOCATE statements by using the STAT= keyword (and even then, only if the error is immediately apparent at the time of allocation; problems due to overcommitting swap space may still cause the program to crash unpredictably later on) but not from much else. > > 4. Tasks (multiple parallel threads of control) can be created and > > communicate. This is a major capability not supported in a standard way > > by many other languages. > > Yes ... although perhaps it is worth mentioning the Fortran binding to the Message Passing Interface (MPI) standard. > > 6.A predefined library is included; it provides input/output (I/O), > > string manipulation, numeric functions, a command line interface, and a > > random number generator (the last two were available in Ada 83, but are > > standardized in Ada 95). Note that Fortran 90/95 provides most of these facilities. There is a command line interface proposal in the current Fortran 2000 draft. What Fortran does not provide is direct language support for fixed-point types (you have to implement them yourself, usually but not necessarily with integers). > > 2) Is there any comparison between performance of Fortran90/95 and Ada95 > > compilers? > It is difficult to compare two different languages in a fair way. For > example > Ada has index checking and exception handling wich Fortran doesn't. > You can of cause turn off these, but it's often valuable to use them, > becase they trap bugs on an early stage, and makes the code more > reliable Such features has a performance penalty. I seem to recall there is some debate over whether exception handling need entail a performance penalty when no exceptions are actually raised. (Of course fragmenting the code into very small blocks may prevent the optimizer from changing the order of execution.) It goes without saying that a fair comparison would be between codes that use equivalent features of both languages. That is, one would either turn bounds checking on or off in both compilers. And the Ada code might use exceptions only where Fortran has alternate returns or ERR=/END=/EOR= branches. > But if we write comparable code in both languages, I would think that > Fortran would win in a raw speed test, because some of the Fortran > compilers optimize extremly well. In other words, Fortran wins because the Fortran compilers currently on the market are generally better at optimizing numerically intensive code than the available Ada compilers. It would still be nice to produce a few benchmarks (no, not TEST_FPU, please; though TEST_FPU might actually be more useful for this purpose than for comparing hardware platforms) to test this very plausible but I think unconfirmed statement. > C++ disqualifies from critical code for several reasons. Things like > pointers and pointer aritmetrics and the possibility to cast everything to > everything, makes the language unsafe. Many such systems must Well, Ada also has Unchecked_Conversion if you feel so inclined. It's use is just easier to review. > have total control of memory usage, and no dynamic memory usage is > allowed in many cases, and makes C and C++ is impossible to use in the > highest safity levels. (But C is used in some safity critical stuff > anyway, and C is widely used for embedded targets.) > > Fortran do not have all the weakneses of C this respect, but is still See my remarks above about recovering from memory allocation problems in Fortran. Also remember that the design and testing methodology often counts for more than the language itself. Ariane 501 was lost due to a bug in Ada code. (My understanding is that it was an error in the specification; that the code happened to be written in Ada was not particularly significant.) -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum