9 ms·
APL Demonstration (1975) [video]
- dang 7y agoA thread from 2014: https://news.ycombinator.com/item?id=7817593 https://news.ycombinator.com/item?id=7817593
- spectramax 7y agoThe clarity, simplicity and minimal didactic approach towards making old instructional videos is gone now. We have subscribe/hit-the-bell reminders, annotations, background music, sponsorships, intro and exit greetings and all kinds of unneeded bullshit in video production. Commercialization of video has ruined this art form. Just compare early Mythbuster episodes to something from 2016. Production quality has horrendously degraded. The money is where the masses are and the masses want entertainment, not education.
- codesections 7y agoAs cool as this is, APL has improved a lot in the 34 years since that video was made. Most notably, these days, APL has `direct functions`, which enable a degree of concision and tacit-programming support unmatched in any other programming language (yes, including Haskell). As a minor taste of the power of direct fns, here's a naive implementation of the Fibonacci sequence with one: `fib←{1≥⍵:⍵⋄(∇⍵-1)+∇⍵-2}`
- jodrellblank 7y agoTrying to pick up some APL over the last year, I've found it mildly annoying to find APL code without explanation. I'm expecting that's fine for experienced users, even trying to work it out is useful, but it's hard to get to a point of being able to do that without some hints. This fib code in the parent comment translates to: def fib(n): if (1 >= n): return n else: return fib(n-1) + fib(n - 2) and it does so with: fib ← { "scriptblock" function declaration implicit variable name ⍵ (omega) for the right side argument 1≥⍵ : ⍵ guard case, if 1>=⍵, return ⍵ ⋄ statement separator, like ; in C-languages if no guard clauses matched, remaining code runs ∇ recursive call to the function it appears in ∇(⍵-1)+∇⍵-2 fib (⍵-1) + fib (⍵-2) } More notably, the kind of tacit programming support looks like this: (××∘⌊|+1≤2||) N Rounding to nearest even number (favouring away from 0) which evaluates to a function that takes N on the right, and the tacit train looks like this, from TryAPL.org visualization: ┌─┼────┐ × ∘ ┌─┼───┐ ┌┴┐ | + ┌─┼───┐ × ⌊ 1 ≤ ┌─┼─┐ 2 | | <- N goes in here The tree evaluates from the lower right. Each triple is a fork, N goes into the right prong, the left prong, then the result of both of those goes into the center prong. Unless there's a constant on the left prong, then that's used as-is. So: |N for the magnitude; 2|(that) for the remainder of dividing by 2; 1<=(that) to find whether to add 0 or 1 for the rounding, (|N)+(that) to re-do the magnitude of N and add the 0 or 1. xN to get the direction +1 or -1, multiplied by the floor of the calculated result. N enters in several places, which avoids having to store temporary variables and name them, when you aren't actually interested in new variables. And this works on a single number, a vector or multi-dimensional matrix of numbers.
- kazinator 7y agoThat's an example of what I call "stupid terse". When comparing program length, we should count tokens, not characters. We should give a penalty to excessively long tokens, of course, like pointlessly_long_variable_or_function_names. Say, any token longer than 8 characters counts as two tokens. Any longer than 16 counts as 4 and so on, exponentially. Pairing tokens like { } and ( ) can count as one for the pair. In syntax like f(x, y), the () are essentialy one operator denoting function application, spread out to enclose the arguments. Your APL fib←{1≥⍵:⍵⋄(∇⍵-1)+∇⍵-2} has 19 tokens. jodrelllblank's Python: def fib(n): if (1 >= n): return n else: return fib(n-1) + fib(n - 2) has 27. There is a bit of verbiage with the colons, the else punctuation and the explicit return commands. TXR Lisp: (defun fib (n) (if (plusp n) n (fib (+ (pred n) (ppred n))))) has 21 tokens (or, if you will, nodes in the syntax tree). Only two more over APL, and provides a clear function definition from which we know it takes exactly one required argument, which is given a name. It exhibits no ambiguities.
- robocat 7y ago> When comparing program length, we should count tokens, not characters. GP said APL had "concision" and you then replied about measuring tokens, ended up using some personal ƒ(tokens,nodes,symbols) for reasons I can't fathom. > It exhibits no ambiguities What ambiguities are present in the APL function? If you answer, please write clearly, because I know nothing about APL (I was watching the video for my own didactic purposes). > That's an example of what I call "stupid terse". That seems needlessly provocative to me. Edits: clarity. I think I would like the function definition to be written a little more clearly, but I would need more interaction with APL authors to understand their communication norms for their language.
- kazinator 7y ago> What ambiguities are present in the APL function? For instance: ∇⍵-2 is that ∇(⍵-2) or (∇⍵)-2? If something similar to ∇⍵-2 appears but with another symbol in place of ∇, does it parse the same way? (I'm not even certain that the ∇⍵-2 excerpt is a syntactic sub-unit that is valid on its own.)
- AlexCoventry 7y agoIn case anyone else is curious, but having trouble parsing that, "1≥⍵:⍵" means "return the input ⍵, for ⍵≤1", "⋄" is a statement separator, and "(∇⍵-1)+∇⍵-2" effectively means "otherwise, return fib(⍵-1)+fib(⍵-2)". ("∇⍵-2" means "∇(⍵-2)", because, as mentioned in the video, APL expressions are evaluated right-to-left.) The {} indicate that this is a function definition: https://www.gnu.org/software/apl/apl.html#Section-3_002e7 https://www.gnu.org/software/apl/apl.html#Section-3_002e7 My initial take on this, at least, is that it seems pretty reader-hostile. Maybe you get used to it, though.
- dTal 7y agoThat is truly beautiful. I already loved APL, from a distance as it were, but this gives me renewed respect for it.
- segmondy 7y agoIt's as reader hostile as mathematics symbol is reader hostile. It's not English, it's not meant to be read like a novel but to be read and understood like mathematics. One of the frustrating thing about programming in English like languages is that words might not mean what they claim to mean. Written language is very ambiguous. Nothing from stoping me from writing something as not_true = true; if (not_true) { ... }. or calling something manager or a process when it's neither. Easy to read and pronounce but harder to digest. The idea of APL is that once you understand the symbol like maths, it's unambiguous, if you can parse it, you can understand. There's no crazy naming to confuse you.
- AlexCoventry 7y agoProgramming is generally not mathematics, though. Usually, you're doing something considerably more complex, though also more concrete.
- yeellow 7y agoI have a feeling that apl (or j) based calculator app (with buttons for all fancy symbols) could be something. All those nice powerful one liners seem to be suited for such app. I wonder if something like that is available. I know there is j for Android, but having a nice closed interface focused on short clever code would be fun.
- codesections 7y agohttps://tryapl.org/ https://tryapl.org/ gets 70% of the way to what you're talking about (though it's obviously missing the closed-interface-focused-on-calculator-functionality part)
- deleted 7y ago[deleted]
- TurboHaskal 7y agoI have J and Retro (it’s a Forth but they’re similar in spirit) on the iPhone. Doing programming puzzles with those on the train is fun and you don’t have to type much.
- synthmeat 7y agoI've mentioned to others this already, but I'd pay good money for real APL pocket calculator.
- agumonkey 7y agoI grew up with a HP48g and for some reason I never considered a handheld APL. That would be the only thing to match HP RPL :)
- agumonkey 7y agoJust in case, Aaron Hsu made a bunch of talks about APL https://www.youtube.com/results?search_query=aaron+hsu https://www.youtube.com/results?search_query=aaron+hsu It's a bit caustic to the mainstream (beauty, terseness over ease and variable names) but I personally find it tickles all my boxes.
- nulldata 7y agoAaron Hsu's work has truly inspired me, and expanded my horizon when it comes to code and programming in general.
- agumonkey 7y agoI too want my algorithms to fit in a less than a java method name size
- nickpeterson 7y agoI'll also note, I emailed him a random question and he spent a non-trivial amount of time answering it and just came off as a legitimately decent and helpful person. So piling on, I'm also a fan now.
- dang 7y agoHe did a couple major discussions on HN a couple years ago: https://news.ycombinator.com/item?id=13565743 https://news.ycombinator.com/item?id=13565743 https://news.ycombinator.com/item?id=13797797 https://news.ycombinator.com/item?id=13797797
- agumonkey 7y agoThanks I missed those
- coldpresent 7y agoI find that his mentioning of "monadic" and "dyadic" instead of "unary" and "binary" interesting, why did he mention those?
- nprescott 7y agoAs far as I know, this is a peculiarity of APL resulting from Iverson's stance on the language as a "tool for thought"[0]. The best explanation I've heard is that "binary" is most apt to number systems (or matrices!) - but a "verb" in APL is not binary, it is dyadic. The language of verbs and nouns is a similar reflection of the ideas that APL is primarily a _language_ (like English, more so than Fortran) to express mathematics succinctly (with a minimum of ambiguity or syntax). This is (to me) even more apparent in his next language, J; where he sought to "correct" deficiencies in APL and further expanded the "language" to include things like "gerunds"[1] more explicitly, which are nominally (as defined in an English dictionary): > a noun formed from a verb, denoting an action or state Which may be summarized somewhat unsatisfactorily as: "Because Ken said so". [0]: https://www.jsoftware.com/papers/tot.htm https://www.jsoftware.com/papers/tot.htm [1]: https://code.jsoftware.com/wiki/Vocabulary/GerundsAndAtomicRepresentation https://code.jsoftware.com/wiki/Vocabulary/GerundsAndAtomicR...
- mjn 7y agoIt's not totally APL-specific terminology, although it's uncommon in other areas of computer science. You can find it (predating APL) in areas like mathematical logic, where a predicate over two terms is sometimes called a "dyadic predicate". I'm guessing Iverson was familiar with that usage and extended it to APL. I wouldn't read too much into it though. It's mostly just Latin vs. Greek roots (unary, binary, ternary are Latin; monadic, dyadic, triadic are Greek).
- TheRealDevonMcC 7y agoIt's also likely that his usage preceded the more common one prevalent now.
- narrator 7y agoAPL made a lot more sense in the era of 110 baud teletypes.
- deleted 7y ago[deleted]