Jump to content

Ratfor: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
m History: corrected to keep the file type references while noting the dead links
 
(41 intermediate revisions by 33 users not shown)
Line 1: Line 1:
{{Short description|Programming language}}
{{unreferenced|date=November 2010}}
{{Infobox programming language
{{Infobox programming language
| name = Ratfor
| name = Ratfor
Line 7: Line 7:
| website = [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor sepwww.stanford.edu]
| website = [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor sepwww.stanford.edu]
}}
}}
'''Ratfor''' (short for '''RAT'''ional '''FOR'''tran) is a [[programming language]] implemented as a [[preprocessor]] for [[Fortran#FORTRAN_66|Fortran 66]]. It provided modern control structures, unavailable in Fortran 66, to replace [[GOTO]]s and statement numbers.


'''Ratfor''' (short for ''Rational Fortran'') is a [[programming language]] implemented as a [[preprocessor]] for [[Fortran#FORTRAN 66|Fortran 66]]. It provides [[Structured programming|modern control structures]], unavailable in Fortran 66, to replace [[GOTO]]s and statement numbers.
Ratfor was designed and implemented by [[Brian Kernighan]] at
[[Bell Labs|Bell Telephone Laboratories]] in 1974, and described in ''Software-Practice & Experience'' in 1975. It was used in the book "Software Tools" ([[Brian Kernighan|Kernighan]] and [[P.J. Plauger|Plauger]], 1976).


== Features ==
Ratfor provides the following kinds of flow-control statements, described by Kernighan and Plauger as "shamelessly stolen from the language C, developed for the UNIX operating system by [[Dennis Ritchie|D.M. Ritchie]]" ("Software Tools", p. 318):
Ratfor provides the following kinds of flow-control statements, described by Kernighan and Plauger as "shamelessly stolen from the language [[C (programming language)|C]], developed for the [[Unix|UNIX]] operating system by [[Dennis Ritchie|D.M. Ritchie]]" ("Software Tools", p. 318):


* statement grouping with braces
* statement grouping with braces
Line 22: Line 21:


For example, the following code
For example, the following code
<source lang="c">
<syntaxhighlight lang="c">
if (a > b) {
if (a > b) {
max = a
max = a
Line 28: Line 27:
max = b
max = b
}
}
</syntaxhighlight>
</source>
might be translated as
might be translated as
<source lang="fortran">
<syntaxhighlight lang="fortranfixed">
IF(.NOT.(A.GT.B))GOTO 1
IF(.NOT.(A.GT.B))GOTO 1
MAX = A
MAX = A
GOTO 2
GOTO 2
1 CONTINUE
1 CONTINUE
MAX = B
MAX = B
2 CONTINUE
2 CONTINUE
</syntaxhighlight>
</source>
The version of Ratfor in ''Software Tools'' is itself written in Ratfor, as are the sample programs, and inasmuch as its own translation to Fortran is available, it can be ported to any Fortran system. Ratfor source code files end in .r or .rat.
The version of Ratfor in ''Software Tools'' is written in Ratfor, as are the sample programs, and inasmuch as its own translation to Fortran is available, it can be ported to any Fortran system. Ratfor source code file names end in .r or .rat.


== History ==
It basically took the flow control statements and generated regular fortran which then could be compiled. It allowed you to use structured programming in writing the code.
Ratfor was designed and implemented by [[Brian Kernighan]] at [[Bell Telephone Laboratories]] in 1974, and described in ''Software&mdash;Practice & Experience'' in 1975. It was used in the book "Software Tools" ([[Brian Kernighan|Kernighan]] and [[P.J. Plauger|Plauger]], 1976).


In 1977, at [[Purdue University]], an improved version of the ratfor preprocessor was written. It was called Mouse4, as it was smaller and faster than ratfor. A published document by Dr. [[Douglas Comer]], professor at Purdue concluded "contrary to the evidence exhibited by the designer of Ratfor, sequential search is often inadequate for production software. Furthermore, in the case of lexical analysis, well-known techniques do seem to offer efficiency while retaining the simplicity, ease of coding and modularity of ad hoc methods." (CSD-TR236).
In 1977, at [[Purdue University]], an improved version of the Ratfor preprocessor was written. It was called Mouse4, as it was smaller and faster than Ratfor. A published document by Dr. [[Douglas Comer]], professor at Purdue, concluded "contrary to the evidence exhibited by the designer of Ratfor, sequential search is often inadequate for production software. Furthermore, in the case of lexical analysis, well-known techniques do seem to offer efficiency while retaining the simplicity, ease of coding and modularity of ad hoc methods." (CSD-TR236).


In comparison of the ratfor preprocessor on a program of 3000 source lines running on a [[CDC 6500]] system took 185.470 CPU seconds. That was cut by 50% when binary search was used in the ratfor code. However rewriting the ad hoc lexical scanner using a standard method based on finite automata took the program to 12.723 seconds.
In comparison to the Ratfor preprocessor on a program of 3000 source lines running on a [[CDC 6500]] system took 185.470 CPU seconds. That was cut by 50% when binary search was used in the Ratfor code. Rewriting the ad hoc lexical scanner using a standard method based on finite automata reduced run time to 12.723 seconds.


With the availability of [[Fortran 77]], a successor named [[Ratfiv]] (Ratfor=rat4 => rat5=Ratfiv) could, with an option /f77, output a more readable Fortran 77 code:
==See also==
<syntaxhighlight lang="fortranfixed">
* [[Ratfiv]]
IF (A .GT. B) THEN
MAX = A
ELSE
MAX = B
ENDIF
</syntaxhighlight>

Initial Ratfor source code was ported to C in 1985 <ref>{{ cite web|url=http://ratfor.sourcearchive.com/documentation/1.0-11/rat4_8c-source.html |title=Ratfor implementation in C (1985)}}</ref> and improved to produce Fortran 77 code too.<ref>{{ cite web|url=http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor |title=Ratfor77}}</ref> A [[git (software)|git]] tree has been set in 2010 in order to revive ratfor
.<ref>{{ cite web|url=http://gitorious.org/ratfor-revived/c-ratfor |title=Ratfor Git Revived}}</ref>
Although the [[GNU Compiler Collection|GNU C compiler]] had the ability to directly compile a Ratfor file (.r) without keeping a useless intermediate Fortran code (.f) (<code>gcc foo.r</code>), this functionality was lost in version 4 during the move in 2005 from [[f77]] to [[GNU Fortran]].<ref>{{ cite web|url=https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24357 |title=gcc lost the ratfor preprocessor}}</ref>

The original source was available in .[[deb (file format)|deb]] and .[[rpm (file format)|rpm]] forms at its original site, mirror.corbina.net/mandriva/, and its archive, www.dgate.org/ratfor/ are gone as of April, 2024.

== Ratfiv ==
'''Ratfiv''' is an enhanced version of the [[Ratfor programming language]], a [[preprocessor]] for [[Fortran]] designed to give it [[C (programming language)|C]]-like capabilities. Fortran was widely used for scientific programming but had very basic [[Control flow|control-flow]] primitives ("do" and "[[goto]]") and no "[[Macro (computer science)|macro]]" facility which limited its expressiveness.

The name of the language is a pun (''Ratfor'' (RATional FORtran) -> "Rat Four" -> "Rat Five" -> ''RatFiv'').

Ratfiv was developed by Bill Wood at the [[Fox Chase Cancer Center|Institute for Cancer Research]], [[Philadelphia]], PA in the early 1980s and released on several [[DECUS]] (Digital Equipment Users Group) SIG (Special Interest Group) tapes. It is based on the original Ratfor by [[Brian Kernighan|B. Kernighan]] and [[P. J. Plauger]], with rewrites and enhancements by David Hanson and friends (U. of Arizona), Joe Sventek and Debbie Scherrer ([[Lawrence Berkeley National Laboratory]]).

Ratfiv V2.1 was distributed on the DECUS RSX82a SIG tape.<ref>[http://www.ibiblio.org/pub/academic/computer-science/history/pdp-11/rsx/decus/rsx82a/330015/ Ratfiv V2.1 archive]</ref>

== See also ==
* [[Fortran]]
* [[Fortran]]
* [[EFL (programming language)|EFL]]


==External links==
== References ==
{{reflist|30em}}

== External links ==
* [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor Ratfor]
* [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor Ratfor]
* [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor90 Ratfor90]
* [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor90 Ratfor90]
* [http://hopl.murdoch.edu.au/showlanguage.prx?exp=692&language=RATFOR History of Programming Languages: Ratfor]
* [https://web.archive.org/web/20060903163415/http://hopl.murdoch.edu.au/showlanguage.prx?exp=692&language=RATFOR History of Programming Languages: Ratfor]
* [http://www.cs.purdue.edu/research/technical_reports/1977/TR%2077-236.pdf Purdue summary]
* [https://docs.lib.purdue.edu/cstech/172 Purdue summary]
* [http://sepwww.stanford.edu/doku.php?id=sep:software:ratfor90 Ratfor90]
* [http://www.ratfor.info Authentic Ratfor]


[[Category:Fortran programming language family]]
[[Category:Fortran programming language family]]
[[Category:Programming languages created in 1976]]

[[es:Ratfor]]
[[ja:Ratfor]]

Latest revision as of 18:12, 7 April 2024

Ratfor
DeveloperBrian Kernighan
First appeared1976 (1976)
Websitesepwww.stanford.edu
Influenced by
Fortran, C

Ratfor (short for Rational Fortran) is a programming language implemented as a preprocessor for Fortran 66. It provides modern control structures, unavailable in Fortran 66, to replace GOTOs and statement numbers.

Features

[edit]

Ratfor provides the following kinds of flow-control statements, described by Kernighan and Plauger as "shamelessly stolen from the language C, developed for the UNIX operating system by D.M. Ritchie" ("Software Tools", p. 318):

  • statement grouping with braces
  • if-else, while, for, do, repeat-until, break, next
  • "free-form" statements, i.e., not constrained by Fortran format rules
  • <, >, >=, ... in place of .LT., .GT., .GE., ...
  • include
  • # comments

For example, the following code

if (a > b) {
  max = a
} else {
  max = b
}

might be translated as

      IF(.NOT.(A.GT.B))GOTO 1
      MAX = A
      GOTO 2
    1 CONTINUE
      MAX = B
    2 CONTINUE

The version of Ratfor in Software Tools is written in Ratfor, as are the sample programs, and inasmuch as its own translation to Fortran is available, it can be ported to any Fortran system. Ratfor source code file names end in .r or .rat.

History

[edit]

Ratfor was designed and implemented by Brian Kernighan at Bell Telephone Laboratories in 1974, and described in Software—Practice & Experience in 1975. It was used in the book "Software Tools" (Kernighan and Plauger, 1976).

In 1977, at Purdue University, an improved version of the Ratfor preprocessor was written. It was called Mouse4, as it was smaller and faster than Ratfor. A published document by Dr. Douglas Comer, professor at Purdue, concluded "contrary to the evidence exhibited by the designer of Ratfor, sequential search is often inadequate for production software. Furthermore, in the case of lexical analysis, well-known techniques do seem to offer efficiency while retaining the simplicity, ease of coding and modularity of ad hoc methods." (CSD-TR236).

In comparison to the Ratfor preprocessor on a program of 3000 source lines running on a CDC 6500 system took 185.470 CPU seconds. That was cut by 50% when binary search was used in the Ratfor code. Rewriting the ad hoc lexical scanner using a standard method based on finite automata reduced run time to 12.723 seconds.

With the availability of Fortran 77, a successor named Ratfiv (Ratfor=rat4 => rat5=Ratfiv) could, with an option /f77, output a more readable Fortran 77 code:

      IF (A .GT. B) THEN
        MAX = A
      ELSE
        MAX = B
      ENDIF

Initial Ratfor source code was ported to C in 1985 [1] and improved to produce Fortran 77 code too.[2] A git tree has been set in 2010 in order to revive ratfor .[3] Although the GNU C compiler had the ability to directly compile a Ratfor file (.r) without keeping a useless intermediate Fortran code (.f) (gcc foo.r), this functionality was lost in version 4 during the move in 2005 from f77 to GNU Fortran.[4]

The original source was available in .deb and .rpm forms at its original site, mirror.corbina.net/mandriva/, and its archive, www.dgate.org/ratfor/ are gone as of April, 2024.

Ratfiv

[edit]

Ratfiv is an enhanced version of the Ratfor programming language, a preprocessor for Fortran designed to give it C-like capabilities. Fortran was widely used for scientific programming but had very basic control-flow primitives ("do" and "goto") and no "macro" facility which limited its expressiveness.

The name of the language is a pun (Ratfor (RATional FORtran) -> "Rat Four" -> "Rat Five" -> RatFiv).

Ratfiv was developed by Bill Wood at the Institute for Cancer Research, Philadelphia, PA in the early 1980s and released on several DECUS (Digital Equipment Users Group) SIG (Special Interest Group) tapes. It is based on the original Ratfor by B. Kernighan and P. J. Plauger, with rewrites and enhancements by David Hanson and friends (U. of Arizona), Joe Sventek and Debbie Scherrer (Lawrence Berkeley National Laboratory).

Ratfiv V2.1 was distributed on the DECUS RSX82a SIG tape.[5]

See also

[edit]

References

[edit]
  1. ^ "Ratfor implementation in C (1985)".
  2. ^ "Ratfor77".
  3. ^ "Ratfor Git Revived".
  4. ^ "gcc lost the ratfor preprocessor".
  5. ^ Ratfiv V2.1 archive
[edit]