Live data from Hacker News

Suggestivity and Idioms in APL

sacrideo.us

11–20 of 24 posts

Re: Suggestivity and Idioms in APL

#11
post #7
post #6

Earlier quoted context omitted.

Why has this thing of posting unchecked GPT4 output become popular? It's infuriating. The explanation is wrong, but who cares right? Oh great I see now they've added yet another APL-on-HN trope: the 'equivalent' (note: it's wrong too!) code in some trendy language (and saying APL/K are unreadable). It's like someone crafted the perfect message to piss me off.

I checked it insofar as I understand APL and what the algorithm was attempting to do: that the algorithm was attempting to detect and return the index of the first element of every consecutive "[0 1]" pair. [Edit: OK, I see the mistake is that it should return the index of the `1`, not the `0`. Yes, that's the kind of mistake I'd catch during unit testing, or after more carefully reviewing the code.] In what way is i…

> can't quickly fact-check the answer

If you would like to, visit https://tryapl.org/ and enter:

      ⎕IO ← 0
      bools ← 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 1 1 1
      {⍸(⊃⍵)@0⊣¯1⌽0 1⍷⍵} bools
The website will only(I think) let you copy-paste line by line, or it has the symbols in a bar along the top you can click on to enter them, and it has a backtick prefix system for typing them, so `L will enter the quad square on the first line and `[ enters the left arrow. Left arrow is variable assignment and the variable with a quad is a system one. The top line sets array indices count from zero instead of the default indexing from one. The curly braces {} make the code into a scriptblock/anonymous function which is immediately executed on the argument "bools".

If you want to see it building up stage by stage it works from the right, these give the intermediate steps:

    {0 1⍷⍵} bools

    {¯1⌽0 1⍷⍵} bools

    {(⊃⍵)@0⊣¯1⌽0 1⍷⍵} bools

    {⍸(⊃⍵)@0⊣¯1⌽0 1⍷⍵} bools
> "Regardless of whether its breakdown is right or wrong, my true intended commentary is about the opacity of the syntax and the difficulty in reading it (which I elaborated on via an edit, after your comment was posted but before seeing it)."

Which is a bit of a shame because the point of the article is at the end: "I do not believe that you can leverage this kind of suggestivity with languages that are more verbose. [...] It is fundamentally easier to try out many single line expressions than it is to try out many 15 - 30 line expressions. [...] in the same way that any technique that reduces the length of the feedback cycle improves our ability to iterate and therefore learn.".

It's not saying that APL is easy to read, it's claiming that learning to read it/think in it has benefits that don't apply to longer languages - more forest less trees, more design less bricklaying. Taking that away into "I never learned it and it looks hard" is not going with the more interesting part of the claim - like, would you rewrite your Rust code to detect the end of groups, then compare both versions and see they are annoyingly clunky, then search for a version which is more pleasing and suggests variations which may do other useful or interesting things with the groups? Even if you did, doing so may be harder because the Rust code is so much longer (more effort to compare in your head) and you would be less able to because the Rust code took more time to write so you have less time left over.

[This is rather more for the world of doing a mathematical puzzle, seeing two equations look similar and realising that the puzzles share some common underlying thing which you hadn't noticed before, than the world of writing production webservers with fearless concurrency].

Re: Suggestivity and Idioms in APL

#12
post #10
post #9

Earlier quoted context omitted.

> From the article it clearly is meant to return [0,5,9,11,16], your rust returns [4, 8, 10, 15]. You're right, I didn't test the code, nor review it especially closely. I took a quick glance for a couple of seconds, checked that it compiled, glanced at the primitives it was using, and said "LGTM". I wanted to know "What general shape will this algorithm take expressed a different way?" You shouldn't expect perfectio…

[flagged]

I'm afraid your comments are unfortunately still well on the wrong side of the HN guidelines. In your GP comment, "someone who's been programming for longer than I've been alive but seems to lack reading comprehension" is a swipe, and the comment I'm replying to here is way too aggressive. "I expect you to test" is supercilious, "complete nonsense" is name-calling, "I don't believe you could fix it in APL [...] but then again you can't seem to fix it in any other language either" is a personal putdown, as is "Clearly rust is too as you posted rust code that doesn't work".

I happen personally to agree with you about shallow dismissals of APL and the other array languages and have felt rather strongly about it at times as well, so I completely get where you're coming from. But that makes it painful for someone like me to read nasty posts flaming people for getting it wrong (or what you and I would call wrong). All that achieves is to alienate not only the person you're talking to but also any neutral readers who don't know much about the subject—and that is the vast majority of readers. It not only doesn't help your (our) position, it gives people a new reason to have negative associations with these little-understood languages, which are much too beautiful and powerful to deserve that.

You clearly know a lot about this topic and you're more than welcome to share what you know on HN. One function of this site is to be an educational hub for non-mainstream knowledge about computing (and other topics as well, but especially computing). However, we need you to do so within the site guidelines (https://news.ycombinator.com/newsguidelines.html) which includes being respectful and kind to people who know less than you.

It's great that you edited out the worst personal attack and the fact that you did that makes it clear that you have good intentions—which I appreciate. But it isn't enough to leave posts that are full of putdowns. We really can't bend these rules, nor is it in your interest for us to bend them because, as I said, all they do is make your minority position even more of a minority position, and that hurts you yourself as well as the rest of us who love these languages.

I definitely hope you'll keep posting and sharing interesting things about APL, but if you'd please review https://news.ycombinator.com/newsguidelines.html and take the intended spirit of the site more to heart, we'd be grateful.

Re: Suggestivity and Idioms in APL

#13
post #9
post #8

Earlier quoted context omitted.

You don't have to understand APL to know what it's attempting. From the article it clearly is meant to return [0,5,9,11,16], your rust returns [4, 8, 10, 15] (at least the second one, the first one doesn't even compile!).

> From the article it clearly is meant to return [0,5,9,11,16], your rust returns [4, 8, 10, 15]. You're right, I didn't test the code, nor review it especially closely. I took a quick glance for a couple of seconds, checked that it compiled, glanced at the primitives it was using, and said "LGTM". I wanted to know "What general shape will this algorithm take expressed a different way?" You shouldn't expect perfectio…

> “What would the APL code look like that had a similar off-by-one error? Would it be easy to spot by reading the code?

It kinda does have an off by one error; (Dyalog) APL defaults to indexing from one and the code assumes indexing from zero. The blog author isa well known APL-er and other “modern APL” users often assume indexing from zero. And the change/fix is the quad-io in my other comment so it’s not easily visible in the code because it’s not in the code at all but it is an easy fix.

At least, that’s one kind of off-by-one error; APL doing whole array transforms in each operation tends not to have as much room for off-by-one errors when you aren’t counting through things in the typical imperative way.

Re: Suggestivity and Idioms in APL

#14
post #10
post #9

Earlier quoted context omitted.

> From the article it clearly is meant to return [0,5,9,11,16], your rust returns [4, 8, 10, 15]. You're right, I didn't test the code, nor review it especially closely. I took a quick glance for a couple of seconds, checked that it compiled, glanced at the primitives it was using, and said "LGTM". I wanted to know "What general shape will this algorithm take expressed a different way?" You shouldn't expect perfectio…

[flagged]

Now that I've had the opportunity to actually run the code and test it against the input from the article, here's a corrected version:

  fn find_zero_one_indices(input: I) -> Vec
  where
      I: IntoIterator,
  {
      let input: Vec = std::iter::once(0).chain(input.into_iter()).collect();
      
      input.windows(2)
          .enumerate()
          .filter_map(|(i, window)| {
              if window == &[0, 1] {
                  Some(i)
              } else {
                  None
              }
          })
          .collect()
  }
There's a limit to how much time I'm willing to spend on this, which I see as tangential to the point I was attempting to explore in my original comment, which was about how the opacity of the APL syntax made it difficult to engage with the ideas; and how using an alternative syntax might make it easier to engage in a discussion about algorithms.

(Yes, I realize the article comments on this. Still, it's difficult to engage with those meta-ideas because the article's analysis relies heavily on APL syntax and constructs.)

To really understand the point being made by the article, I'd need to follow it step-by-step, and attempt to translate each code fragment it's discussing into something comparable in another language; and then attempt to see how those fragments or functions compose, or fail to compose, in the same way that they can in APL. I'd need to see a side-by-side comparison.

True, the Rust code above is a lot longer than "⍸(⊃⍵)@0⊣¯1⌽0 1⍷⍵", but I question to what degree it's less modular. The constructs that the Rust code relies on, like `chain`, `windows`, `enumerate`, `flat_map`, etc., are (as far as I understand) similar, general-purpose constructs analogous to APL operators (or whatever the right term is). They can even operate over higher-rank spaces in conjunction with suitable libraries.

So it's not immediately obvious to me that the APL code fragments discussed in the article do not have analogous code fragments in languages like Rust. Perhaps this dimension of higher-order programming (rank-agnostic code? would that be a correct description?) is most useful in numerical computation, which is not my forte.

Or perhaps it's gone over my head relative to the time that I've invested in it, and to understand the ideas I'd need to read it more carefully, like an academic paper.

(Remark: Insert "your favorite language here" in place of Rust. I chose Rust in my example simply because I'm learning it; not in an attempt to proclaim it as superior. I believe Java and Python and most other modern languages could probably express the algorithm similarly.)

Re: Suggestivity and Idioms in APL

#15
post #12
post #10

Earlier quoted context omitted.

[flagged]

I'm afraid your comments are unfortunately still well on the wrong side of the HN guidelines. In your GP comment, "someone who's been programming for longer than I've been alive but seems to lack reading comprehension" is a swipe, and the comment I'm replying to here is way too aggressive. "I expect you to test" is supercilious, "complete nonsense" is name-calling, "I don't believe you could fix it in APL [...] but t…

Perhaps you should give some thought to discouraging the use of ChatGPT as if it were a source of information. The tendency to use it as a substitute for understanding or research seems corrosive to discourse.

Re: Suggestivity and Idioms in APL

#16

I walked in, realized just how advanced this was and then proceeded to read through the same way I pan through the Abstract Art section of the museum. I freaking love APL and would love to learn it, but it is so incredibly jarring not knowing anything about the syntax.

I share your sentiments and it is incredible. To an outsider this might as well be a parody of programming blog posts. Such impenetrable syntax taken in stride:

    We can improve this approach by recognizing that we can handle the edge cases by using a catenation:
        ⍸0 1⍷0,⍵
        ⍸1 0⍷⍵,0
    Notice immediately how much better this feels.
Ah yes, how immediate is the feeling, much better, indeed. APL is so ridiculous, you have to love it.

Re: Suggestivity and Idioms in APL

#17
post #12

Earlier quoted context omitted.

I'm afraid your comments are unfortunately still well on the wrong side of the HN guidelines. In your GP comment, "someone who's been programming for longer than I've been alive but seems to lack reading comprehension" is a swipe, and the comment I'm replying to here is way too aggressive. "I expect you to test" is supercilious, "complete nonsense" is name-calling, "I don't believe you could fix it in APL [...] but t…

Perhaps you should give some thought to discouraging the use of ChatGPT as if it were a source of information. The tendency to use it as a substitute for understanding or research seems corrosive to discourse.

Auto-generated comments are banned on HN but I think we'd get accused of overreach if we tried to tell people how they should use ChatGPT.

Re: Suggestivity and Idioms in APL

#18
post #17

Earlier quoted context omitted.

Perhaps you should give some thought to discouraging the use of ChatGPT as if it were a source of information. The tendency to use it as a substitute for understanding or research seems corrosive to discourse.

Auto-generated comments are banned on HN but I think we'd get accused of overreach if we tried to tell people how they should use ChatGPT.

Barging into a conversation with what amounts to "I don't know what I'm talking about, but I expect you to read the next five paragraphs of GPT copy-pasta" is at least as harmful as a "shallow dismissal" or "internet trope". It's a gish-gallop at best, and outright spam at worst. It is not overreach to curb antisocial behavior, whether machine-assisted or naturally-occurring.

Re: Suggestivity and Idioms in APL

#19
post #17

Earlier quoted context omitted.

Auto-generated comments are banned on HN but I think we'd get accused of overreach if we tried to tell people how they should use ChatGPT.

Barging into a conversation with what amounts to "I don't know what I'm talking about, but I expect you to read the next five paragraphs of GPT copy-pasta" is at least as harmful as a "shallow dismissal" or "internet trope". It's a gish-gallop at best, and outright spam at worst. It is not overreach to curb antisocial behavior, whether machine-assisted or naturally-occurring.

I agree! (except I think "antisocial behavior" in the last sentence is too harsh). But I don't see how we can make a moderation rule out of it. "Don't quote ChatGPT as if it were an authoritative source of information" is much too specific. We'd need some sort of general principle.

Re: Suggestivity and Idioms in APL

#20

I walked in, realized just how advanced this was and then proceeded to read through the same way I pan through the Abstract Art section of the museum. I freaking love APL and would love to learn it, but it is so incredibly jarring not knowing anything about the syntax.

If you are interested in learning APL, take a look at https://xpqz.github.io/learnapl/intro.html

Disclaimer: author

Post reply on HN