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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c4cb2c432feebd9d X-Google-Thread: 1094ba,c4cb2c432feebd9d X-Google-Attributes: gid103376,gid1094ba,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!newsfeed2.telusplanet.net!newsfeed.telus.net!edtnps90.POSTED!53ab2750!not-for-mail From: Gordon Sande Newsgroups: comp.lang.ada,comp.lang.fortran Message-ID: <2006052415345816807-gsande@worldnetattnet> References: <0ugu4e.4i7.ln@hunter.axlog.fr> <%P_cg.155733$eR6.26337@bgtnsc04-news.ops.worldnet.att.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: Ada vs Fortran for scientific applications User-Agent: Unison/1.7.5 Date: Wed, 24 May 2006 18:34:58 GMT NNTP-Posting-Host: 24.89.210.20 X-Trace: edtnps90 1148495698 24.89.210.20 (Wed, 24 May 2006 12:34:58 MDT) NNTP-Posting-Date: Wed, 24 May 2006 12:34:58 MDT Xref: g2news2.google.com comp.lang.ada:4424 comp.lang.fortran:10212 Date: 2006-05-24T18:34:58+00:00 List-Id: On 2006-05-24 14:54:12 -0300, "Dr. Adrian Wrigley" said: > On Wed, 24 May 2006 17:12:55 +0000, Dick Hendrickson wrote: > >> >> >> Dr. Adrian Wrigley wrote: >>> On Wed, 24 May 2006 15:19:23 +0000, Dick Hendrickson wrote: >>> >>> >>>> >>>> robin wrote: >>>> >>>>> "Dick Hendrickson" wrote in message >>>>> news:PkHcg.90575$Fs1.7198@bgtnsc05-news.ops.worldnet.att.net... >>>>> >>>>> >>>>>> Ada's is surely better. Knowing that a subscript has to be >>>>>> in range, because it's checked when a value is assigned to >>>>>> the subscript variable, has to be more efficient than what >>>>>> Fortran can do. In general, Fortran has to check the value >>>>>> of the subscripts on every array reference. >>>>> >>>>> >>>>> It can do this only if it is a compiler option. >>>>> It is not a feature the language. >>>> >>>> There's a ambiguous "it" in those sentences. ;) >>>> >>>> But, if "it" refers to Fortran, subscript bounds rules >>>> ARE a feature of the language. You are NEVER allowed to >>>> execute an out-of-bounds array reference in a Fortran >>>> program. >>> >>> ... >>> >>> So what does the standard say must happen if you attempt >>> such an access? Can a program fail unpredictably under >>> such (rather common!) circumstances - as routinely happens >>> in C and C++, sometimes at great cost? >> >> The Fortran standard says nothing at all about what must >> happen for most run-time errors. There is a requirement >> that a compiler be able to diagnose syntax-like errors at >> compile time. There is also a requirement that some >> (unspecified) I/O errors and some memory management errors >> be checked for at run time. The job will abort unless the >> program uses one of the error detection methods. But for >> things like subscript bounds errors, or subroutine argument >> mismatches, the standard doesn't impose anything on the >> compiler. > > ... > >> The other big problem with [old] Fortran programs was >> messing up the argument list in a procedure call. >> Separate compilation made this a lot easier to do. >> The Fortran 90 addition of MODULES essenially closes >> this hole. Most procedure interfaces now can be explicit >> and the compiler must check for calling consistency. >> It's harder to shoot yourself in the foot now, but >> people can still lie to the compiler. > > I think this is an area that Ada really shines. The standard > requires numerous checks for consistency at both compile > time and runtime. Versions of code that don't match properly > can't be linked together or can't be run together (as appropriate). > Using the language gives a feeling of integrity of coding, > with mistakes often being caught very early on. > > Unfortunately, the language features for integrity cannot > be added to an existing language without breaking old > code. This is because the integrity features are often a result > of prohibiting "dodgy" code, flawed syntax or misfeatures. > The history of the C family of languages illustrates this. > I'm not sure where modern Fortran sits in relation to > its forbears in terms of safety and security though. > It's noteworthy that Ada and Fortran are on convergent > paths (modules, user defined types, templates etc). > > With array subscripts, an exception must be raised if the > bounds are exceeded. The same with arithmetic operations. > (curiously, compiling Ada under gcc (GNAT), a compilation > switch is needed to be standards compliant - a mistake:(). > The checks can be switched on and off in the source code > as desired. > > One of the benefits of the compile- and run-time checking > is that refactoring code becomes much easier because the > compiler will usually tell you about what parts haven't > been fixed up yet. Languages like C or Perl are at the > opposite end of the spectrum, I find. From what I read here, > Fortran is somewhere in between. There is a distinction to be made between what the standard requires and what the various compilers offer. Some systems are oriented to the ultimate SpecMark(??) benchmark figures while others offer tightly monitored executions. Subscript checking can be turned on for those systems. Some even go the extra mile of offering checking for usage of undefined (uninitialized) variables. Some undefineds can be caught as a byproduct of flow checking at compile time but others, like array elements, are only possible at run time. Some "real" programmers disdain the use of such tools but others are glad for all the aids that are available. As with most groups there are subgroups. Some Fortran programmers dismiss any notions of less than full exploitation of every last quirk of the hardware and software of the day. Their equivalents in other programming groups are probably the folks who ignore all interrupts. The urban legends have the Fortran error of a DO loop that changed into an assignment because of a typo changing a comma into a period and a satellite was lost. For Ada it is a tossed interrupt that caused a launch failure. Bad practice of one will always be inferior to good practice of the other.