
APL Tutorial - ktRolster
http://www.zerobugsandprogramfaster.net/essays/5b.html
======
gregfjohnson
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
The earliest programming languages were the most creative. APL and Lisp are
inspirational.

~~~
rebootthesystem
I got started with Machine language, APL, LISP, C, FORTH, roughly in that
order. Used them all professionally for at least ten years (still using C, of
course).

Truly an excellent way to venture into computing.

------
Homunculiheaded
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/](http://www.dyalog.com/) [1]
[https://news.ycombinator.com/item?id=11963548](https://news.ycombinator.com/item?id=11963548)

~~~
kaiwetzel
They also have _Mastering Dyalog APL_ by Bernard Legrand as a free PDF
download. I've just starting reading it, seems to be a very gentle
introduction to APL: [http://www.dyalog.com/mastering-dyalog-
apl.htm](http://www.dyalog.com/mastering-dyalog-apl.htm)

~~~
davorb
I used it to learn APL, and it really is a great resource.

------
gtani
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...](https://www.amazon.com/P-L-Prentice-Hall-automatic-
computation/dp/0130388858)

~~~
rebootthesystem
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.

~~~
spthorn60
APL was hot in Poughkeepsie, where I grew up. My first APL program was a
Mastermind simulator (on our high school's Telex connected to a timeshare
system). My dad worked for IBM, and Ray and Ken were household names.

~~~
xxxxxxxxxxxxxxx
Did you go to PDS (Poughkeepsie Day School)?

------
gregors
Check this out - you miss out on the ambience until you actually see it in
action -
[https://www.youtube.com/watch?v=_DTpQ4Kk2wA](https://www.youtube.com/watch?v=_DTpQ4Kk2wA)

~~~
3princip
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.

------
qwertyuiop924
You may want to learn J instead. It uses ascii, and it's from Iverson, so it's
the true continuation of APL.

~~~
beagle3
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.

~~~
scottlocklin
Or Nial, which is APL in plain English.

[http://www.nial.com/OpenSource.html](http://www.nial.com/OpenSource.html)

They're working on a distributed and GPU versions.

~~~
eggy
I didn't know about any new effort with Nial. I'll have to check it out. The
distributed and GPU parts are especially enticing to me. CUDA is wearing me
out!

I have really become comfortable with J now, and I don't know if it would help
me to step into a text-based APLish language. More typing for me to do the
same I do in J, and I don't code for or with others, so no collaboration
arguments here. And, I can read my old J programs just fine, even years later.
Most code fits in a glance, and if you are not very practiced, very little
time to refresh as opposed to looking through pages of 'easy to read' Python
for example.

How is Kerf [1] coming along? How similar to J?

[1] [https://github.com/kevinlawler/kerf](https://github.com/kevinlawler/kerf)

~~~
scottlocklin
Kerf's doing well: we're adding a sort of NoSQL functionality which is pretty
unique (unstructured data you can index and join on). Closer to K than J, but
really pretty different from both, beyond the Array language heritage.

I had considered building a distributed processing system using J and zeroMQ,
but now considering doing something like this with Kerf. Main thing is ... do
the customers want it. I can't pay rent with technological innovation.

FWIIW, Pascal has something you might be interested in for GPUing in J, if you
are not aware of it; jarrayfire.
[https://github.com/Pascal-J/Jfire](https://github.com/Pascal-J/Jfire) I
haven't screwed around with it, but I keep meaning to get around to it. Looks
solid. I made an abortive attempt to do something cheaper (cuda hooks
basically), but got distracted.

------
ontouchstart
APL\B5500: The Language and its Implementation

Gary Kildall

[https://news.ycombinator.com/item?id=12223304](https://news.ycombinator.com/item?id=12223304)

------
Roboprog
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
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

~~~
snaky
[http://prog21.dadgum.com/121.html](http://prog21.dadgum.com/121.html)

~~~
yummyfajitas
Python has the idiom he describes as a builtin.

    
    
        with open(filename) as f:
            ...your func goes here
    

If you want to create your own custom one:

    
    
        @contextlib.contextmanager
        def with_a_foo(...):
            foo = ...
            yield foo
            ...cleanup the foo...
    

It's less terse (and in my opinion more readable [1]) than J, but same idea.

[1] I _very rarely_ find point free programming to be comprehensible. This may
be my mental limitation.

------
clifanatic
> 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
The real question is where do I get a magic typewriter that works like that???

~~~
ndr
You can try J instead, [http://www.jsoftware.com/](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)](https://en.wikipedia.org/wiki/J_\(programming_language\))

~~~
35bge57dtjku
Sorry, I meant the typewriter from here:
[https://www.youtube.com/watch?v=_DTpQ4Kk2wA](https://www.youtube.com/watch?v=_DTpQ4Kk2wA)

------
abraae
As a young IBM engineer, seeing APL keyboards put me off programming for a
decade. The incomprehensible hieroglyphics were daunting.

------
rebootthesystem
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
We detached this subthread from
[https://news.ycombinator.com/item?id=12255109](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.

~~~
rebootthesystem
Just saw this.

Hey, you know, your forum, your rules. So, fine with me. No issues.

However, you are getting tripped-up by language and, effectively, censoring
it, which is exactly opposite our culture. And passing judgement on the
necessity of language is a very subjective thing. Profanity or colorful
language is able to communicate at a level that is almost impossible to match
with hundreds of words.

In this case the use of the word "abomination" is objectively correct and
true. This coming from someone who started using APL over 30 years ago, was
very much a part of the community, published APL papers, met every luminary in
the language and fully understands how, when and why J came about. Few people.
Very few people on HN can match this degree of depth in APL and most voice
opinions about J out of ignorance of the history and genesis of this history-
changing mistake.

The only modern parallel I can find is what happened with Python 2.7 and 3.0.
Not a perfect analogy because the incompatibilities did not kill Python. J all
but assured that APL was dead.

Instead of sticking with and evolving the great concepts of notation as a tool
for thought Iverson managed to both give the world one of the most amazing new
concepts in computational problem solving and, at the same time, years later,
pretty much kill it. Yes, "abomination" fits that history.

Still, your forum, your rules. Live long and prosper.

