I work in a number of different languages depending on the project. For rapid prototyping I use Jupyter Notebook with Python 2 or 3 which is then converted to standalone code, documents are written in Markdown or LaTeX and compiled to HTML or PDF, Fortran is used for heavy computation, etc. I also revitalize a lot of legacy FORTRAN IV and FORTRAN77 code so I frequently find myself wishing I had the capabilities found in the standard libraries of more modern languages. I also miss certain language-specific development tools which don’t have a Fortran equivalent.
In the previous post, I lamented the lack of a standard library in Fortran and briefly reviewed the contents of the standard libraries for both C and Python. While these languages serve different roles than Fortran, they are popular and mature and I felt they were worth investigating for inspiration. This post covers two topics: first, I present a brief summary of how a hypothetical Fortran Standard Library could be created and adopted (the “Big Picture“), and second I look at the standard libraries of Julia, R, and Ada.
The Big Picture approach I am taking is to:
- describe the problem (lack of a standard library),
- show how other languages address it,
- set high level policies and goals,
- define & implement an achievable initial library,
- have people use it and provide feedback, and,
- iterate over 4 through 6 until the library is stable, adjusting the policies and goals in 3 to ensure the library is implementable, stable, usable, and meets with community approval.
Following this model, we can define high-level capabilities we want in a standard Fortran library and then get into the details of what functions are necessary. In software engineering terms, that means setting requirements and creating design and functional specifications.
One of Fortran’s major drawbacks is its lack of a standard library, a formally defined set of components outside the language core which are supplied along with the compiler. Recent revisions of the Fortran standard have defined several standard modules (ISO_C_BINDING and ISO_FORTRAN_ENV are the two best known) but these do little more than define constants and data types. As of 2017, there are no standard libraries for (say) operating system or filesystem access, string handling, searching and sorting, or networking.
Since Fortran is primarily used for numerical computing, the lack of a standard network library may not be a great disadvantage. However the lack of filesystem tools and text manipulation and parsing tools severely limit the utility of the language.
Before asking what should be in hypothetical Fortran Standard Library, it might be helpful to review what’s in the standard libraries of other languages such as C and Python.