4 ms·
APL is a write-only language. [1] This will be a controversial statement to devotees, but there's a simple argument that should clarify why this is true: 1. A
by civilized 5y ago
APL is a write-only language. [1]
This will be a controversial statement to devotees, but there's a simple argument that should clarify why this is true:
1. APL's inventor claims that APL is a tool of thought. Specifically, it is designed to facilitate the development of algorithms.
2. Tools of thought, like mathematical notation or writing in general, are used wherever people think.
3. When people think about algorithms, they write code or pseudo-code.
4. Thus, if APL were truly a tool of thought, it would be adopted as a pseudo-code. Academics would use it to more easily, concisely, and precisely express algorithms and programs. Software engineers would use it in their whiteboard planning. Etc.
5. In reality, essentially no one uses APL as a pseudo-code. Even by its devotees, it used exclusively as a programming language. The process of coding something into APL's idiosyncratic logography can only happen after the idea is already clear by other means. And virtually no one finds themselves understanding an algorithm via APL code which they did not already understand via more accessible languages or pseudo-code.
6. Therefore APL is not a tool of thought. On the contrary, it is what its notation indicates to virtually everyone who sees it: a write-only language.
Admittedly, there's some appeal in this idea that a super-concise notation might be a sort of life-hack for thinking about algorithms. If you could just get your brain to think in this notation, all sorts of new concepts would be accessible to you! But that's just not how reality has unfolded, at least in the case of APL. Perhaps there is a yet-undiscovered notation that truly realizes the promise of a Tool of Thought about algorithms. But I have no idea what it would be.
This letter from Dijkstra and the discussion underneath it [2] further strengthens the argument above. Note how APL is marketed as a tool of thought, but those who would teach it are distressed at the idea of teaching it without a terminal to execute it on. As Dijkstra notes, this is inconsistent with what we'd expect from a true tool of thought. Such a thing should have no trouble expressing its appeal through writing.
[1] https://en.wikipedia.org/wiki/Write-only_language https://en.wikipedia.org/wiki/Write-only_language
[2] https://www.jsoftware.com/papers/Dijkstra_Letter.htm https://www.jsoftware.com/papers/Dijkstra_Letter.htm
- pfortuny 5y agoIt may be a tool but you know? Jewelry hammers are also tools but too specific to be used by many. Guess the same happens with APL.
- keithalewis 5y agoIt is a tool of thought _for smart people_. But thanks for that, um, like, uh totally awesome Wikipedia link! +1
- civilized 5y ago> It is a tool of thought _for smart people_. As I said, if this were really true, there would be evidence of people using it to express thoughts that are too hard to express by other means. But in reality, people who think in APL just don't seem to be on the forefront of published algorithmic thought. It might be helpful to contrast APL with nonstandard analysis, a mathematical tool of thought for doing rigorous real analysis more easily. People have proved new and useful results in nonstandard analysis, and the fact that these results were first proved in nonstandard analysis is at least some evidence that nonstandard analysis served as a real tool of thought to produce those results. (To be fair, the idea that nonstandard analysis was an essentially tool in these proofs is controversial among mathematicians. But there is at least the hard fact of the results being proved first by this means.) So, if smart people are able to use APL to push the boundaries of algorithmic thought, we'd expect APL-ers to have that sort of achievement to show for it. But we don't see that. After pre-existing thoughts are translated into APL's logography, there does not seem to be any demonstrable enhancement of the ability to reason about algorithms. Or maybe there is some enhancement for that individual person, relative to their abilities without APL, but it does not seem to cause that person to rise above the general human level of algorithmic ability. "APL as a tool of thought" seems to be a beautiful theory whose predictions have not met with reality.
- patrec 5y ago> As I said, if this were really true, there would be evidence of people using it to express thoughts that are too hard to express by other means. Like Arthur Whitney you mean?
- dzaima 5y agoWhat sort of evidence are you expecting there to be? A tool of thought would usually, uh, stay as thought. I'd expect a good percentage of APL users are using it as such, but making a big deal out of that just doesn't really make any sense for any given individual. At least in the couple array language chat rooms I'm in, pseudocode-ish APL is somewhat frequently used to convey thoughts, and I certainly use arraylangs as such too. APL doesn't magically double your ability to think though. Pushing boundaries takes a lot more than raw thought power. And APL is used so little that you couldn't make any correlations even if APL increased thinking ability tenfold anyways. But it still is a very useful tool (among many other tools) from time to time. I personally don't see myself using any array language as a general purpose language for everything though. They're useful (extremely useful!) for things that map well to array operations or benefit from terseness, and anything from "meh" to awful for other things.
- mlochbaum 5y agoPoint 5 is not true. APLers regularly communicate verbally and on paper in APL or pseudo-APL. See [0], paragraph after the bullet points. I've participated in many conversations that were as much spoken APL as English, as well as heard off-hand references to writing paper notes in APL-like notation. [0] https://aplwiki.com/wiki/Edsger_W._Dijkstra#APL_by_Dijkstra.27s_criteria https://aplwiki.com/wiki/Edsger_W._Dijkstra#APL_by_Dijkstra....
- civilized 5y agoI agree #5 may not apply to some people. If a small community of people is able to use APL to do things that can't be done by other means, that would be an effective refutation of this argument, or at least an important caveat to the scope of its claims. Maybe APL is truly an effective tool of thought for at least this small group of people. I would be interested in your response to this post [1], which is on that point. I noted the Ackermann function and inverted index results in Hui's response to Dijkstra. I can't understand the APL so can't be sure how novel or significant these results are, but I would predict that such properties of the Ackermann function and inverted tables/indices would have been known long before these derivations. These may just be examples of pre-existing knowledge being encoded into APL logography. [1] https://news.ycombinator.com/item?id=28967730 https://news.ycombinator.com/item?id=28967730
- mlochbaum 5y agoI don't claim that APL is necessarily useful to everyone. I think the fraction of people who could use array-based notation effectively is not small, but there's no hard evidence for this. APL has not to my knowledge been used to prove novel mathematical results. Has any programming language? It's not very interesting to note that a language that's unknown to working mathematicians doesn't find much use in cutting-edge mathematics. However, APL is closer to the notation that is used for these discoveries than nearly any other programming language (Mathematica is the exception that comes to mind). There are some historical APL successes to point to. It was used to design IBM's highly-regarded system/360[0]; as the first APL implementation ran on the 360 this was of course done entirely on paper. I believe some early time-sharing systems were written in APL as well, though I don't have a source. STSC's Mailbox[1] was one of the earliest email systems[2]. More recently Aaron Hsu has used APL to create what seems to be the first data-parallel compiler[3]. While data-parallel is rigorously defined (polylogarithmic time given infinite processors), the vagueness of "compiler" means this isn't a result of interest to mathematicians. I myself have used APL to make what I consider to be a significant discovery about sequences of natural numbers[4]. It unifies methods that I've come up with ad-hoc in the past, and I've now used this framework dozens of times to more quickly solve a variety of problems. I don't expect you to understand the APL-heavy description, but isn't that what you asked for? I and many others think in APL. It just seems natural to us. Here's a quote along those lines[5]: > And I looked at the code that I’d written, and it’s about 150 lines or so, and it was complicated, complicated stuff. I went to sleep, and I had a dream, and in the dream, it told me how to approach this in a whole different way that I had done before. So I woke up, I sat down at the computer at six o’clock in the morning, and by noon I’d rewritten the whole thing from scratch, pretty much. I kept 7 lines of code that were tangential to that, and it was all correct. It passed the QAs like that. So sure, you can write for loops in your sleep, but I can write entire correct programs in my sleep! [0] https://dl.acm.org/doi/10.1147/sj.32.0198 https://dl.acm.org/doi/10.1147/sj.32.0198 [1] https://forums.dyalog.com/viewtopic.php?f=30&t=1629&p=6415 https://forums.dyalog.com/viewtopic.php?f=30&t=1629&p=6415 [2] https://en.wikipedia.org/wiki/History_of_email https://en.wikipedia.org/wiki/History_of_email [3] https://scholarworks.iu.edu/dspace/bitstream/handle/2022/24749/Hsu%20Dissertation.pdf https://scholarworks.iu.edu/dspace/bitstream/handle/2022/247... [4] https://aplwiki.com/wiki/Partition_representations#Unification https://aplwiki.com/wiki/Partition_representations#Unificati... [5] https://www.arraycast.com/episode-0-transcript https://www.arraycast.com/episode-0-transcript
- abainbridge 5y ago> 3. When people think about algorithms, they write code or pseudo-code. Or draw boxes and arrows on a whiteboard or pieces of paper. But I agree, they usually don't write APL or anything like it.
- adrian_b 5y agoI do not agree. I have never used an APL interpreter or compiler, but nonetheless I use it as a pseudo-code, so instead of no one, there is at least one user. Whenever people claim that APL is write-only they give some convoluted example with a bunch of obscure APL operators that are seldom used, so even for APL users it might be difficult to remember what they do. For the majority of the problems that a programmer might need to solve every day, only a small fraction of APL might be needed, which is simple to understand, learn and remember. As an unfamiliar notation, you might need to learn 5 or 6 extra operators at most and for the rest you need just use the same that you use in any programming language only with additional rules that allow more freedom than in the popular programming languages. The main difference between APL and conventional languages is that you no longer have to write "for" loops, you just write the same expressions that you would write for scalar variables. I cannot see how one would claim that omitting all the redundant boilerplate code needed by "for" loops or "map" functions decreases the readability of a program. If you do not want to learn 20 new operators, there is no need for that, the base APL language does not need them. There are only very few operators that are strictly needed, e.g. reduction, inner product, outer product, rank, index. If you like verbose identifiers you could use names for them, the symbols are not the essence of APL, only its rules for writing expressions. The 3 simplest rules are: 1. a function of 1 argument applied to an array is the array of the values obtained by applying the function to the array elements. 2. a function of 2 arguments applied to a scalar and to an array is the array of the values obtained by applying the function to the scalar and to each array element. 3. a function of 2 arguments applied to 2 arrays of identical ranks and dimensions is the array of the values obtained by applying the function to each pair of corresponding array elements. I do not see anything obscure and unintuitive in such simple rules. (It should be obvious that these are particular cases of a general rule that in a function of N scalar arguments, you should be able to replace 1 or more of the scalars with arrays of the same rank and dimensions and then the function result shall also be an array of the same rank and dimensions.) On the contrary I find it hard to understand why these rules are not valid in any programming language and you are forced in most of them to write loops for such trivial operations. There is only one real barrier for using the APL notation, but in my opinion those who surpass it are rewarded. The order of evaluation for APL expressions is different from the order learned in school, which is then extended in various way in the programming languages. In APL there are no precedence levels. The right operand of an operator is everything that is to the right, until the end of the expression. So the operators are evaluated from the right to the left (i.e. in reverse order compared to the traditional order for e.g. addition), unless you use parentheses. This order is frequently more readable than the traditional, because usually when browsing a program you do not need to read the expressions until their end. The important parts are at the left end and it is normally enough to read only those. With the traditional order you might need to scan the line much farther to the right to be sure that you did not miss something important. This obstacle of the different evaluation order discourages many of those who could benefit by using APL as a pseudo-code, but once you understand that this modified order can really simplify most expressions and you become adept at reading it as easily as the traditional order, you can use APL as a pseudo-code with good results.
- michaelfeathers 5y ago> APL is a write-only language. [1] I've never seen an argument against APL that wouldn't also apply to Kanji and Chinese script - notations with billions of readers.
- moeris 5y agoYou can write APL or J in a way that is readable. Part of the problem is that most people's exposure to array languages is in the context of code golf or leetcode-style problems. In some areas, if you're familiar with the language, it's much more readable than other languages due to being more concise. For example, if you wanted to calculate the sample standard deviation ``` mean =: +/ % # sum_of_squares =: +/@:*:@:(] - mean) stdev =: %: @: (sum_of_squares % <:@:#) ``` Is pretty readable, I think. Of course, of you don't know the primitives, then it doesn't look like it's readable. (I'm on my phone, so I may have typed something wrong.)
- Jtsummers 5y agoTwo spaces in front of each line of code to make a code block, HN does not use markdown. (_ as spaces): __mean =: +/ % # Becomes: mean =: +/ % # Don't use the surrounding ```...``` because it just becomes noise, and you don't need extra newlines, two lines of code can be adjacent to each other if you prefix each with two spaces: line 1 line 2, no extra newline was used https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc - a very short document describing all the formatting options for HN comments. There aren't many.
- kragen 5y agoAlso, Markdown doesn't support ``` fenced code blocks; that's a common misconception. I don't know which Markdown derivative originated them (maybe GFM?) but they ended up in CommonMark.
- Jtsummers 5y agoNew Reddit (aka, Really Obnoxious Interface Reddit) uses that as well. Since Old Reddit is the only useable version of Reddit (IMHO), it's really annoying to see people make such extensive use of it as it gets butchered for Old Reddit users.
- moeris 5y ago> Markdown doesn't sorry ``` fenced code blocks There isn't a single markdown. There are many different flavors, and all of them are markdown. Many include ``` (GitHub, Kdoc, pandoc, reddit, commonmark), especially as it allows you to specify the language if you want. I actually don't know if any tool I use that doesn't support them.
- pasquinelli 5y agopoint 5 should be: 5. In reality, essentially no one uses APL. and your reasoning flys out the window as a result.
- civilized 5y agoThere are many reasons people might choose not to use APL as a programming language. There are fewer reasons why they are not choosing to use it as the "tool of thought" it is supposed to be.
- shrubble 5y agoThe main problem with your thesis is that Iverson notation was used for at least 5 years prior to being turned into the programming language APL, purely as a mathematical notation. See also the 1964 IBM Systems Journal document in Volume 3, Number 3, "A Formal Description of System/360" with Iverson, Falkoff and Sussenguth as authors.
- civilized 5y agoI don't see Iverson's intentions as relevant here. He may have wanted APL to be a tool of thought, but it wasn't really picked up as such. APL the computational tool, and its descendants, can claim some successes, but the "tool of thought" concept didn't gain traction for the vast majority of technical people. It's like if an important human rights document was written in Esperanto. The document might be indisputably important, while its language and the intentions behind it are an incidental historical detail.
- rak1507 5y agoYour point 5 is completely wrong. 'The process of coding something into APL's idiosyncratic logography can only happen after the idea is already clear by other means.' In fact, often I will write something in APL before translating it to other languages, not the other way round. When I was a beginner, I did translate things as I hadn't learned to properly 'think' in APL yet. Perhaps you have tried it, and not got past that initial barrier? In which case, my advice would be to stick with it for a bit. 'And virtually no one finds themselves understanding an algorithm via APL code which they did not already understand via more accessible languages or pseudo-code.' is also untrue. An example of a time APL like notation has helped me to understand an algorithm is Kadane's algorithm for a maximum subarray sum. There are probably hundreds of articles and videos out there explaining it, suggesting that it's probably something quite a few people find unintuitive. However, in k, an APL descendant, the entire algorithm is expressible as |/0(0|+)\ To anyone who knows APL/k this is instantly readable and intuitive. This was the first thing that really made it 'click' for me. Ok, APL hasn't been widely adopted and there are definitely some downsides and problems with it, but it's still useful and definitely not write-only.
- lifthrasiir 5y ago> However, in k, an APL descendant, the entire algorithm is expressible as |/0(0|+)\ The conclusion notwithstanding, an ability to concisely express the algorithm doesn't relate to an ability to actually understand it. Personally I found Kadane's algorithm intuitive as is and the concept of partial sum seems more important for the intuitive understanding of the algorithm. Array languages are surely benefited from built-in partial sum, but that'd be arguably same for any other language with readily accessible partial sum.
- civilized 5y ago> an ability to concisely express the algorithm doesn't relate to an ability to actually understand it. Exactly! Computationally, Kahane's algorithm is only a few simple steps. It's easy to write the steps down in a few lines of any language, and equally easy to understand what the individual steps are doing. The hard part about it isn't that it's too long and needs to be compressed into 8 symbols to be understood. The hard part is understanding why it is correct.
- rscho 5y agoNice opinion piece. I think in J when doing data munging, BTW...
- xearl 5y agoi regularly use K (an APL descendant) as "pseudo-code". in fact, i regularly _think_ about problems in an array-programming fashion, heavily inspired by K. when jotting them down, i often use K. when turning them into actual code to run, it's mostly immaterial if i then use K, J, numpy, julia, etc. the general approach translates well into a multitude of array programming varieties. as such, i don't believe your point 5 holds. this way of thinking is certainly off mainstream, as is, e.g constraint programming, but there are niches where people use it highly productively. you won't necessarily glean that from the output coming from those niches, though.