Apl Language

Now that Unicode support in browsers is decent, I'll try to put the code examples in Unicode characters rather than images. Let me know if there are any problems. (I'm keeping the images for now - feel free to delete if the Unicode characters are sufficiently useful.) -- Marnen Laibow Koser


APL stands for A Programming Language. It is an Array Oriented Language.

Its character set is a superset of ASCII. This is demonstrated in the following APL code sample:

www.chilton.com

[6] L←(Lι':')↓L←,L ⍝ drop To: [7] L←LJUST VTOM',',L ⍝ mat with one entry per row [8] S←¯1++/∧\L≠'(' ⍝ length of address [9] X←0⌈⌈/S [10] L←S⌽(−(⍴L)+0,X)↑L ⍝ align the (names) [11] A←((1↑⍴L),X)↑L ⍝ address [12] N←0 1↓DLTB(0,X)↓L ⍝ names) [13] N←,'⍺',N [14] N[(N='_')/ι⍴N]←' ' ⍝ change _ to blank [15] N←0 ¯1↓RJUST VTOM N ⍝ names [16] S←+/∧\' '≠⌽N ⍝ length of last word in name

Reserved words are preceded by a special symbol (called quad).

There are no precedence rules in APL: statements are simply read from right to left. For example,

12 - 3 + 4 yields 5, same as 12 - (3 + 4)

Contributors: DanB (Dan Baronet, or Dan Bernstein?)

While APL is executed right to left, it is read from left to right. -- Jim Russell

The intent was to use 'function'al notation i.e. f(g(x)).

Could someone give a list of what the characters in the above example mean? I remember some of them, and a number of them are described in www.users.cloud9.net . However, I have no idea what LJUST, RJUST or VTOM mean - I don't believe they are APL primitives, but are either functions written in APL, or else functions from some language which replaces APL characters with alphanumeric strings. -- Paul Morrison

Paul: You are right that LJUST & RJUST and VTOM are not primitives. They appear to be variable names or function names, based on the preceding syntax. My guess is the RJUST and Ljst are Left and Right Justify, respectively, but I'm not sure what VTOM is. -- Hans Wobbe

Hans: VTOM is a well-known function (at least to SHARP APL users), the name means Vector TO Matrix. It basically takes a delimiter, followed by a vector which contains lines delimited by that delimiter, and returns a padded matrix with each line as a separate row, each preceded by the delimiter. That is, VTOM '.ab.cde' is the matrix 2 4 {shape} '.ab .cde' -- Leigh Clayton

Thanks, Leigh. I guess that became a popular function name after my days as IPSA. I still have the primitives code and never did get around to setting it up as a function. Perhaps one of the reasons that I do enjoy following the Object Oriented discussions around here, is that I seem to be guilty of a lot of such over-sights. By the way, It's nice to have our paths cross, once again. Regards, - 'hwo'.


Note that 12-3+4 = 12-(3+4) = 5 is exactly opposite from the way Smalltalk Language does it. In Smalltalk, 12-3+4 = (12-3)+4 = 13.


APL was developed by Ken Iverson who has since gone on to direct his attention to the language J [Jay Language].


Yes, you needed a special keyboard, and yes, you need a special terminal, since at that time we are talking about VT100 and variants, mostly IBM terminals actually, but I can't remember their names.

Did you know there is a Uni Code range devoted to APL symbols? See if any of the code points U2336-U237A have glyphs in your favorite fonts.

I found some keyboard designs in Google. The one I used was similar to the most complex.

www.unb.ca

www.rexswain.com

Although difficult to get used to, APL was Fun. I know of a large bank in Brazil that had a team of economists just doing what we call today Data Mining in APL 20 years ago.

As I understand, if you had an extended APL, you needed an extended keyboard also. IBM must have loved this language at that time.

An APL program to find all Prime Numbers <= an integer:

www.users.cloud9.net

PRIMES :
(~R∈R○.×R)/R←1↓ιR

So Apple stole the option key trick from APL? That makes the fact that Windows doesn't use it even more disappointing than it already was.


APL was originally created to Define Document Specify the IBM 360...

No; Iverson published a formal spec for the 360 in 1964, but APL was not developed for that purpose. His 1962 book A Programming Language specifically says in the preface that he developed it over severals years teaching graduate courses, as a mathematical notation for discussing algorithms.

The notation used in the book used semantically significant fonts, superscripts, subscripts, and such that were replaced by more practically implementable notations in the later implementation of it as a programming language.

...and it was close enough to being an actual computer language that an interpreter was implemented for it (and a special type ball on the ibm selectric was created to represent it).

APL was once used to prototype SQL - SQL could be looked at as an attempt to extract the data-storage aspects of APL into a form which is generally useful.

You could look at it that way as a metaphor or something, but that's not to say that that's where SQL got those aspects of its nature. Those aspects came from Codd's database theory research.

I don't see these as contradictory. Using APL to implement a prototype has little or nothing to do with where SQL as a language came from.

They *are* contradictory, because in terms of objective documented history, SQL was *not* "an attempt to extract the data-storage aspects of APL into a form which is generally useful". It just wasn't, and there aren't any citations out there to support that speculation. That's why I said (trying to be gentle) that you could say that as a "metaphor", because it sure as hell isn't historical fact.

I'm a fan of APL, it doesn't need anyone to lie (or even exaggerate) about its historical contributions to justify its worth.

APL is now a dead language: the user community is so small that you almost never hear about it

That's a subjective judgement, not an objective fact. I am not part of the APL/J/K community, but I hear about it repeatedly over the years. The APL community was always a small one. The introduction of the J and K dialects seem to have kindled some new interest.

...and there are so many divergent variants that little is held in common beyond the basic language.

I believe that there are only 3 many variants, that they have actually quite a bit in common, and that it is meaningless to say "beyond the basic language", because it sounds like you're saying they do have the basic language in common, and are thus contradicting yourself in the very same phrase in which in make your claim.

Still, there are lessons to be learned from APL which could benefit even the most cutting edge technologies.

Agreed.

I, too, agree. The Apl community I was privileged to join in 1972, was one of the most educational environments I have encountered in my career. And while it has always been small, its core members undoubtedly have a lot that they could contribute. If there is any interest, I would be pleased to try to find some of the following and try to recruit them to post here. I think we would be the better for it. Specifically:

David Keith (large databases in APL)

Eric Iverson (oldest Ken Iverson son who managed Ip Sharp's 'zoo' - the developers.)

Leslie Goldsmith (666 mailbox)

Roger Moore (original programming implementation team that won the Grace Hopper award)

... -- Hans Wobbe

For example: one of the lessons of UML is that it's a mistake to introduce aggregations or multiplicities early on. These are details which are added later. And yet, "object-oriented" languages force you to learn design patterns dedicated to dealing with these concepts. In APL, on the other hand, you can use the same code to deal with 1:1, 1:n, n:1, or n:n multiplicities (yes, n:n is really 1:1 multiplicity, but you wouldn't know that by the way you have to represent it in a classic OO language). n:m (outer join) multiplicities take a slightly different approach, but we're talking a minor syntactic difference here, not a design pattern which requires the creation of several different classes.

This seems interesting but I'm not 100% sure of what you're driving at.

When you look at a body of OO code (like .NET, or J2EE), and compare it to a body of APL code (like what you see at www.kx.com , you can't help but realize that there are lessons about Code Reuse which we've yet to integrate into the mainstream.

I'm willing to believe you, but which lessons are those?

The lesson is the point above about n:n multiplicity being the same thing as 1:1, 1:n, n:1, et al, in APL. In Java, operations on an Array of Foos are different from operations on a single Foo. In APL and members of its family, the code doesn't change at all when you move from a single Foo to a collection of Foos. It's a striking and powerful difference.

That's certainly a powerful feature of APL and its descendants, but how does it have anything to do with code reuse? --Marnen Laibow Koser


Reading Material

Lack of libraries in APL old.vector.org.uk.novaredirects.com

APL wiki hosted on Moin Moin wiki.vector.org.uk


Q Anyone know where to get a "free" Apl Language processor that works in Windows Xp, can communicate with a Com Component (or activex) that has GUI, and also links up to databases via ODBC or OLEDB drivers? Any dialect will do, though I prefer basic APL with ability to remap keyboard to using APL keys

A Did you try www.jsoftware.com , home of the "free" Jay Language interpreter [Randy Mac Donald]

No and I assume you have tried and liked it? If all I have to sacrifice in using J is the lack of greek characters, but if it has a reasonable GUI for Windows Xp and ODBC, then I will try it. BTW, does the version work on Pocket Pc as well? That would indeed be good. Thanks from David Liu

A Workstation APL2 Time Limited Version of APL2 Last time I looked, the limitation is accumulated CPU time, so one can use this over a period of days, weeks, or months. www14.software.ibm.com

[IBM.com ... Products & services > Software > Software Development] gerry lowry gerry.lowry@abilitybusinesscomputerservices.com

(Wednesday 2004-11-03 03:15 Eastern Time)

Thanks for information. What is the exact time limit? I must have missed it when looking at that web page. Also do I get a clean uninstall?

-- sorry, I do not know the exact time limit ... regardless, because it's in CPU allocation, unless you stuck in a loop, you should get a substantial number of days, weeks, or months to play with it ... as for clean uninstall, I am not that sure ... one would hope that IBM can perform a clean uninstall but unfortunately, I can not speak on their behalf. As for me, I never uninstalled it, so I do not have an answer from my personal experience. -- gerry abilitybusinesscomputerservices.com

A I've found NARS2000 at www.nars2000.org to be a solid player. It's a Windows executable but it does easily run using Wine on Linux as suggested on it's page. See also the "What it's Not" section to know where it's aimed. I certainly have used it to play around and attempt to rekindle my 30 year old skills (and I'm only 45 so what kind of geek does that make me?)



See original on c2.com