APL Programming

Has anyone here learned APL? It’s a programming language that uses symbols instead of keywords like this:

life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

I like the idea and worked through part of this interactive tutorial one afternoon, but haven’t had time to look closely. There is another tutorial here.

List of symbols:

3 Likes

Someone told me a dude had a keyboard with the symbols and recreated an entire app infrastructure using it

1 Like

On the opposite side, it’s simplicity in symbols, makes many things unclear. I mean unless ur supper familiar with the syntax, it’s like mars language to even skillful programmers?

But I love the idea a symbol for an instruction.:woozy_face:

2 Likes

Back when programming was hard to learn :sweat: in 1982 when people could find jobs using assembly language, APL seemed like a beautiful thing. They made me learn it at CalPoly Pomona on special keyboards probably because IBM funded the lab. I promptly forgot it. It’s still a beautiful thing (Perl is beautiful too) but the impracticality of being too efficient and the availability of languages that manage larger systems with easier syntax like VB have made that ship sail long ago.

It seems like we are moving back to liking terse syntax again with all the interest in lambda calculus based functional programming that node.js started and has extended into all the current major languages through a ReactiveX library. I’m a much bigger fan of readability in code rather than terseness so this isn’t a great improvement in my mind.

5 Likes

In a production setting, I agree readability is more important. But for more private matters, sometimes creating the most terse program you can make you feel like an artist. It’s one of the reasons I like the more esoteric languages out there like Lisp or Forth.

4 Likes

I remember when I first learn lambda expression, it’s supper challenging to me. :dizzy_face:

3 Likes

I’d like to learn Lisp. I don’t know much about Forth.

1 Like

@Josh, I came from where students in a production background paid my bills so output instead of beauty was one of my values. But after 20 years of Java, it got so bloated and seemed destined to die a death of lack of interesting improvements. Kotlin was a breath of fresh air creating terseness sometimes by a factor of 20 and crossplatform compilation to JavaScript. But there weren’t any students interested in improving legacy code.

I also dread traditional JS coding. Had I wanted to continue web development, I would have pursued Blazor since I was fluent in C# and instead of JS code to debug, it would have produced the vastly superior WebAssembly code. Go was another option to produce wasm code but I didn’t want another C++ clone.

These are some really beautiful languages out there that can be applied now. I know the feeling of being an artist @ehcolston and it motivates me to do better code. For me, thinking about code in analysis was the canvas and the language was just the paint and the style. APL seemed like painting up close in a pointillism style like a Seurat painting.

3 Likes

I compiled some Go to wasm and it didn’t seem ready for production yet. I think the garbage collector might have been adding to the file size, and some important packages didn’t work. I guess it will be improved eventually though (or maybe I did something wrong). For C++ like, Rust is interesting.

2 Likes

It is interesting though. I wonder how one would encode all those symbols to good memory images. You would have to go and use things which have similar shapes.

3 Likes

APL is pretty cool. I haven’t used it directly, but I did learn a little of its lower-ASCII-only cousin J. There’s another branch of that family called K, which seems to be heavily used in quantitative finance.

I think we’ve only explored a little of the conciseness vs understandability curve, and it’s definitely not an inverse linear relationship. Some languages are verbose AND hard to understand, and therefore others are concise and easy to understand. However J was a bit much for me (I got lost at all the terminology of dyads and tacit forms), but I’ll probably come back to it in future.

BTW about learning the meanings, I’m not sure that mnemonics is the best way – just like with human languages, I’m coming to believe that it’s better to rely on procedural learning (by writing lots of APL programs) rather than declarative memory (memorising individual facts, like using mnemonics to learn what each symbol does).
On the topic of human languages, I think Stephen Krashen’s theories are correct, about “comprehensible input” leading to automatic fluency, compared to students trying to memorise grammar rules and vocabulary lists and coming away with extremely limited proficiency. I suspect a similar thing applies to programming languages like APL (although maybe less so, since when writing programs it’s fine to stop and think for a long time before making your next move).

There was a good video series on YouTube where someone had livestreamed his attempts to solve the “Advent of Code” puzzles from December 2020 in APL as a learning experiment. I did the same in Haskell (without streaming it, that would have been embarrassing since one of the problems took me over 10 hours), and it was a fantastic learning experience.

3 Likes

People here might be interested in this:

2 Likes

Here’s another APL link I saw today:
https://xpqz.github.io/learnapl/intro.html

Some of them look intuitive for mnemonics:

  • ⌈ — ceiling
  • ⌊ — floor
  • ∣ — absolute
  • ⍳ — index generator
  • ○ — multiply by pi
  • ↓ — drop
  • ↑ — take (mnemonic: opposite symbol of drop)

Without stickers or keycaps it might be harder to remember how to enter them though.

1 Like

Was that a challenge? :grinning:

APL function above key mnemonic
⌈ — ceiling S Sealing
⌊ — floor D Dungeon
∣ — absolute M Minus sign removed
⍳ — index generator I Index
○ — multiply by pi O Same as function operator, round pie
↓ — drop U drop in a U-shaped cup
↑ — take Y take off in flight with hands up
1 Like