Echos of APL

Not only do developers frequently conjure up Ken Iverson ghosts, they also invariably turn into little apostles of array programming that won’t shut up about how cutting down on all those goddamn loops clarifies and simplifies algorithms. How learning to think about operating on entire arrays, versus one dinky number at a time, frees the mind. post

The thesis of Iverson's influential paper is that the advantages of executability and universality found in programming languages can be effectively combined, in a single coherent language, with the advantages offered by mathematical notation. post

The Python people fixed Python with NumPy. Pythonistas reluctantly embraced NumPy but quickly went apostolic! Now books like Elegant SciPy and the entire SciPy toolset that been built on NumPy take it for granted.

The NumPy examples in this post are from the SciPy.org NumPy quick start tutorial. For each NumPy statement, I have provided a J equivalent. J is a descendant of APL. It was largely designed by the same man: Ken Iverson.

a = np.arange(15).reshape(3, 5) a =. 3 5 $ i. 15 a = np.array([2,3,4]) a =. 2 3 4 b = np.array([(1.5,2,3), (4,5,6)]) b =. 1.5 2 3 ,: 4 5 6 c = np.array( [ [1,2], [3,4] ], dtype=complex ) j. 1 2 ,: 3 4 np.zeros( (3,4) ) 3 4 $ 0 np.empty( (2,3) ) 2 3 $ 0.0001

.

The author provides many more examples. This would be most interesting to folks who have some J and NumPy experience.

Needless to say, J can be quite cryptic to those who have not learned its basic syntax and idiomatic usage. Conversely, J can be amazingly expressive to those who have. We can get a feeling for its expressiveness without learning J by simply browsing the large collection of J idioms called the J Phrase Book. page

.

The secret of APL’s popularity was simple: learning all the alien symbols is a one-time investment, but the leverage you as a programmer gain is for life. APL deserves its renaissance too. post

With the permission of IBM, the Computer History Museum is pleased to make available the source code to the 1969-1972 “XM6” version of APL for the System/360 for non-commercial use. post