← Back to context

Comment by ofalkaed

2 days ago

Any pointers on how to get better at expressing high-level application logic in APL? Any good resources on programming in APL? So far I have only found tutorials and basic stuff for learning APL but not much on applying APL. I am slowly improving and think I sort of get it but probably don't.

Not that I know of, unfortunately. This is, IMHO, the biggest pain point of APL pedagogy at the moment. I'm actually working on some resources, but they're still gestating.

For non-event driven systems, the short story is to organize application state as a global database of inverted tables and progressively normalize them such that short APL expressions carry the domain semantics you want.

For event driven systems, we have token enumeration over state machines, which can be expressed as literal Branches to state blocks.

Granted, the above likely doesn't communicate well unless you're already primed with all the necessary ideas. If you're interested, I'm willing to chat. Email is in my profile description.

source: Current day-to-day is greenfield APL dev.

  • >IMHO, the biggest pain point of APL pedagogy at the moment

    It is the one that always trips me up. I just started in on my third attempt at learning APL/array languages, both previous times I got to the same point where I was mostly at a loss of how to apply it all. So I move on and forget all that I learned until the next time and have to start over. Thankfully the last attempt seems to have mostly stuck as far as keyboard layout goes, makes progress much quicker.

    I may take you up on that email offer once I get a bit further along in this current attempt, can't quite form reasonable questions yet and only know what tripped me up in the previous attempts. I believe you are a regular on APL Orchard? I will be joining it soon so perhaps will see you there.

What would you consider "high-level application logic"?

  • The logic of the system instead of the pieces of the system; how the language's core data structure applies/relates towards expressing that system. I could very well be overthinking things and seeing some sort of magic which is not there but this line in the previous response to me, makes me think I am still missing a piece of the puzzle:

    >organize application state as a global database of inverted tables and progressively normalize them such that short APL expressions carry the domain semantics you want.

    • Ok. I have some idea I think of where you are at, so I will give it a shot. I think this sort of thing is an emergent property in the design of APL applications, and so there's nothing to "see" in terms of an example unless you can see that design process.

      But first, "database" here is just the list of global variables. If that wasn't obvious, it is important.

      My application processes weblogs, and "clicks" is the bit-array of which event was a click (redirect), as opposed to having a variable called "weblog" which contains a list of records each possibly having an event-type field.

      Normalizing them that acknowledges that the weblog (input) probably looked like the latter, but it's easier to do work on the former. APL makes that transformation very easy: Just rotate the table. In k this is flip. Simples.

      Those "domain semantics" are simply the thing I want to do with "clicks" which in my application comes from the business (users), so I want them to provide a bunch of rules to do that.

      Now with that in mind, take a look here:

      https://code.jsoftware.com/wiki/Vocabulary/bdot#bitwise

      and here:

      http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec...

      Look carefully at the tables, because they're given in a slightly different way, but they are the same. And these are all of them, so it should be obvious at this point you can represent any boolean operation against any matrix of variables with a matrix of these numbers.

      For example, you might have a sql-like expression (from a user of your application) of x=y, and x<y and so on that you want to use to filter some data set.

      Now if you are to think about how you might do this in Javascript (for example; probably in scheme too) you would probably organise such a table as a chain of closures. And I think if you look at any ORM in just about any language you'll see this kind of pattern (maybe they use classes or use a tree, but these are obviously the same as closures), but such a tree can only be traversed, and the closure can only be called. Maybe you can batch or shard, but that's it, and since I would bet there are a lot of dependant loads/branching in this tree of closures, it is slow.

      But if you understand that this tree is also a matrix of boolean operators, it is obviously parallelisable. And each operation is simple/cache-friendly and so therefore fast. This leads to your "queries" being a set of projected indexes or bitmaps (whichever is convenient), which you probably also store in global variables someplace (because that is convenient) while you're doing what you need to do (make xml, json, bar charts, run programs, whatever)

    • I may be reading too much into this but it sounds like you’re searching for templates to stimulate ideas similar to how there are examples for smaller puzzle type problems.

      I think most sizable stuff is proprietary. I implemented an lsp in an open source K which uses json/rpc. But the open source K is probably best considered a hobby project.

      https://github.com/gitonthescene/ngnk-lsp/blob/kpath/k/lsp.k

      You might consider joining one of the APL forums if you haven’t already.