top | item 12254574

APL Tutorial

123 points| ktRolster | 9 years ago |zerobugsandprogramfaster.net | reply

55 comments

order
[+] gregfjohnson|9 years ago|reply
It is a pleasure to see APL crop up on HN from time to time. APL was the first language I learned, back in the 1970's. "First love," and all that. I remain a devoted user of the language, though only as a thought-amplifier and prototyping tool.

The big key to the language IMHO is the idea of computation liberated from time. This is what I think Dijkstra was getting at when he railed against "operational thinking". Instead of thinking of programming in terms of mentally replaying the execution sequence of the code you are writing, you can step outside of time, as it were. Computation becomes a way of thinking about mathematical transformations at an abstract, extra-temporal level. Dijkstra described this as programming via "predicate transformers". But he was still constrained in a scalar world. Iverson, on the other hand, encouraged people to dream in abstract aggregates of data. His mathematics of arrays was at once simple and rich, ripe with expressive possibility.

In my view, the functional programming people are doing beautiful work creating new realities and ways of thinking within this cognitive universe.

So, (pun alert) APL remains unsurpassed in its beauty and timelessness.

[+] davedx|9 years ago|reply
The earliest programming languages were the most creative. APL and Lisp are inspirational.
[+] 0xdeadbeefbabe|9 years ago|reply
Makes me wonder if Knuth agrees with Dijkstra about the preidcate transformer?
[+] Homunculiheaded|9 years ago|reply
For anyone interested, I noticed that Dyalog made their proprietary implementation of APL free for non-commercial use just recently [0]. I suspect this change might have been in reaction to an uptick in traffic to their site from this other APL HN post[1] a bit more than a month ago (there's some good discussion their as well).

[0] http://www.dyalog.com/ [1] https://news.ycombinator.com/item?id=11963548

[+] gtani|9 years ago|reply
I learned C and IBM APL2 around the same time for financial apps. For APL, i read the Polivka and Pakin book about 30 times, not this edition, but the red paperback I used is apparently impossible to buy. Excellent book, it got me to where i could be competitive in obfuscated APL contests: https://www.amazon.com/P-L-Prentice-Hall-automatic-computati...
[+] rebootthesystem|9 years ago|reply
I have pictures of my younger self at an APL conference in 1983 with Polivka, Pakin, Ken Iverson and other APL luminaries of the day. Small community.
[+] rbanffy|9 years ago|reply
"Obfuscated APL"? Isn't that a pleonasm?
[+] ktRolster|9 years ago|reply
I agree, it is one of the best tutorial/technical books I have ever read. Very clean writing style, and the authors clearly enjoy their topic.
[+] kbenson|9 years ago|reply
> i read the Polivka and Pakin book about 30 times

I hope that's because the book was more accessible than the computer platforms at the time, otherwise that is a steep learning curve.

[+] gregors|9 years ago|reply
Check this out - you miss out on the ambience until you actually see it in action - https://www.youtube.com/watch?v=_DTpQ4Kk2wA
[+] 3princip|9 years ago|reply
Great video, thanks for sharing! A bit embarrassing that Professor Bob Spence teaches at my/our alma mater and I didn't realize it was him until checking out the description at the end.

Wish I had used my time at University more productively, so many interesting people and subjects concentrated in one place. It went by very quickly and most the time was spent worrying about passing exams. Seems I'm much more interested in some of the subjects nowadays, I certainly would have appreciated the experience more now than at that age.

[+] curiousgal|9 years ago|reply
Livecoding sessions d'époque, I love old programming videos!
[+] Sir_Cmpwn|9 years ago|reply
Anyone know of a good place to buy teletypes like this?
[+] qwertyuiop924|9 years ago|reply
You may want to learn J instead. It uses ascii, and it's from Iverson, so it's the true continuation of APL.
[+] beagle3|9 years ago|reply
Or K (a JS interpreter called oK with an interactive coding env called iKe can be found in John earnest github account).

It is a distillation of APL/J concepts. Much smaller core, clicks better than J for some people.

[+] mseepgood|9 years ago|reply
Code is read much more often than it is written. That's why I prefer APL's symbols over J's ASCII clutter.
[+] eggy|9 years ago|reply
A lot of people have cited the APL Life example, but I found this J example of somebody exploring Ulam's spiral as a great way that J is used to approach a mathematical concept [1]. Very easy to follow along in J open next to YouTube, and it still amazes me how quickly you can visualize from the REPL with 'viewmat'.

The Jupyter notebooks, are modern kin to this, and are still trying to catch Mathematica, which for me, really shines for toying around with the curated data and one-liners.

[1] VIDEO - https://www.youtube.com/watch?v=dBC5vnwf6Zw

[+] Roboprog|9 years ago|reply
How does something like "R" compare to APL?

If you replaced the greek letters and other symbols in APL with function names, keeping the right to left order of operations, is there something missing? (I only did a tiny bit of APL for a class 30 years ago)

[+] yummyfajitas|9 years ago|reply
I've played with J a bit. I have yet to see any J code that can't be translated in a pretty straightforward way to idiomatic Python + Numpy.

Of course, it's pretty important to note that idiomatic Numpy is very different from idiomatic Python. For example, here's some idiomatic numpy:

    gamma = arange(0,1, 1/1024.0)
    x = np.outer(r(T-event_times[M+1:N]), gamma)
    log_likelihood += M*log(gamma) + sum(log(1-x), axis=0)
    return exp(log_likelihood)
Idiomatic python might be:

    for i in range(0,1024):
        log_likelihood[i] = M*log(gamma[i])
        for j in range(M+1,N):
            tmp = r(T-event_times[j])*gamma[i]
            log_likelihood[i] += log(1-tmp)
        likelihood[i] = exp(log_likelihood[i])
    return likelihood
[+] rebootthesystem|9 years ago|reply
I think you mean J.

Easy: J is an abomination. Notation is a very powerful thing and J destroyed it. It was a misguided attempt to deal with hardware limitations of the time.

I used APL professionally for about ten years.

Don't take it from me, ironically Iverson himself made the case many years ealier in this paper:

http://www.jsoftware.com/papers/tot.htm

[+] clifanatic|9 years ago|reply
> For most of us, getting access to a computer and being able to use it as long as we wish is merely a dream.

Ah, so he has kids, too.

[+] 35bge57dtjku|9 years ago|reply
The real question is where do I get a magic typewriter that works like that???
[+] ndr|9 years ago|reply
You can try J instead, http://www.jsoftware.com/

As Wikipedia puts it [0]: it is a synthesis of APL (also by Iverson) and the FP and FL function-level languages created by John Backus.

To avoid repeating the APL special-character problem, J uses only the basic ASCII character set, resorting to the use of the dot and colon as inflectionsto form short words similar to digraphs.

[0] https://en.wikipedia.org/wiki/J_(programming_language)

[+] jxy|9 years ago|reply
Like all the non-English speakers do.
[+] beachy|9 years ago|reply
As a young IBM engineer, seeing APL keyboards put me off programming for a decade. The incomprehensible hieroglyphics were daunting.
[+] rebootthesystem|9 years ago|reply
No, it's not. It is a horrible abomination. See my other post.

It's like changing all math symbols to words because the computers of the time can't display the integral sign or greek letters. A total destruction and negation of the power of notation. Iverson made a very bad decision with J. It's crap.

[+] sctb|9 years ago|reply
We detached this subthread from https://news.ycombinator.com/item?id=12255109 and marked it off-topic. Inclusions like “It is a horrible abomination.” and “It's crap.” are not necessary or acceptable on Hacker News.
[+] pierrec|9 years ago|reply
APL symbols are slighly more suggestive than J symbols, sometimes they vaguely resemble mathematical counterparts with similar meanings, but they remain entirely separate programming symbols with their own meanings. The idea of using other, more common characters instead remains an excellent idea. Afflicting J with lovecraftian adjectives and scat doesn't help.
[+] Crito|9 years ago|reply
> "It's like changing all math symbols to words because the computers of the time can't display the integral sign or greek letters."

You mean like TeX? Seems pretty fucking sensible to me.

[+] rbanffy|9 years ago|reply
The worst part of APL (I learned it in college) was dictating programs to colleagues.
[+] ktRolster|9 years ago|reply
imo using the symbols is part of the fun of APL! Apart from the utility.
[+] qwertyuiop924|9 years ago|reply
Sigh, I guess you're right. It's not like their aren't massive disadvantages to the APL way of doing things, like not being able to edit your code in standard editors, and having to learn confusing new keybindings, or even get a new keyboard.

OH WAIT.