> The virtues of APL that strike the programmer most sharply are its terseness — complicated acts can be described briefly, its flexibility — there are a large number of ways to state even moderately complicated tasks (the language provides choices that match divergent views of algorithm construction), and its composability
I had an introduction to APL in university and what I absolutely hated was this terseness. I guess when you're a mathematician APL is more natural but to me, as a programmer, I much prefer to have some extra verbosity to make my code more (human-)readable.
I find APL very difficult to read. Incidentally, I am told (by stack overflow) that the APL expression "A B C" can have at least four different meanings depending on context[1]. I suspect there's a connection here.
One of my list of dream projects that I might never have time to do, and so feel free to "steal" the idea, would be a eink notepad in where you could code in APL or similar.
APL was born as a mathematical notation, pertaining to the blackboard, so it makes sense to write it using a writing implement. Its terseness would make it ideal for the handwriting world, it's REPL implementation would give quick feedback loops, you could move around input and output streams.
You could be in a sofa, writing the solution, expending most of your energy thinking, not writing, once you got used to the new way of thinking and the vocabulary.
If you haven't tested any array language I would recommend you try to solve things using one, and check existing solutions so you can see how to think differently. Some problems are naturally easier with this approach, some are harder.
You are exactly right that the original vision of APL was a handwritten, non-ambiguous, consistent, and executable math notation. This was never accomplished.
In 2021, I made a prototype calculator designed for iPad and Pencil and wrote four essays called "New Kind of Paper" describing this concept. The video demonstration of the prototype [Demo] sums up pretty well how it might be used.
In 2024, Apple released Math Notes, which implements this concept for standard math notation. My "review" of it is at [MathNotes]. In short, it is currently a preview of a damn great tool, but its future depends on notation and expressivity.
APL is a language from 2066, created in 1966. While its semantics make more sense now due to machine learning, syntactically it remains alien to most people. Backus' FP/FL and Iverson's J are more approachable to current programmers, but still not there. In New Kind of Paper, I created a tiny language called Fluent, which is nowhere near the ambition of any language mentioned, but it is intentionally designed to be handwritten. A week ago, I open-sourced it. [Fluent]
There is plenty of work left to do, but it is a good start.
I’ve practiced array languages extensively myself, including for code golfing, and I fully understand the intellectual joy they can provide. But as I’ve gotten older, I’ve come to see a deep mismatch between what these languages present as “elegant” and what I find truly elegant from a computer science perspective.
Sure, realizing that the foobar of x is nothing more than the transpose of the 15th foo of x, combined via an inner product with the 7th bar of x raised to the power of baz, can be an ineffable intellectual delight. But actually computing that, rather than writing a “boring” loop, feels horrible to me. To my eyes, a “boring” piece of code written by Dijkstra in some Algol-like language contains more beauty than all these dazzling sleights of hand that hide zillions of loops under the rug while pretending that the actual computation doesn’t matter.
Array languages are more conceptually simple. What do you concretely mean to mock with:
> realizing that the foobar of x is nothing more than the transpose of the 15th foo of x, combined via an inner product with the 7th bar of x raised to the power of baz
It's not like array languages don't do any optimizations... Denying the programmer the ability to be clever by manually writing loops makes some things easier and simpler for the compiler as well.
I’d like to play with an array language because I’ve never used one. I don’t want to pay for it; this is just for fun and as an experiment. I also want to run it locally in a shell, writing it in a local editor, not working in a web UI. And while popularity isn’t everything, and none of these are exactly Python levels of widespread, I also don’t want to find myself learning a cool one along with 3 other people in the world and then find out all other array language programmers do things completely differently. (Analogy: I don’t want the equivalent experience of picking Haskell as my first ever PL.)
This topic tends to bring up a few, like APL itself, J, K, and BQN. Given those (soft!) constraints, what’s the one I want to start hacking around with?
J is, within the APL family of languages, the one I have always found the most useful. I reach for it as I used to reach for my HP calculator in the past, to quickly compute or numerically model things. I always have it running in a terminal window.
Contrary to popular belief, its learning curve isn't steep. I once introduced it to high school freshmen who had no real experience with programming. I recommend the series of booklets by Kenneth Iverson himself: Arithmetic, Algebra, Calculus — there is even a Concrete Mathematics companion to accompany the book of the same name by Graham, Knuth et alii. They're all available for download on the site.
13 comments
[ 4.8 ms ] story [ 33.6 ms ] threadI had an introduction to APL in university and what I absolutely hated was this terseness. I guess when you're a mathematician APL is more natural but to me, as a programmer, I much prefer to have some extra verbosity to make my code more (human-)readable.
[1] https://stackoverflow.com/a/75694187
APL was born as a mathematical notation, pertaining to the blackboard, so it makes sense to write it using a writing implement. Its terseness would make it ideal for the handwriting world, it's REPL implementation would give quick feedback loops, you could move around input and output streams.
You could be in a sofa, writing the solution, expending most of your energy thinking, not writing, once you got used to the new way of thinking and the vocabulary.
If you haven't tested any array language I would recommend you try to solve things using one, and check existing solutions so you can see how to think differently. Some problems are naturally easier with this approach, some are harder.
In 2021, I made a prototype calculator designed for iPad and Pencil and wrote four essays called "New Kind of Paper" describing this concept. The video demonstration of the prototype [Demo] sums up pretty well how it might be used.
In 2024, Apple released Math Notes, which implements this concept for standard math notation. My "review" of it is at [MathNotes]. In short, it is currently a preview of a damn great tool, but its future depends on notation and expressivity.
APL is a language from 2066, created in 1966. While its semantics make more sense now due to machine learning, syntactically it remains alien to most people. Backus' FP/FL and Iverson's J are more approachable to current programmers, but still not there. In New Kind of Paper, I created a tiny language called Fluent, which is nowhere near the ambition of any language mentioned, but it is intentionally designed to be handwritten. A week ago, I open-sourced it. [Fluent]
There is plenty of work left to do, but it is a good start.
[NKoP]: https://mlajtos.mu/posts/new-kind-of-paper
[MathNotes]: https://mlajtos.mu/posts/new-kind-of-paper-5
[Fluent]: https://news.ycombinator.com/item?id=46649223
[Demo]: https://youtu.be/y5Tpp_y2TBk
Thanks for coming to my TED talk.
Sure, realizing that the foobar of x is nothing more than the transpose of the 15th foo of x, combined via an inner product with the 7th bar of x raised to the power of baz, can be an ineffable intellectual delight. But actually computing that, rather than writing a “boring” loop, feels horrible to me. To my eyes, a “boring” piece of code written by Dijkstra in some Algol-like language contains more beauty than all these dazzling sleights of hand that hide zillions of loops under the rug while pretending that the actual computation doesn’t matter.
> realizing that the foobar of x is nothing more than the transpose of the 15th foo of x, combined via an inner product with the 7th bar of x raised to the power of baz
This topic tends to bring up a few, like APL itself, J, K, and BQN. Given those (soft!) constraints, what’s the one I want to start hacking around with?
Contrary to popular belief, its learning curve isn't steep. I once introduced it to high school freshmen who had no real experience with programming. I recommend the series of booklets by Kenneth Iverson himself: Arithmetic, Algebra, Calculus — there is even a Concrete Mathematics companion to accompany the book of the same name by Graham, Knuth et alii. They're all available for download on the site.