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 Path: g2news2.google.com!news3.google.com!news.glorb.com!proxad.net!proxad.net!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada,comp.lang.fortran Subject: Re: Ada vs Fortran for scientific applications Date: Tue, 23 May 2006 10:25:37 +0200 Organization: Adalog Message-ID: <0ugu4e.4i7.ln@hunter.axlog.fr> References: NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1148374865 5705 195.25.228.57 (23 May 2006 09:01:05 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 23 May 2006 09:01:05 +0000 (UTC) User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:4360 comp.lang.fortran:10108 Date: 2006-05-23T10:25:37+02:00 List-Id: Disclaimer: I am an Ada guy. FORTRAN was my first programming language, but it was long, long ago, and I don't know about the latest improvements to the language. I'll answer some questions here, but I'd like to be enlightened on the latest trade from the FORTRAN side. Dan Nagle a �crit : > Hello, > > Jean-Pierre Rosen wrote: >> Nasser Abbasi a �crit : >>> What are the technical language specific reasons why Fortran would be >>> selected over Ada? >>> >> Some immediate reasons: >> 1) Packaging. Packages allow better organization of software, which is >> good for any kind of application. > > Can you compare and contrast Ada packages > with Fortran modules and submodules? Honestly, I don't know about Fortran modules. >> 2) Strong typing. Scientific applications often deal with physical >> units, and Ada is great at supporting these. > > What specific features of Ada provide better support > than the comparable feature of Fortran? Is it possible in Fortran to define three *incompatible* types Length, Time, and Speed, and define a "/" operator between Length and Time that returns Speed? >> 3) User defined accuracy. Ada allows you to define the accuracy you >> need, the compiler chooses the appropriate representation. Note that >> you are not limited to only two floating point types (many machines >> have more than that). > > How is this better than Fortran's kind mechanism? I need to be educated about Fortran's kind, but can you use it to specify that you want a type with guaranteed 5 digits accuracy? >> 4) Fixed points. Not available in Fortran > > Agreed. How important is this for floating point work? > Fortran is rarely used for imbedded software (at least, > I wouldn't). It's not important for floating point work, it's important for fixed point work :-) Because Fortran has no fixed points, the scientific community sees floating point as the only way to model real numbers. Actually, fixed points have nothing to do with embedded software, they are a different way of modelling real (in the mathematical sense) numbers, with different numerical properties. Depending on the problem, fixed point may (or not) be more appropriate. >> 5) Guaranteed accuracy, not only for basic arithmetic, but for the >> whole mathematical library > > Can you compare Ada's accuracy requirements with Fortran's > support for IEEE 754? Ada's accuracy requirement is independent from any hardware (or software) implementation of floating points, and are applicable even for non IEEE machines. >> 6) Standardization. All compilers process exactly the same language. > > Again, how is this different? Fortran compilers are required > to be able to report use of extensions to the standard. AFAIK, there is a formal validation suite for Fortran, but 1) Compilers rarely report their validation result 2) A compiler is deemed "passed" if it succeeds 95% of the tests, while 100% is required for Ada >> 7) Interfacing. Easy to call libraries in foreing languages => all >> libraries available for Fortran are available for Ada. > > Can you compare Interfaces.C to ISO_C_BINDING? > How is one better or worse than the other? Sorry, I don't know what you are refering to (except for Interfaces.C :-) >> 8) Concurrency, built into the language > > Co-arrays and concurrent loops are coming in Fortran 2008. Concurrency has been in Ada since 1983! Moreover, it's a multi-tasking model, not concurrent statements model. Both models have benefits and drawbacks, it depends on the needs. > >> 9) Generics. Stop rewriting these damn sorting routines 1000 times. > > Intelligent Macros are coming in Fortran 2008. I don't know what an "intelligent macro" is, but certainly generics (once again available since 1983"), are much more than macros, even intelligent ones. For one thing, the legality of generics is checked when the generic is compiled. This means that, provided actual parameters meet the requirements of the formals, there is no neeed to recheck at instantiation time, and ensures that any legal instantiation will work as expected. AFAIK, this cannot be achieved by macros. >> 10) Default parameters. Makes complex subprograms (simplex...) much >> easier to use. > > Agreed. > >> 11) Operators on any types, including arrays. Define a matrix product >> as "*"... > > How is Ada's operators for types better or worse than Fortran's? > Is Ada's "*" operator better than Fortran's matmul()? More convenient to write: Mat1 := Mat2 * Mat3; >> 12) Bounds checking, with a very low penalty. Makes bounds checking >> really usable. > > How is Ada's bounds checking better or worse than Fortran's? I may miss something on the Fortran side, but Ada's very precise typing allows to define variables whose bounds are delimited. If these variables are later used to index an array (and if the language features are properly used), the compiler statically knows that no out-of-bound can occur. In short, most of the time, an Ada compiler is able to prove that bounds checking is not necessary, and corresponding checks are not generated. In practice, compiling an Ada program with or without bounds checking shows very little difference in execution speed, because only the really useful checks are left, all the spurious ones have been eliminated. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr