Dyalog ’23 Videos: Week 2 – APL Problem Solving Competition

The section that is dedicated to the annual APL Problem Solving Competition is always one of my own favourite parts of a Dyalog user meeting, and the talks by the two winners this year were no exception. It is always a treat to hear about how the student winners are able to go from zero knowledge about APL to delivering very well designed, array-oriented, solutions in a few weeks, sometimes days!

This year, we were very pleased to have both the student grand prize winner Andrea Piseri and the professional winner Alexander Block present. Andrea is studying mathematics at Università degli Studi di Milano (University of Milan) and Alexander is an actuary at the Viridium Insurance Group in Germany.

Before Gitte Christensen presented the prizes to the winners and they gave their talks, our “Chief Problem Maker” Brian Becker gave us a brief history of the competition and overview of the contest website (which uses Dyalog-grown tools). He also mentioned that we are revising the format of the competition, most likely by running simpler/smaller problem sets at a higher frequency. We’ll be making official announcements about that early in 2024.

Read more about this section of the user meeting in our Dyalog ’23 daily blog post.

——————————————

This week’s videos:

Materials for all presentations can be downloaded from the Dyalog ’23 webpage.

Welcome to the Dyalog ’23 Videos!

Welcome to the 2023 edition of the Dyalog user meeting presentation recordings. This year, we plan to release a few talks each week until the Winter Solstice – and I will be doing my best to introduce each block of related talks.

Week 1 – A New CEO!

For the 19th year running, the annual Dyalog user meeting started with CEO Gitte Christensen’s Welcome, followed by my own Technical Road Map presentation. However, all is not as it has been: this year, Gitte opened the user meeting with the announcement that she intends to retire from her role as CEO when she turns 70 at the end of this year. The final presentation in this first block is by our incoming CEO, Kirstine Kromberg, and our new Administration Assistant, Jada Andrade, who closed Dyalog ‘23 with a presentation of the vision for the future of Dyalog Ltd.

The similarity between my name and that of the new CEO is not a co-incidence – she is the daughter of the current CEO and CTO. Kirstine (Stine for short) has an MBA in Business Administration and Information Technology from Copenhagen Business School, and everyone believed she was destined to become a manager at one of the large Danish shipping or pharma companies. However, after Stine’s second maternity leave, she discovered that returning to her job as a business consultant would mean twiddling her thumbs until the consulting market picked up again after the Covid pandemic. At the same time, the search for a new CEO for Dyalog Ltd had started.

Stine has been working for Dyalog Ltd for almost four years now, learning how everything works as an accountant and CFO and running several internal projects both on the administrative and technical side of the business. This experience confirmed to us – and to the board, where half of the directors represent our largest clients – that she could strike the right balance between preserving continuity and having the “change management” skills that are required as we grow beyond 25 full-time employees.

As you will see if you watch my presentation, I have a long list of features that I want to see in Dyalog before I retire – and since everything takes longer than I think, I expect to be around for quite some time! Uncharacteristically, both the first and the last talk mention money: Gitte introduces “The APL Fund”, which will allow successful APLers to contribute to the future growth of APL, and Jada speaks about the new prices for Dyalog licences (effective from 01 January 2024). Except for an initial adjustment when Gitte and I joined Dyalog Ltd, the price of a licence has not changed in the 19 years that Gitte and I have been with the company (don’t worry, they are not changing significantly now unless you are still running a 32-bit version!).

I hope you enjoy watching the first set of recordings from Dyalog ’23!

——————————————

This week’s videos:

Materials for all presentations can be downloaded from the Dyalog ’23 webpage.

Formal Proposal for APL Array Notation – Seeking Feedback

One of the defining features of the APL language is the ability to denote numeric vectors directly through juxtaposition — separating the elements by spaces, as in 0 1 1 2 3 5 8. The notation for character “vectors” is similar to that for “strings” in most other languages, using quotes to denote the start and end of a list of characters. When generalised arrays were added to the language in the early 1980s, the most popular APL dialects extended the vector notation to allow nested arrays to be written using so-called strand notation, allowing the juxtaposition of sub‑expressions producing arrays to form a one-dimensional array — as in:

      (2+2) (FOO 42) MAT

Strand notation works well for small, relatively simple one-dimensional arrays. As soon as arrays are too large to be represented on a single line of code, deeply nested, rank greater than one, or (in APL systems that support them) contain namespaces or objects, APL requires the use of primitives or system functions to assemble them from simple components.

The flexibility of the APL language has allowed many APL programmers to work around the issue, either by implementing custom array notations or by using the ability of most APL interpreters to simply store arrays within saved workspaces without having an actual source form of the data. Within specific applications, domain specific notations can be very successful, but readability is poor for anyone not trained in the specific variation used — or who is missing the tooling required to interpret them — as well as sometimes having significant run-time cost.

Recently, the need for a better notation for arrays has grown within the Dyalog APL community:

  • The switch to text-based sources means that arrays that represent constants, enumerations or initial values — that arguably constitute part of the source of an application — need a textual representation if they are to be managed using the same tools as functions and operators.
  • The increased use of namespaces and name/value pairs as arguments to both user-defined and system functions makes the lack of a good notation for namespaces painful.

Dyalog Ltd intends to implement core language support for a notation that makes it possible to write most arrays literally, without requiring the use of primitive functions, over multiple lines of source where this increases readability. It can be used to write nested arrays, and arrays of rank greater than one. The notation also describes many namespaces/objects, providing both inline and anonymous definitions.

Acknowledgements

Although I used the word “recently” above, the foundations for the notation which gradually evolved into the proposal that we are publishing today were laid by Phil Last at Dyalog’15 in Sicily. At Dyalog, Adam Brudzewsky has been the torch bearer and is the author of the current proposal. We would also like to recognise the contributions of Marshall Lochbaum and dzaima, who have acted as sounding boards and have implemented notations similar to that proposed here in the APL-derivative BQN and in dzaima/APL respectively.

Download the full proposal document

Experimentation within Dyalog APL

Experimental implementations using APL models are available within some tools in the Dyalog eco-system, such as the Link tool (which supports the representation of code and data in Unicode text files) and the functions Serialise and Deserialise within the namespace ⎕SE.Dyalog.Array. You can also try it out in the interactive online sandbox.

Providing feedback

Dyalog Ltd is keen to have feedback from the array language community on the notation proposed here, so that we can feel confident about the design before we proceed with our implementation. Our hope is that we will be able to keep the differences between future array notations within the family of array languages to a minimum.

You can leave feedback below or in the APL Orchard chatroom, the APL Farm’s #apl channel, the r/apl and r/apljk subreddits, and the comp.lang.apl newsgroup, all of which we will monitor. (See APL Wiki for information about these forums.) In addition, we have created a topic in our own forum. If you prefer not to comment publicly, then please send comments by e-mail. We will update the discussion page for APL Wiki’s Array notation design considerations article to contain a record of significant feedback.

11 April 2023 – A Day to Celebrate!

Today we reach two very significant milestones.

40 Years of Dyalog APL

On this day, we have cause for celebration: it is 40 years since the release of Dyalog version 1.0! Geoff Streeter would say that from his perspective we are already in the 42nd year, as he and John Scholes started work on the new interpreter in 1981. On the other hand, Pete Donnelly might argue that the interpreter wasn’t really ready for serious use until a few years after that date. The fact remains that the APL ’83 conference in Washington DC saw the first official release of the product, and is considered to be the “birth” of Dyalog APL.

Farewell Geoff Streeter

On the same day, we also congratulate Geoff Streeter, the last Dyalog developer who will have worked on the interpreter throughout its existence, on the first day of his retirement. We are happy to be able to report that, unlike John Scholes who designed and built version 1.0 together with Geoff but sadly passed away in 2019, Geoff is retiring in good health. We wish him many happy years in retirement in the company of his wife Sarah, children and grandchildren – although we are also hoping that he will pop by the Dyalog office from time to time to let us know how he thinks we are doing, and hopefully also join us at some future user meetings!

Continuity

It is impossible to exaggerate the value of the dedication and continuity that Geoff and John provided to Dyalog over these four decades. In the early days, when company finances were shaky, they sometimes continued work on the interpreter without compensation. Today, we are still blessed with many team members who have worked for Dyalog for most, if not all, of their careers – although we are doing what we can to avoid the need for the extremes of dedication that were required in the early days.

Good Choices

Dyalog APL started its life as a unique combination of what was to become the leading nested array paradigm (APL2/NARS floating arrays) coupled with what John and Geoff (and the rest of the consulting team at Dyadic Systems Ltd) thought were the best “commercial” extensions selected from APL systems developed by STSC and I.P.Sharp Associates (component files and control structures from STSC, error trapping from IPSA, and many other features).

The early choices have stood the test of time, and paved the way for Dyalog to become extremely competitive when Windows 3.1 and John Daintree arrived at the same time – resulting in the extremely easy-to-use Win32 GUI support. In typical fashion, the team did not merely implement a tool for GUI programming, they adopted an approach that led to the very general notion of namespaces, which meant that the same architecture could be used to interface to COM/OLE and subsequently .NET and complete support for object-oriented programming in Dyalog.

UNIX

Geoff was (and is) very much a UNIX man, and the first versions of Dyalog were built for the small UNIX machines that Dyadic Systems expected to take over from the mainframe. Unfortunately, UNIX was slow to gain acceptance and, around 1990 when UNIX was finally starting to take off, Microsoft Windows arrived and the centre of gravity of the commercial business shifted in that direction. Geoff was often heard muttering to himself about how the company was making poor technical choices, driven by what he referred to as “commercial” pressure. He kept his head down, and ensured the UNIX implementations were well supported and that all designs took the needs of these platforms into account.

Users of UNIX-based Dyalog can be grateful for Geoff’s unwavering enthusiasm. And Dyalog too: not only is the IBM AIX version of APL still a significant source of revenue, the ease with which we have been able to add support for Linux and macOS is very much down to our long UNIX history and the goal of maintaining cross-platform compatibility, throughout the history of the product.

Dedication

As a further example of Geoff’s dedication: as a young man with a motorcycle and a keen sense of community, Geoff started riding at night, delivering blood from blood banks to hospitals where it was urgently needed. He started doing this in 1980, just after he started at Dyadic Systems, and, although he is retiring from Dyalog today, Geoff will continue as a volunteer for SERV S&L. Although he no longer rides his bike, he now acts as the controller for the new generation of riders. In October 2021, SERV S&L was presented with The Queen’s Award for Voluntary Service by the Lord Lieutenant of Surrey.

The Future

In the same way that Geoff has not been riding his bike at night, he has not been doing any new development on Dyalog for the last year. Instead, he has been preparing and holding internal presentations to a new generation of Dyalog developers, providing insight into the work that he has done over the last four decades. Ultimately an impossible task of course, but at least they now know where to start digging – and Geoff is still around to answer questions in an emergency if we offer him a cup of coffee and three plain chocolate digestives (his stated minimum requirement to come into the office!).

As Dyalog enters its fifth decade, all parts of Dyalog Ltd. (including the development team) are larger – and broader – than they have ever been. The good choices made by Geoff, John, Pete, and many others in the early years are holding up, and the company continues to grow.

Many thanks to Geoff from everyone at Dyalog Ltd. We will do our best to allow him to relax, enjoy his well-deserved retirement, and look forward to continued dividend payments from the Dyalog shares in his pension fund!

References:

Extending Structural Functions to Scalars

Traditionally, the set of monadic reversing or reflecting primitives, Reverse-First (), Transpose (), and Reverse () apply to entire arrays and are defined as identity functions on scalar arguments. Dyalog v19.0 extends the definitions to provide equivalent reflections on scalars.

Character Data

We expect that the new transformations will be most useful on characters. For example:

      (⍉'A')(⌽'P')(⊖'L')
ᗉꟼΓ

Note that you can apply the same transformation to all the items of an array using Each (¨) or Rank (⍤0):

      ⌽¨ 'New APL?'
Ͷɘw Aꟼ⅃⸮
      (⊖⍤0) 'CAN HAPPEN SOON!'
C∀N H∀ЬЬEN ꙄOOͶ¡

Composition allows the combination of reflections to perform rotation:

      ⊖∘⍉¨ '→A/common'  ⍝ 90° clockwise rotation
↓ᗆ\ᴒoᴟᴟoᴝ
      ⌽∘⊖¨ '→A/common'  ⍝ 180° rotation
←∀/ɔoɯɯou

We can combine the above techniques with additional structural functions, including reflection of the entire array, to achieve more advanced effects that are often needed in modern user interfaces:

      ⌽¨ ⌽ 'New APL?'     ⍝ mirror
⸮⅃ꟼA wɘͶ
      ⊖∘⍉¨ ⍪ '→A/common'  ⍝ vertical
↓
ᗆ
\
ᴒ
o
ᴟ
ᴟ
o
ᴝ
      ⌽∘⊖¨ ⌽ '→A/common'  ⍝ upside-down
uoɯɯoɔ/∀←

Numeric Data

Although the transformations are more easily applicable to characters, many numbers are also in the domain of the extended functions:

      ⌽¨ 1.618 2.71828 3.1415
816.1 82817.2 5141.3
      ⌽¨ 3J4 0J1 0.5
4J3 1 5
      ⌽∘⊖¨ 60 69 908    ⍝ 180° rotation
9 69 806
      ⍉⌽ 8              ⍝ 90° counter-clockwise rotation
1.797693135E308

Notes

Character Data

  • Although the new definitions are available in both 32-bit and 64-bit Unicode editions of Dyalog, very few characters can be reflected in the Classic edition.
  • A TRANSLATION ERROR will be signalled if the required result cannot be represented.

For example, using the Classic Edition where the Rank operator is represented as ⎕U2364:

      (⊖ ⎕U2364 0) 'PHI!'
bHI¡
      (⊖ ⎕U2364 0) 'ABC'
TRANSLATION ERROR: Unicode character ⎕UCS 8704 not in ⎕AVU
      (⊖⎕U2364 0)'ABC'
      ∧

Numeric Data

  • The result of numeric reflections can depend on the value of ⎕FR.
  • A DOMAIN ERROR will be signalled if the required result cannot be represented.

For example, beginning with the default value ⎕FR←645:

      ⌽ 1.2345E67
DOMAIN ERROR
      ⌽1.2345E67
      ∧
      ⎕FR←1287
      ⌽ 1.2345E67    ⍝ 76×10*5432.1
9.56783313E5433

Conclusion

Although it is extremely unlikely that real applications rely on the current behaviour, the extensions are potentially breaking changes and are, therefore, being released as part of a major version upgrade.

We are somewhat surprised that these obviously useful extensions have been ignored by the APL community for such a long time, and are very pleased to finally make them available to commercial, educational and hobbyist users. Please contact ʇɹoddns@dyalog.com if you would like to test a pre-release of Dyalog v19.0 and help us understand the potential impact on existing applications.

Structural vs. Mathematical “Under”

The APL Farm has recently hosted discussions about the proposed under operator, asking “why Dyalog hasn’t implemented it a long time ago”. I claimed that an important reason was that Roger Hui wasn’t a big fan of the proposed extension known as “structural under”. Stefan Kruger then asked me why that was so. Since Roger isn’t able to respond himself, I’ll do my best to explain my own understanding of the issues.

For anyone not familiar with the concept of under, or dual as it was known when first implemented in SHARP APL, it is an operator that provides a way to express a common mathematical pattern, where a computation or proof is simplified by first translating the input domain, applying a function, and then performing the inverse transformation. For example, if we use the symbol to denote under, have the translation function as the right operand, and the function that applies to the translated domain as the left, then we could use +⍢⍟ to demonstrate that multiplication is equivalent to addition under logarithm, which is why slide rules work:

      1 2 3 4 (× ≡ +⍢⍟) 0.1 1.1 17 100
1

Another example of simplifying multiplication using dual is the use of Fast Fourier Transforms to multiply very large numbers, as explained in the notes about xtimes in the dfns workspace.

It is easy to find examples of dualities outside the mathematical domain, such as midnight snacking: (open refrigerator door, remove food, close door) or Roger’s favourite example of medical surgery: apply anaesthetic to greatly simplify the operation, perform surgery and (very important) back out the anaesthetic.

I believe that Roger was of the opinion that under/dual should be restricted to functions that have well-defined inverses using the “mathematical” definition used in SHARP APL and the J language. We can model this with a defined operator, let us call it Um:

   Um←{⍺←{⍵ ⋄ ⍺⍺} ⋄ ⍵⍵⍣¯1⊢(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵)}

The extension known as structural under allows the transformation function to be a structural function, even though such functions do not have inverses in the mathematical sense. In this case, the left operand is applied to the subset of items selected from the right argument by the structural function. This is easy to model using a feature of some APLs known as selective specification, in which you can have a function to the left of an assignment whereby the assignment only modifies items selected from an array using so-called “structural” functions – those functions that select or reorder items of an array without doing math, such as ↑ ↓ ⍉ ⌽ ∊.

Let us call this Us:

   Us←{⍺←{⍵ ⋄ ⍺⍺} ⋄ w←⍵ ⋄ ((⍵⍵)w)←(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵) ⋄ w}

This is very useful, for example, we could negate all items of an array except the first two by writing:

      - Us (2∘↓) ⍳5
1 2 ¯3 ¯4 ¯5

The big question is whether Us and Um can be combined into the same operator, or two separate operators are needed. One problem is that already has a defined inverse in Dyalog APL, which pads with zeros, so Um returns something different:

      - Um (2∘↓) ⍳5
0 0 ¯3 ¯4 ¯5

If we want to combine the two into one, then we need a rule that allows us to decide which definition to use. Marshall Lochbaum‘s BQN language has a table of structural primitive functions; it performs a structural under when possible (according to an extensively described rule), and otherwise attempts a mathematical under.

Personally, this sort of conditional logic in the definition of a key primitive makes me very uneasy, and I think Roger was struggling with this as well. Unfortunately he passed away before we were able to finish argdiscussing the design. Another reason for feeling that the two operators are different is that, while it often makes sense for the transformation to apply to both arguments in the mathematical case, it is extremely rare for structural under. You cannot do:

       1 + Us (2∘↓) ⍳5

because when you apply (2∘↓) to the left argument, you get an empty vector. Instead, you need to turn the left operand into a monadic function to add one to the three trailing elements:

       1∘+ Us (2∘↓) ⍳5
1 2 4 5 6

This increases my personal unease about combining the two into a single operator. Even though this would work “just fine” most of the time, it would still make it difficult to explain exactly what is going on.

It is my opinion that APL needs to remain a rationalised mathematical notation if it is to remain useful and relevant in the long term. Deciding whether to implement a strict mathematical operator, a combined operator, or two separate operators (or do nothing for a while longer), is one of the key design decisions that we will be faced with in the near future.