alt.hn

5/11/2026 at 10:38:12 AM

Saying Goodbye to one line of APL

https://homewithinnowhere.com/posts/2026-05-10-one-line.html

by tosh

5/14/2026 at 1:41:15 PM

APL was designed to be written on a chalkboard (if I remember the story right). It is quite dense, and programs are quite small. Reading is slow and requires you to ponder about what was written. You can hold a lot of content in a small amount of 'ink'.

Now, an idea: HN is always complaining that an ipad (or any other tablet) is a consumption device, as it is not designed to be used with keyboard/mouse. Do any of you know if there is an app where you can write APL with a stylus, and has the ability to evaluate expression on the fly, similar to a repl? That would be an awesome thing to do.

by harperlee

5/14/2026 at 6:42:48 PM

The Raspberry Pi and probably other versions of Dyalog APL has all the characters visible across the window and is interactive with a REPL.

by shrubble

5/14/2026 at 3:11:22 PM

On-screen tablet/phone keyboards seem perfect for apl to me.

There’s an iOS port of J but it’s no longer available on the App Store.

by buescher

5/14/2026 at 5:11:48 PM

J is unclear on the concept, it's a hack to port APL to ASCII. I'm typing on a ZMK keyboard now where an APL unicode layer would be trivial. There are modern APLs. One can code a iOS keyboard with AI help.

While a native APL would be nice, the cloud solution would be robust access to a professional product. Build the chain via existing tools to bridge the iPad to APL running on a desktop machine.

I looked into this recently; but I've decided on Lean 4 as the successor "best language in existence" for my needs.

My recent language comparison: https://github.com/Syzygies/Compare

My APL one-liner story: https://news.ycombinator.com/item?id=27460887

by Syzygies

5/14/2026 at 2:19:17 PM

My favorite APL one liner reduces spans of consecutive spaces in a string to one space by doing boolean algebra on the vector of which characters are spaces. APL provided me with a whole different perspective on vector style operation (it was my second language to be familiar with after Basic due to finding an APL introductory book at a discount shop). I find that way of thinking has been very helpful in developing with LINQ in C# and my personal library has many methods inspired by APL operators.

by NetMageSCW

5/14/2026 at 2:40:50 PM

Do you remember what it was? This is how I would spell that in BQN, and you could write something very similar in APL (you don't have shift, so you'd have to write 1 drop 0 cat swap instead)

    ((«¬∘∧⊢)' '=⊢)⊸/
This works by building a boolean mask of spaces, and converting it to a mask of 'is a space, preceded by a space', negates that, and replicates out by that inverted mask (i.e. is not a space preceded by a space):

Here's stepping through it with some input.

       (' '=⊢)  "this  is a  sentence with       many   spaces"
    ⟨ 0 0 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 ⟩
       («' '=⊢)  "this  is a  sentence with       many   spaces"
    ⟨ 0 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 0 0 0 ⟩
       ((«∧⊢)' '=⊢)  "this  is a  sentence with       many   spaces"
    ⟨ 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 ⟩
       ((«¬∘∧⊢)' '=⊢)  "this  is a  sentence with       many   spaces"
    ⟨ 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 ⟩
       ((«¬∘∧⊢)' '=⊢)⊸/  "this  is a  sentence with       many   spaces"
    "this is a sentence with many spaces"

by icen

5/15/2026 at 5:28:53 AM

With an OR 2-scan, you can avoid the negation. Here's how I'd do it in APL: {⍵⌿⍨2∨⌿0⍪' '≠⍵}. In general, I find that boolean 2-scans pop up quite a bit in real-world APL usage. It's worth working through them. I have a short article [0] on the subject, if you're interested.

It's also worth thinking through how all 16 boolean operators work on boolean masks. E.g. what do msk≠msk2, msk<msk2, msk≤msk2 etc. mean? In my experience, the important part is to find crisp domain-specific meanings for these patterns. In general, really, that's how you gain APL fluency. In the same way that reading fluency requires chunking so that letters "disappear", APL fluency requires familiarity with semantic phrases, so you stop thinking in the individual symbols.

[0]:https://blog.wilsonb.com/posts/2023-07-24-suggestivity-and-i...

by xelxebar

5/15/2026 at 9:43:23 AM

(crossing fingers I one shot formatting correctly) I use 2-wise for figuring out which water surfaces to draw: ⍉l⊤⍸∊(chunk=¯1)(2>⌿⍤2⍪⍤2)⊢0⍴⍨⊃l

- ⍪⍤2 add padding on top of surface of bit mask of water

- 2>⌿⍤2 identify where surface is exposed by seeing if air comes after water vertically

- ⍉l⊤⍸∊ collapse and get where water is in chunk position format row-by-row

by kcroarkin

5/14/2026 at 4:15:52 PM

Some alternative spellings:

    (¬∘∧⟜«' '=⊢)⊸/
    (¬·«⊸∧' '=⊢)⊸/
    {¬«⊸∧' '=x}⊸/ # should have double-struck x here (U+1D569), but hn removes it

by dzaima

5/14/2026 at 4:30:05 PM

There's also the much less vector oriented spelling:

    (1 ∾˜ "  "⊸(¬∘⍷))⊸/
which removes the first space of each occurrence of double spacing

by icen

5/14/2026 at 4:37:32 PM

in k:

  s:"this  is a  sentence with       many   spaces"
  
  s@&~0&':s=" "

by tosh

5/14/2026 at 8:50:55 PM

s@&~&':^s would be a bit shorter. is-null(^) also works on spaces

by pillmillipedes

5/14/2026 at 4:20:08 PM

Here’s some helpful background information on the project: https://news.ycombinator.com/item?id=47872891

In particular, it has diagrams of the data structures and how the algorithm operates on them.

by i_don_t_know

5/14/2026 at 11:42:19 AM

FYI Page certificate is bad (expired, wrong, etc.).

by TruffleLabs

5/14/2026 at 12:09:17 PM

Author here. D’oh! Thanks for catching that. I have no idea what I’m doing web dev wise and made this site to talk about my APL experience. Will try to fix this when time permits.

by kcroarkin

5/14/2026 at 12:16:48 PM

I see nothing wrong here: Firefox and Chromium are both happy.

    Issued On Saturday, May 2, 2026 at 2:44:13 AM
    Expires On Friday, July 31, 2026 at 2:44:12 AM
    Certificate d87df94f5e922e0637aaff31768405813764ca7dadcafbd051bf48898860fb8f
    Public Key a9bd7eee0bb4f1e12431ca8fab0a70591b8966dad8226db84f53791e2d81c9e3

by TacticalCoder

5/14/2026 at 7:18:57 PM

numpy is the APL reincarnate

by kimjune01

5/14/2026 at 7:49:12 PM

Numpy doesn’t quite get it. It covers the core verbs, but it opts for specialised names instead of using adverbs (you can apply your own, but it’s much more laborious).

Once you see +/, you understand ,/ or fn/ - whereas you have to remember that it’s written sum, concatenate, or np.ufunc.accumulate in numpy. The same goes for +\ vs cumsum etc (and you don’t get all of these pre defined).

The difference here means that whilst numpy gets the core array operations down, it’s much less convenient and less self explanatory than the apl system.

by icen

5/14/2026 at 3:08:12 PM

> The core what it does seems ridiculously simple. So much so that when I initially considered this I didn’t think it would even be close to being performant. I mean, an interpreted language and all of these movements on large shapes at once!–doesn’t feel like it would be a good idea!!! I guess I was wrong? Doing this on a chunk sized `16 128 16` is pretty fast and I’m able to fly around the map at high speeds (TBA: me demoing this live in a presentation). This kind of boggled my mind and broke my intuitions of what I considered good patterns, at least in the domain of APL.

I wonder what makes it so fast? Is it similar to how GHC can fuse/inline ops and such?

by LoganDark

5/14/2026 at 7:54:54 PM

Iirc, the interpreter recognizes common idioms (sequences of 2-4 operations) and has optimized fused implementations for those idioms that avoid intermediate results.

It can also avoid creating intermediate results for quite a few operations, because for example reverse, transpose, etc only change how the arrays are traversed (order in which elements are accessed). You can reuse the original data and change the indexing information. That’s known as beating and dragging.

by i_don_t_know