18 ms·
APL deserves its renaissance too (2018)
- kmstout 4y agoSuppose you have a couple graphs, represented by adjacency matrices (A and B) whose cells represent travel times or distances or some other notion of cost. Assuming their dimensions are compatible, and that the columns of A correspond to the same nodes as the rows of B, then A ⌊.+ B will produce a new adjacency matrix (call it C) where each c_ij is the minimum traversal cost from node i to node j. For example, if A represented driving times from all cities in NY state to all airports in NY, and B represented direct flight times from all NY airports to all CA airports, then our result would be the minimum travel time (ignoring parking and security) between any NY town and any CA airport. The sequence `⌊.+` is an inner product chosen specifically to achieve this effect, with addition where multiplication would normally be, and ⌊ (min) where multiplication would normally be. Notice that it took me longer to give this under-caffeinated explanation of what is going on than to write the code.
- actually_a_dog 4y agoSo, if I understand correctly, your APL code translates to the following Mathematica code: Inner[Min, A, B, Plus] where B = Transpose[A] ?
- abrudz 4y agoIf anything, you'd need B = Transpose [B] as A and B are not related.
- Qem 4y agoCan APL be used for symbolic computations, like Mathematica or Sympy, or is it practical just for numeric code, like Matlab or Numpy?
- abrudz 4y agoSome tools for symbolic computations have been written in APL, but APL doesn't provide such capabilities out of the box.
- nequo 4y ago> The sequence `⌊.+` is an inner product chosen specifically to achieve this effect, with addition where multiplication would normally be, and ⌊ (min) where multiplication would normally be. Sorry, it is early for me too. I am wondering if there is a mistake here. Do you mean that addition is where multiplication would be and min is where addition would be? The regular inner product would be C_ij := \sum_k A_ik B_kj and the modified one is C_ij := \min_k (A_ik + B_kj) ?
- mcabbott 4y agoI presume so. Note that this pseudo-code is very nearly valid Julia code (with my package): @tullio (min) C[i,j] := A[i,k] + B[k,j]
- deleted 4y ago[deleted]
- misja111 4y agoSorry but to me this looks like a cool language to play code golf, but a terrible language to use in production. It feels like obfuscating your own source code.
- avmich 4y agoThis is an executable math. Consider the program a mathematical expression - or a set of them - which produce useful values.
- michelpp 4y agoYes, multiplying graph adjacency matrices over a min-tropical semiring produces shortest paths. APL supports this syntactically, but how does it function in the real world? What if the matrices are extremely sparse, like almost all real world graphs are? Syntax is the easy the problem. The hard problem is having very sparse graphs with billions of nodes and many billions of edges. How is a square matrix going to deal with that? Sparse and hypersparse graph computing is hard, which is not syntactically relevant. Python does not have this terse a syntax, but it gets very close with multiple bindings to the SuiteSparse GraphBLAS Hypersparse graph processing libraries, which intrinsically supports sparse graphs and a very large number of operators, including the tropical min/max ones. Suitesparse doesn't provide syntax (that's the easy part), it provides the hard part, sparse and hypersparse data structures and very complex dynamic, parallel graph processing optimizations including JIT compilation of GPU accelerated operations. Here's a notebook that shows your shortest path example using Python and the GraphBLAS. While it's a trivial example, it can scale the the largest graphs possible to use today using SuiteSparse: https://github.com/Graphegon/pygraphblas/blob/main/demo/Introduction-to-GraphBLAS-with-Python.ipynb https://github.com/Graphegon/pygraphblas/blob/main/demo/Intr... NB: I should clarify I'm not advocating for Python's syntax in particular vs APL, I'm saying that syntax is not the hard part of any particular problem, especially when it comes to sparse graphs. There are also other binding to GraphBLAS like Julia that are quite nice. I do appreciate that APL does elgantly permit the notion of graph operations with linear algebra.
- krackers 4y agoThis is basically floyd-warshall, right?
- krackers 4y agoHm wait floyd-warshall is subtly different from regular matrix multiplication with (+, *) replaced with (min, +). We're accumulating into the existing matrix so the order of loop iteration matters, it has to be {k, i, j}. As such I'm not sure how C_ij := \min_k (A_ik + B_kj) would work to give all pairs shortest path, since in floyd-warshal the results of C[i][j] at iteration k depend on C[i*][j*] for k-1 being computed, which is not true for the above where C_ij can be computed independently of all others. It seems like it _is_ possible to easily express APSP via an inner product with (min, +), but it's less efficient than floyd warshal. Whereas floyd warshall asks "What's the shortest path from i to j using vertices in {1..k}", if you instead ask "what's the shortest path from i to j of length at most k" and then use repeated-squaring you can get the answer in n^3 lg(n). See http://users.cecs.anu.edu.au/~Alistair.Rendell/Teaching/apac_comp3600/module4/all_pairs_shortest_paths.xhtml http://users.cecs.anu.edu.au/~Alistair.Rendell/Teaching/apac... https://cse.buffalo.edu/~hungngo/classes/2004/531/notes/floyd-warshal.pdf https://cse.buffalo.edu/~hungngo/classes/2004/531/notes/floy... https://resources.mpi-inf.mpg.de/departments/d1/teaching/ss12/AdvancedGraphAlgorithms/Slides14.pdf https://resources.mpi-inf.mpg.de/departments/d1/teaching/ss1... https://www.cs.utexas.edu/~ecprice/courses/randomized/fa15/notes/lec14.pdf https://www.cs.utexas.edu/~ecprice/courses/randomized/fa15/n...*
- krackers 4y agoAlso https://www.csd.uwo.ca/~mmorenom/HPC-Slides/apsp-mm.pdf https://www.csd.uwo.ca/~mmorenom/HPC-Slides/apsp-mm.pdf
- akavel 4y agoThe tutorial of the recently posted BQN variant of APL (https://news.ycombinator.com/item?id=33180842 https://news.ycombinator.com/item?id=33180842) is super approachable and written so nicely, that I couldn't resist being drawn in - I highly recommend checking it if you're even slightly "APL-curious". The first part is at: https://mlochbaum.github.io/BQN/tutorial/expression.html https://mlochbaum.github.io/BQN/tutorial/expression.html
- redrobein 4y agoBQN is great, but I rarely get to use it for anything... useful. I hope the ecosystem and tooling around bqn will get better in the future. I would like to see something like what dyalog is to apl for bqn. A jupyter notebook style ide+repl (maybe a bqn for of RIDE), libraries for common scripting tasks, embedding (a la lua) in more languages, maybe even a way to compile to libs so you can call bqn code from other languages. I'd definitely use it more if it was open to more use cases.
- avmich 4y agoHave some experience with J, would like to comment. > A jupyter notebook style ide+repl (maybe a bqn for of RIDE) J terminal looks pretty close. > libraries for common scripting tasks There are phrases (see www.jsoftware.com), but for many tasks it seems not many libraries are actually needed. > embedding (a la lua) in more languages, maybe even a way to compile to libs so you can call bqn code from other languages There is a way to call C from J and vice versa; not too convenient maybe... but still quite possible. APL languages don't benefit much from compilation, J interpreter is very fast.
- jjtheblunt 4y ago> APL languages don't benefit much from compilation Is the idea because most the action is in already compiled datastructure manipulations, in the standard library, specified by the terse source?
- 4y ago
- lokedhs 4y agoThere is a lot of development happening in the area of APL-insipred programming languages. I've spent far too much time working on an APL dialect that allows you to combine APL with imperative structures at the same time. I really need to document it better though. https://aplwiki.com/wiki/KAP https://aplwiki.com/wiki/KAP Then there is April, which is a very neat version of APL that is implemented in Common Lisp. It allows you to miss Lisp arrays with APL arrays, giving you the best of both worlds. It's very functional even now: https://github.com/phantomics/april https://github.com/phantomics/april And of course, BQN is a new language that takes a lot of the good ideas from APL but also changes a lot of the symbols. It's a very nice language: https://mlochbaum.github.io/BQN/ https://mlochbaum.github.io/BQN/
- adenozine 4y agoWhat about using like a Wacom drawing tablet in order to interact with APL? I've never tried any of the Iverson-verse languages but the non-ascii inputs seem daunting and cumbersome.
- linguistics__ 4y agoMost editors let you use an input prefix, so typing `y gets you ↑ for example. Makes it a lot easier
- pavlov 4y agoMost typing in the world today is done on virtual keyboards on touchscreens. I’ve always hoped someone would make an APL for iOS and Android. The code density and use of symbols seems like a good fit for small touchscreens.
- kkylin 4y agoCame here to say exactly this -- an APL-like notation + programming environment would seem to be a great way to program on a tablet + stylus. I'd love a notebook environment where I can mix equations, doodles, executable code, & their output.
- jodrellblank 4y agoWhat about using gesture recognition on a smartphone or tablet? It could become a useful portable calculating/coding app that doesn't need much typing. I know there are J apps and web APLs available, but not gesture ones that I know of.
- petercooper 4y agoThe only time I see APL is each year during Advent of Code – https://adventofcode.com/ https://adventofcode.com/ – APL users always pop up and manage to solve the most complex of tasks with about ten symbols versus everyone else's 50 lines of Python :-)
- marginalia_nu 4y agoI tried to do AoC in sed one year. Didn't get all the way through. Real turing tarpit sed is. My solutions had the readability of APL and the brevity Java. Mistakes were made.
- vanderZwan 4y agoI'm not sure if I should be in awe or feel sorry for going to that level of programming masochism in one's spare time. Probably both.
- jd3 4y agoI enjoyed russ cox's advent of code series using rob pike's ivy (https://github.com/robpike/ivy https://github.com/robpike/ivy), an apl-like calculator https://www.youtube.com/playlist?list=PLrwpzH1_9ufMLOB6BAdzO08Qx-9jHGfGg https://www.youtube.com/playlist?list=PLrwpzH1_9ufMLOB6BAdzO...
- shadytrees 4y agoThis is what got me and my friend into APL-likes. My friend even made an APL-like towards the end. I assert that APL is one of the main, definitional pillars of programming languages, the way Lisp and C and Prolog are. It is extraordinarily easy to build an APL with scalar and vector support -- once you start thinking about higher-dimensional data structures, though, it is the ergonomics and the design that become subtle and tricky. (Ivy, in particular, does some questionable things at with multi-dimensional matrices.) Also, if you think of APL operators as verbs, perhaps there should be adverbs that lift the verbs up into higher dimensions...
- deleted 4y ago[deleted]
- diego_moita 4y agoAPL died for the same reason Perl is fading: it is a write-only language. Those symbols look cool. But they're not very far away from Brainfuck.
- Ygg2 4y agoAt least Brainfuck didn't require a custom keyboard. https://en.m.wikipedia.org/wiki/APL_(programming_language)#Hardware https://en.m.wikipedia.org/wiki/APL_(programming_language)#H... Or today, custom keyboard mapping.
- UncleEntity 4y agoI actually want to get a custom APL keyboard, mostly for the cool factor, but it turns out they’re kind of pricey.
- TeMPOraL 4y agoLet's be fair. APL is write-only whereas e.g. Python is not, only in the same sense math notation in scientific papers is write-only whereas elementary school summation is not - the former is much more ergonomic once you have the prerequisite knowledge and experience, but most people only need the latter to conduct their business.
- randomdata 4y agoIf a programming language can be written it can be read, but readability refers to enjoyment. Everyone has a hobby, but I don't think the masses would ever find reading Brainfuck enjoyable even if they were experts who coded in it every day. Whereas there are languages that are geared towards readability, with talented developers working in those languages, when combined are able to produce something that is something you would be glad to sit down and read; up there with the best novels of our time.
- TeMPOraL 4y agoTherefore my comparison with mathematical notation. It can be used to write beautiful things, but the reader needs to have some knowledge to understand it and appreciate its beauty. Most importantly though, the density/opaqueness of the notation is what allows it to lift powerful ideas - to express in few lines what would otherwise take many pages. It's not brevity for brevity's sake - it's understanding the limits of human working memory. The more verbose a description gets, the harder it is to work with it, until at some point, you just can't process it at all (at this point people start making indexes or developing notation to... make things more concise). Comparing APL with Brainfuck is just ridiculous. The former is designed to be dense to enable efficient work; the latter is a joke that's designed to be sparse.
- ninkendo 4y agoI disagree. The terseness of APL is the worst part about it. Its arcane symbols are a close second. I don't want my programming language to be as terse as possible. I want it to be easy to read and maintain. I don't see how APL is a step in the right direction at all, and IMO should just be relegated to the dustbin of history as a failed experiment.
- nudpiedo 4y agodon't you. think you can become better at it after some practice? let's compare that with mathematics notation or whatever... APL has less symbols than java's String methods.
- seanmcdirmid 4y agoAPL could serve the niche as a write only language. Not for code to be maintained, but for one offs. Of course, those one offs inevitably become code to be maintained, so maybe this niche doesn’t really exist.
- generalizations 4y agoIt would also be a phenomenal spreadsheet language. the terseness means we get more visible code per cell block, the default data types mesh well, and the numerical orientation of the language is ideal.
- forrestthewoods 4y agoWe already have regex for unmaintainable, read-only code.
- seanmcdirmid 4y agoregex isn't a programming language, it is a language for describing strings that can be recognized by finite automata.
- memorable 4y agoAPL (and probably many languages in the Iversonian family) are more geared towards expressiveness, although terseness plays a large part of the language design. Also, once you understand the rules of these languages when parsing expressions (which is always right-to-left unless the case of a parenthesis) and all the symbols, readability become less of a problem. As for maintainability, well, it kinda depends on you and whoever is going to maintain it. I do agree that the arcane symbols of APL is a minus, though. Which is why languages like J, K and Q are born: to make APL ASCII-friendly. Generally speaking, this seems to me like a comment from someone who doesn't give APL more than a cursory look. And if that relates to you, please, try APL, or any other languages in the family, just even once. You _may_ change your view about it.
- kuwoze 4y agoit's called q https://code.kx.com/q/ https://code.kx.com/q/
- gamingproapk2 4y ago[dead]
- bobterryo 4y agoThere are two J apps for the iPad and iPhone. One for J704 and one for J904 even though it has J901 as the name. https://apps.apple.com/us/app/j901/id1483497239 https://apps.apple.com/us/app/j901/id1483497239
- bear8642 4y agoHmm, feel q looses APL and K's conciseness with the ability to express yourself within a few characters rather than whole words
- kuwoze 4y agoWell, the article said "renaisance" not "copy"
- shin_lao 4y agoKDB+, using Q, is heavily inspired by APL. Great to look smart, might make you productive, horrible for cooperation, maintenance nightmares, heavy technical debt. I'll pass, but you do you.
- jd3 4y agoI remember reading the manual for arthur whitney's shakti/k9 and seeing this normative claim: > Learning k9 means code like {x@(!#x)+\!#y} is clear and actually prefered to something much longer and verbose. https://estradajke.github.io/k9-simples/k9/index.html https://estradajke.github.io/k9-simples/k9/index.html All I could think of was Abelson/Sussman's evergreen quote from the preface of SICP: > Programs are meant to be read by humans, and only incidentally for computers to execute.
- shin_lao 4y agoLots of respect for Arthur, KDB+ was transformative when it arrived but I think now we need to move beyond that. Will take one or two decades for banks to migrate though lol.
- steveBK123 4y agoIt's also a misunderstood product from the outside. Unfortunately banks had a tendency to pay a bunch of senior engineers to do a build out for 3 years and then turn it over to cheap nearshore consultants to operate for 10 years. The core of most big bank code you see was written before 2010. Where I have seen bakeoffs and largely failed attempts to replace, the challenge is the number of vendor & open solutions you need to cobble together to replace all the use cases that KDB supports. Every year it was a slightly different combination that didn't really cover all the bases. To replace KDB in many of these large use cases, you need - a fast columnar PB-scale database, an efficient on-disk store, a fast in-memory cache, SQL support plus with expressive query language additions for time series operations, an event bus, a stream processor, and a programming language to write more complex applications close to the data. A lot of the newer cloud-centric offerings are more about massive parallelism/scale than about pure single thread/individual request-response performance. This is great for the vast majority of CRUD apps with millions/billions of users. It's even great for some financial "backtesting" type use cases where you can kick off large It generally isn't sufficient for many of the real-time financial use cases of doing ad-hoc analytics on billions/day datasets with expected responses in ms. The biggest complaints are its expensive, and the devs are expensive. On the other hand you usually don't need as much hardware or dev staff to support it.
- vindarel 4y agoAPL + Lisp = O_o https://github.com/phantomics/april/ https://github.com/phantomics/april/ and yes it is used in production©! > What pushed the development of April really is that April is used by a hardware startup called Bloxl (of which I am the CTO). There are other users but Bloxl is the flagship application. https://www.arraycast.com/episodes/episode23-andrew-sengul https://www.arraycast.com/episodes/episode23-andrew-sengul Bloxl in use: https://user-images.githubusercontent.com/3721004/159686845-b562d37b-209c-49aa-a001-7115053cbe0c.png https://user-images.githubusercontent.com/3721004/159686845-... See also the ELS conference 2022.
- bakul 4y agoThere was a paper in 1993 about "APROL: a Hybrid Language" that combines an array processing language and a dialect of Lisp (Scheme) in a consistent and useful manner. Seems like April is much further ahead!
- andsoitis 4y agoI particularly liked this principle from the article: "learning all the alien symbols is a one-time investment, and expressiveness — the leverage you as a programmer gain — is for life."
- tgv 4y agoAllow me to disagree. The page presents toy examples, and those are already unreadable. APL lacks data structures, modules, exception/error handling and typing. Well, since almost everything is a matrix of floats, perhaps typing isn't needed, but that idiom just deteriorates readability. You might think of it as a "bc" on steroids, but a rebirth for APL is uncalled for.
- abrudz 4y agoMulti-dimensional arrays provide all sorts of data structures, but modern APLs have also have namespaces/dictionaries, classes with inheritance, etc. Oh, and APL has had exception/error handling since the ’60s, with today’s APLs having rather flexible systems for this.
- MarkusWandel 4y agoAPL is from an era where impressively functional code that looks like line noise (another obsolete concept) was considered heroic. Other examples of such code are text editing and text formatting macro languages. Recall that EMACS stands for "Editor Macros" because that was its original implementation. Back then, computers were so limited relative to human capability that this was still a good thing. Those days have gone. The bizarre syntax of APL has had its day. Its powerful array manipulation primitives can easily be brought forward into a language with modern syntax, and haven't they? In my company there is a lot of Matlab usage but I'm personally not knowledgeable.
- mlochbaum 4y ago> Its powerful array manipulation primitives can easily be brought forward into a language with modern syntax, and haven't they? Kind of. The languages that one might expect to do this (Julia, R, NumPy) have picked out a few things from APL in an inconsistent way, leaving a lot as well. For example most are missing the generalization of prefix sum that APL calls "scan". So in [0], Conor was able to translate some code to every language in the APL family but not yet any outside of it. Another one, I don't think I've ever seen Replicate[1] outside the APL family. It's a generalization of filter to take an arbitrary count instead of 0 or 1 that's often useful if you know about it. [0] https://github.com/codereport/array-language-comparisons/blob/main/comparisons/leetcode/P1614_Max_Paren_Depth.md https://github.com/codereport/array-language-comparisons/blo... [1] https://mlochbaum.github.io/BQN/doc/replicate.html https://mlochbaum.github.io/BQN/doc/replicate.html
- ohbtvz 4y agoI can't make head or tails of the first links, so I'll leave experts to it. The second one, yeah, it's nice syntaxical sugar, but it can be replicated very easily (map + "constant list" + concatenate). And versions of it exist in many languages - even C# has SelectMany https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.selectmany?view=net-7.0 https://learn.microsoft.com/en-us/dotnet/api/system.linq.enu...
- 4y ago
- dncornholio 4y agoToo much magic. I don't feel any fulfilment from knowing quirks of a specific language that not many others know. A waste of time IMHO. Is it still pretty cool? Yes I think so.
- pjmlp 4y ago> Even Haskell not only gained popularity on its own but deeply influenced F# and Scala. The influences came from Standard ML and OCaml, primarly. F# started its life as OCaml.NET.
- TurboHaskal 4y agoWell, it won't happen. The language is too weird and for a language these days to make it, it has to target the lowest common denominator of developers. Let's say you're at work, and you casually mention to your team something about APL, ATS or Agda. How many were excited about it? How many did roll their eyes? Yeah, I thought so.
- deleted 4y ago[deleted]
- neves 4y agoFast.ai steals a lot of ideas from APL: https://forums.fast.ai/t/apl-array-programming/97188 https://forums.fast.ai/t/apl-array-programming/97188 I've programmed in APL last millennium. It is hell.
- maxbond 4y agoIs the adoption of matrix oriented languages like Mathematica or Octave not the APL renaissance?
- __rito__ 4y agoYou can get everything there is in APL, plus no weird symbols in the J programming language. > learning all the alien symbols is a one-time investment No one time investment is needed if you want to learn J. And yes, it does teach you to think in a new way. I am not kidding. You can see the plethora of (mostly free) books available at the website [0]. Learning J has given me "enlightenment" at the same level The Little Schemer has given me. (I don't recommend APL to anyone as you need to learn and painstakingly slowly insert those symbols. If you want to learn array thinking, go straight to J. Why waste time and headspace with APL symbols?) [0]: https://code.jsoftware.com/wiki/Books https://code.jsoftware.com/wiki/Books
- abrudz 4y agoWell-chosen symbols aid thinking about the concepts. That's why mathematicians don't write their formulas in ASCII. Once you learn the keyboard layout, it is faster to type APL than J's two-glyphs and three-glyphs.
- __rito__ 4y agoKen Iverson invented J after he worked on APL and according to him J is an improvement upon APL. Most people don't know about J, but know about APL because of those weird symbols. I agree with your thoughts that not everything should be ASCII (and this is what many comments on this thread don't see), but don't reach the same conclusion as you do.
- abrudz 4y agoThe core language of J was an improvement on the APL back then, but modern APLs have since borrowed many features from J. Iverson's choice of ASCII was because he wanted to make it more accessible to schools that couldn't get the equipment necessary to display APL glyphs. Note that J was released the year before Unicode.
- ssfrr 4y agoThe use of ASCII was a concession to the state of technology at the time. I don't think he actually preferred the ASCII digraphs to APL glyphs.
- liminal 4y agoThis is great. I just wish the page fixed the GoL equation at the top of the page so I didn't need to keep scrolling back and forth.
- skruger 4y agoThere are a lot of comments of the type "it's unreadable/write-only/unmaintainable" here. It's a natural reaction; I know, I was there. It looks different. But readability is in the eyes of the beholder, not the language. I made this point in my APL book (https://xpqz.github.io/learnapl https://xpqz.github.io/learnapl) -- just because I can't read Japanese does not make Japanese unreadable. Since I wrote that book, I've spent a few years immersing myself in APL, gradually rewriting thousands of lines of Python into APL, and it's such a productivity boost. My code is an order of magnitude smaller. More, sometimes. Fast, too. For the right use cases, it's unbeatable. Sure, you probably wouldn't want to write an OS kernel in it, but anything that reads a bunch of data, mashes it up, and spits out some result, APL is a hand-in-glove fit. And with modern SIMD processors, APL really screams. https://xpqz.github.io/learnapl https://xpqz.github.io/learnapl https://xpqz.github.io/cultivations https://xpqz.github.io/cultivations Drop in on https://apl.chat https://apl.chat if you're interested.
- ohbtvz 4y ago"Fast" is not relevant - the runtime would be just as fast if the code was written in plain words. Code size is also irrelevant unless you're called Elon Musk. The only claim left is that it's a productivity boost, but I just can't see how a language that needs a special keyboard to be written can be written more productively than actual words, especially with modern IDEs.
- abrudz 4y agoI type each APL symbol with a single chord, e.g. ∊ is AltGr+e and ⍷ is AltGr+Shift+E. Each keystroke is basically instant.
- MichaelCollins 4y agoYou don't worry about repetitive strain injury from all that chording? I try to avoid that sort of thing as much as possible; even though I use emacs, I do it with evil bindings. Capslock rebound as control is useful, but the bottom row modifiers seem problematic. I can't easily reach those modifier keys while also keeping my fingers on the home row; I have to either contort my thumb or pinky in a bad way, or move my entire hand (which is usually how I use those keys.) Either way, keeping hands straight and my fingers positioned on the home row seems much safer and comfortable. I just can't imagine using a language where I have to altgr for every character I type.
- nine_k 4y ago«APL has flourished, as a DSL embedded in a language with excellent I/O. It's just got weird syntax and is called Numpy. Or Tensorflow. Or PyTorch...» (https://news.ycombinator.com/item?id=17176147 https://news.ycombinator.com/item?id=17176147 4 years ago)
- hoosieree 4y agoAny sufficiently complicated (linear algebra system) contains an ad-hoc, informally-specified bug-ridden slow implementation of half of (APL). With apologies to Phillip Greenspun. https://philip.greenspun.com/bboard/q-and-a-fetch-msg?msg_id=000tgU https://philip.greenspun.com/bboard/q-and-a-fetch-msg?msg_id...
- GnarfGnarf 4y agoThe practical working set of English is about 60,000 words. In theory, every word does not need to be more than four characters (26^4 = 456K). But we don't do that. Because the brain needs redundancy. Ditto source code.
- avmich 4y agoSomehow math notation seems not to fit to this theory.
- mark-r 4y agoI had to use APL once back in the 1970's, because I needed the graphics capabilities of an IBM 5100. I managed, but it wasn't a pleasant experience and I've felt no compulsion to repeat it. I admit it was kind of cool to be able to operate on whole arrays at a time, but nowadays I can do that with Python's numpy.
- rbanffy 4y agoOnly with beam-spring keyboards, like the original.
- sudosysgen 4y agoA lot of people in finance like to us q, an APL derivative with some more functional programming facilities, so in that sense it's had a mini-renaissance.
- haolez 4y agoStop it! I have a lot of real work to do, but my urge to binge "J for C Programmers" is getting harder and harder to control :)
- deleted 4y ago[deleted]
- __rito__ 4y agoThe book "Easy J" is also great (and binge-able) to start J with.
- KingLancelot 4y agoIs the author insane?
- ilyt 4y ago> life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵} Nope, it should be burned in fire. > Roughly 86% of all the fun you get from APL programming comes from the mysterious symbols and the magic behind them. It’s not that APL is alien to computers, it’s just the computers were alien to APL for quite a while. That's being alien to humans my dude. If understanding syntax is heaviest mental exercise in programming language it is unexcusably terrible. It should be considered torture to even require someone to read it.
- abrudz 4y agoHave you even looked into APL's syntax? It is really simple.
- ilyt 4y agoSo is brainfuck. Orders of magnitude simpler, in fact.
- deleted 4y ago[deleted]
- jodrellblank 4y ago> life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵} > "Nope, it should be burned in fire." With a glance at it, things jump out: ¯1 0 1∘.⊖ ¯1 0 1∘.⌽ ⊂⍵ that's rotating a matrix by one cell left, same, right: to make three matrices, then shifting those three up and down by one place to make nine with the 'surrounding squares' of each cell. Like so: mat ← 3 3⍴ (0 0 0 0 1 0 0 0 0) mat ┌→────┐ ↓0 0 0│ │0 1 0│ │0 0 0│ └~────┘ ¯1 0 1∘.⌽ ⊂mat ┌→────────────────────────┐ │ ┌→────┐ ┌→────┐ ┌→────┐ │ │ ↓0 0 0│ ↓0 0 0│ ↓0 0 0│ │ │ │0 0 1│ │0 1 0│ │1 0 0│ │ │ │0 0 0│ │0 0 0│ │0 0 0│ │ │ └~────┘ └~────┘ └~────┘ │ └∊────────────────────────┘ ¯1 0 1∘.⊖ ¯1 0 1∘.⌽ ⊂mat ┌→────────────────────────┐ ↓ ┌→────┐ ┌→────┐ ┌→────┐ │ │ ↓0 0 0│ ↓0 0 0│ ↓0 0 0│ │ │ │0 0 0│ │0 0 0│ │0 0 0│ │ │ │0 0 1│ │0 1 0│ │1 0 0│ │ │ └~────┘ └~────┘ └~────┘ │ │ ┌→────┐ ┌→────┐ ┌→────┐ │ │ ↓0 0 0│ ↓0 0 0│ ↓0 0 0│ │ │ │0 0 1│ │0 1 0│ │1 0 0│ │ │ │0 0 0│ │0 0 0│ │0 0 0│ │ │ └~────┘ └~────┘ └~────┘ │ │ ┌→────┐ ┌→────┐ ┌→────┐ │ │ ↓0 0 1│ ↓0 1 0│ ↓1 0 0│ │ │ │0 0 0│ │0 0 0│ │0 0 0│ │ │ │0 0 0│ │0 0 0│ │0 0 0│ │ │ └~────┘ └~────┘ └~────┘ │ └∊────────────────────────┘ How much work is that in Python? Compare with this Python Game of Life found on the internet[1]: https://gist.github.com/amankharwal/e04369de79c4060fb7edab5c29ea22b7#file-game-of-life-py https://gist.github.com/amankharwal/e04369de79c4060fb7edab5c... and see that this part overlaps with their line 8, finding the neighbours of a cell: neighbors = [(1,0), (1,-1), (0,-1), (-1,-1), (-1,0), (-1,1), (0,1), (1,1)] Quick, are their tuples correct or did I sneak in a mistake? Easier to eyeball ¯1 0 1 for correctness, right? The whole APL expression is shorter than their line 14 to copy the board: copy_board = [[board[row][col] for col in range(cols)] for row in range(rows)] with its five variable names (easy to mistake col/cols and row/rows), four keywords, chained indexing inside a nested list comprehension. That's Followed by 12 more lines of code dense with 0s, 1s, <, >, >=, ==, row, rows, col, cols, neighbour, neighbours - quick are they all typo-free and all the comparison and boundary cases correct with no off-by-ones? That leaves ∨.∧ as something weird, but it's short so you can try https://aplcart.info https://aplcart.info see if it's a known idiom or part of one, and if not it won't be much effort to type into a REPL like https://tryapl.org https://tryapl.org and play with. You can make some boolean arrays to try it in a few characters. What if you don't understand the Python code, how much more work is it to extract it into a test file and make test data and some print functions for it? > "If understanding syntax is heaviest mental exercise in programming language it is unexcusably terrible. It should be considered torture to even require someone to read it" The syntax is not the hard part, "how does this data transform solve the game of life" is the hard part, and hiding the data transform in a torrent of fluff like "(r < rows and r >= 0) and (c < cols and c >= 0) and (copy_board[r][c] == 1)" is inexcusably terrible. Details are what computers are good with, and what people are bad with. High level transforms is what people should focus on and tools should enable. [1] https://thecleverprogrammer.com/2020/12/25/game-of-life-with-python/ https://thecleverprogrammer.com/2020/12/25/game-of-life-with...
- dang 4y agoand has for a while: APL deserves its renaissance too - https://news.ycombinator.com/item?id=17173283 https://news.ycombinator.com/item?id=17173283 - May 2018 (118 comments) (Reposts are fine after a year or so - https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html - especially about APL.)
- agumonkey 4y agoAaron Hsu tried with some level of success. https://duckduckgo.com/?q=aaron+hsu+apl&t=ffab&iax=videos&ia=videos https://duckduckgo.com/?q=aaron+hsu+apl&t=ffab&iax=videos&ia...
- bbanyc 4y agoI've dabbled in APL, and a couple of jobs ago I worked extensively in kdb/q. I found it to be an immensely powerful tool in its natural environment of time-series processing, and extraordinarily painful to use outside that domain. Typically I'd write the core logic in q with a small wrapper in Java or Python to do string formatting and other tasks that kdb falls down on. Which is fine. Not every language needs to do everything. Horses for courses.
- smasher164 4y agoI like Ivy's[0] approach by using keywords instead of symbols. I feel like something like APL should either be embedded in some host language, be given lots of functionality for I/O, or some static type system with rank polymorphism. [0]: https://github.com/robpike/ivy https://github.com/robpike/ivy
- shadytrees 4y agoI agree!! I think having APL be a embedded domain-specific language is the perfect fit. I don't want to give up record and union types when I'm programming something large; but some piece of the app I'm writing will want to perform vector math or compute order statistics, and for that there's nothing better than APL. Note that Python and numpy is shockingly close to this state of the world already: Python's the general language, and numpy is the beautiful vector escape hatch. If only Python and numpy were statically typed.
- robomartin 4y agoNo, it does not. I used APL professionally for about ten years (early '80's to early '90's) for a range of applications spanning various business applications, industrial automation and DNA sequence analysis used in the Human Genome Project. The language is/was fantastic. It truly is a tool for thought. How about the funny symbols? I see this type of comment all the time. If you think this way, you lack context. The notation is an important element of APL's value proposition. You cannot understand this by watching an APL video on YouTube or running through a tutorial. I equate it to something like using vim. People who have casual contact with it absolutely hate it. Those who commit and develop the skills and mental automation have a very different perspective. From that context, someone saying "vim's cryptic keyboard commands and states are horrible" sounds, well, I'll be kind, uninformed. And yet, my first sentence implies I think APL does not deserve to exist. Which is it? I firmly believe the future of advanced types of software engineering will require a form of notation in order to effectively communicate and describe computational solutions. What comes to mind is AI/ML. I think APL needs to mutate and evolve into being the tool that is best-suited for solving complex AI/ML problems. If this can happen, the notation will be critical and just as important as it is in mathematics or music. I think the issue might be that we don't yet know enough about this evolutionary stage of AI/ML to understand what kind of programming notation we might need to invent. This isn't well defined at all. For the most part, AI/ML is exactly where it was in the 80's and 90's. We have faster computers with massive resources. Yet, if you go back to books on AI dating back to the 80's you will be surprised to learn we haven't really invented much in the last few decades. This three volume set on my bookshelf is a good reference dating back to the early '80's: https://www.sciencedirect.com/book/9780865760899/the-handbook-of-artificial-intelligence https://www.sciencedirect.com/book/9780865760899/the-handboo... In fact, if you read through it you'll discover just how much was done in the '70's and '60's. So, yes, I would not use or recommend APL for any modern project. It's a liability from an ROI perspective. In addition to this, the pool of capable APL software engineers is microscopic. That is a huge problem. APL does not make business or technical sense and cannot compete with modern tools, their libraries and the large pool of capable programmers who can use them.
- sedatk 4y agoAPL feels like the ideal language for AI to write code with.
- tabtab 4y agoThere are implementations/dialects of APL that use "ASCII-friendly" operation names. The "J" and "K" language are examples.
- rdm 4y agoThat's a cute writeup, but the author overlooked some important bits of history. For example, the original use of APL (before it was called APL and before anyone had implemented it as a programming language -- the reason Iverson joined IBM) was to specify the IBM 370 machine architecture. In other words, it was being used to document how the CPU worked. And it was impressively successful there, distilling a large body of documentation into 2 pages. This reduction in cognitive load, describing machine structure, is what made it popular back then. And this is what motivated the effort to implement it as a programming language. (Also, if I understand correctly, there's also a relatively short and direct step from APL to the initial implementation of SQL.)
- jodrellblank 4y agoThe original use was to "to implement the world's first graduate program in "automatic data processing"" at Harvard; Fred Brookes volunteered to join in and "It was in this period that Iverson developed notation for describing and analyzing various topics in data processing, for teaching classes, and for writing (with Brooks) Automatic Data Processing. He was "appalled" to find that conventional mathematical notation failed to fill his needs, and began work on extensions to the notation that were more suitable." Then "Iverson joined IBM Research in 1960 [...] he was allowed to finish and publish A Programming Language and (with Brooks) Automatic Data Processing, two books that described and used the notation developed at Harvard. [...] At IBM, Iverson soon met Adin Falkoff [...] Chapter 2 of A Programming Language used Iverson's notation to describe the IBM 7090 computer. In early 1963 Falkoff [...] proceeded to use the notation to produce a formal description of the IBM System/360 computer then under design." - https://en.wikipedia.org/wiki/Kenneth_E._Iverson#Harvard_(1955%E2%80%931960) https://en.wikipedia.org/wiki/Kenneth_E._Iverson#Harvard_(19...
- account-5 4y agoI intend to learn an APL at some point. I'm an avid listener of the Array Cast podcast [0]. Can't say I u derstand all of what they talk about but I definitely feel like APL has its place for number crunching. [0] https://www.arraycast.com/episodes https://www.arraycast.com/episodes
- amelius 4y agoI love the keyboard. Wouldn't it be nice if modern programmers had some more symbols at their disposal?
- auggierose 4y agoI am using a Stream Deck for that. Should have bought the largest one, but even the medium size on is quite useful via nested menus. Here are some symbols I am using for a formalisation in Isabelle currently: ∀∃⊤⊥𝔇𝔄≽⇒𝒰υτ↣𝟭‹›∅×∈⊆
- privong 4y ago> I am using a Stream Deck for that. Something like the DuckyPad[0,1] might work for that as well. I haven't tried using mine for APL or anything like that, but it's been great for use as a "Zoom meeting control", numpad, and MacOS shortcut pad. [0] https://github.com/dekuNukem/duckyPad/ https://github.com/dekuNukem/duckyPad/ [1] https://www.tindie.com/products/dekuNukem/duckypad-do-it-all-mechanical-macropad/ https://www.tindie.com/products/dekuNukem/duckypad-do-it-all...
- orangepurple 4y agoYou could probably get it working on any keyboard with Autohotkey on Windows Ahk can override keyboard button presses with just about anything and you can use a layer key as a modifier
- amelius 4y agoxmodmap in Unix/X11 also. But I'd really like a language that comes with its own keyboard :) I mean, other people should be able to edit my code.
- orangepurple 4y agoProvide a copy of your ZMK keymap file and a recommended build target alongside your software (lol)
- claudiawerner 4y agoAPL looks like a lot of fun, and I've tried to get into learning it for a while, but it's a shame that the most popular implementation is proprietary, and GNU APL is a dialect which is not as featureful and a separate dialect of APL unto itself, so it's not as though you can write a reasonably sized APL program with Dyalog and then expect it to work in GNU APL.
- icen 4y agoYou can download a copy of Dyalog for free, if availability is the issue. If it's licensing/a desire to use open-source software, perhaps taking a look at its close relatives of J, or BQN, would be reasonable? * Dyalog https://www.dyalog.com/download-zone.htm https://www.dyalog.com/download-zone.htm * J https://code.jsoftware.com/wiki/System/Installation/J903/Zips https://code.jsoftware.com/wiki/System/Installation/J903/Zip... * BQN https://mlochbaum.github.io/BQN/index.html https://mlochbaum.github.io/BQN/index.html All of the languages and implementations have their differences, but they are all driving toward the same ultimate goals.
- smartmic 4y ago"The GNU APL interpreter is an (almost) complete implementation of ISO standard 13751 aka. Programming Language APL, Extended." [1] GNU APL is closely following the APL2 standard [2], Dyalog has lots of (proprietary) extensions. APL does not have its roots in the FOSS world, all the more the efforts to provide and maintain a powerful, free option here are to be supported. It is not self-evident that there are always free software alternatives available. [1]: https://www.gnu.org/software/apl/ https://www.gnu.org/software/apl/ [2]: https://www.ibm.com/downloads/cas/ZOKMYKOY https://www.ibm.com/downloads/cas/ZOKMYKOY
- claudiawerner 4y agoOh, I didn't know that. Looks like I was completely wrong about GNU APL. Thanks for the links.
- mlochbaum 4y agoThe standard for APL2 is quite old and doesn't reflect the state of commercial APL at all (Dyalog is the only one with significant development now but APLX and APL+Win kept it going through the 90s). For example, GNU doesn't have control structures so you are expected to program with the branch statement, APL's version of go-to. It also has various extensions of its own, including some that are based on Dyalog but not compatible. It's the only dialect that I would recommend against; I believe April, NARS2000, and dzaima/APL are all better despite various issues.