Array programming languages

The Array Cast is creating a series of podcasts (with transcripts) on array programming languages, which they consider to be APL, J, k, and q. Their latest episode, Loops and Learning about Array Languages, indirectly points to a strength of modern Fortran, which has array operations and which also executes loops fast. Once LFortran is mature (the cited languages have REPLs), I think discussions of array programming languages will have even less reason to ignore Fortran.

1 Like

One could define a .x. operator in Fortran such that A .x. B is equivalent to matmul(A,B) for matrices and vectors. What should it do for arrays of dimension 3 and higher? For array dimensions higher than 2, should transpose in Fortran emulate numpy.transpose?

I don’t understand the “part-ref” comment.

IBM got a European patent for a translator from APL to Fortran 77 in 1987 that expired in 2007. Translating to modern Fortran should be easier.

program rank_part
  type t
    real :: x(3) = 0.0
  end type t

  Type(t):: z(2)

  z = t(x=[1.,2.,3.])

  print *,size(z)
  print *,size(z(1)%x)
  print *,z%x !error
end program

Coincidentally, there is a very active Twitter thread on arrays (in Fortran) with 1k likes and more than 50 comments:

https://twitter.com/ID_AA_Carmack/status/1401959248507047948

Some of my favorite posts:

  • By Pontus Bergsten:

    I work in a huge c++ code base, which have a dependency to an f2c:ed version of Lapack (amongst others). It is fun to watch the hyper light speed compilation of the lapack files, compared to the c++ files (especially those wich are template heavy with boost dependencies.

  • Andy Somogyi:

    I still find it astonishing that C or even c++ never supported a native matrix type. It’s a trivial thing to do. The lack of a native type invites 10,000,000 different and incompatible homebrew solutions.

3 Likes

Hacker News in a thread Try APL has a post by Syzygies

In the mid-seventies at Swarthmore College, we were mired in punched card Fortran programming on a single IBM 1130. The horror, a machine less powerful than the first Apple II. My job six hours a week was to reboot after each crash. People waited hours for their turn to crash the machine. I let a line form once people had their printouts. I’d find the single pair of brackets in a ten line listing, and I’d explain how their index was out of bounds.

…

There is a language called Remora that supports rank-polymorphic programming . Fortran has had some support for rank-polymorphic programming since the F90 standard, where many inttrinsic functions act either on scalars or on arrays of any rank. User-defined ELEMENTAL functions were then added, and Fortran now allows arguments to be assumed rank arrays (although you can’t do much with them without SELECT RANK). Maybe reading about Remora and reaching out to its creators could yield some ideas for enhancing Fortran.

3 Likes

Rank-polymorphic programming is related to Mathematics of Arrays (MoA) that I’ve been trying to get up to speed lately:

2 Likes