4 ms·
Notation as a Tool of Thought
- azhenley 6y agoThis is Kenneth Iverson's 1979 Turing Award lecture.
- blululu 6y agoYes. There are some deep insights in this exposition. The irony is (in my opinion) APL is the worst Array/Matrix based programming language. In fairness it was also the first, but compared to Matlab or Julia it is not as expressive and feels much harder to use.
- solinent 6y agoThere's a certain mathematical elegance to APL, I think. When the language is terse enough it helps you visualize and work with the language as a tool of thought--Matlab attempts to map actual mathematics to ASCII which is not that successful for me at least, since it meets a middle ground where it's too difficult for me to think quickly purely in Matlab and it's too high level for it to be useful as a practical language. Engineers love it for prototyping, though, so maybe I just haven't worked with Matlab enough.
- blululu 6y agoFair point - personally I found APL to be a little too terse to be readable in ASCII. I think that there is a big difference in the affordances of a chalkboard/paper and a monospaced text editor, and to me APL is too close to paper based notation where it is easy to read and write a larger set of symbols. Matlab has some dedicated notation around matrices but uses more text heavy descriptions beyond that which feels better suited to a command line. Julia takes an even more text based approach and supports notations like list comprehensions which feel easier to learn, read and use than a set glyphs.
- Someone 6y ago“Engineers love it for prototyping, though” Makes perfect sense. Matlab is for engineers, not for mathematicians. They use computer algebra systems, proof assistants, etc. Difference is that engineers (and physicists) want answers and don’t care about how they are obtained, while its the reverse for mathematicians. I think APL, although it, too, is a language for computing numbers, spiritually is a bit closer to mathematics than Matlab.
- solinent 6y agoI'm a bit of both, so I guess I take the radical approach--straight from mathematics to C++/ASM/FPGA/ASIC. Ultimately programming languages are just an alternate notative system for mathematics--formal language theory actually formalizes and generalizes this, it's what us Computer Scientist's specialize in generally. Since the computer is just a glorified calculator with memory (sorry Apple), we can fit the whole thing into a formal mathematical framework.
- patrec 6y agoIf you think APL is less expressive than Matlab, you probably haven't really grasped it, IMO. Having said that, Matlab is optimized for manipulating matrices and replicating the notation of normal linear algebra and has excellent implementations of basically any numerical algorithm that frequently comes up in this . So writing something like chol(X'*X+diag(eig(X))) in an APL will look uglier and quite possibly slower and less accurate and depending on the numerical routines you need, require extra implementation work on your part. But that overhead is constant factor, more or less anything you can express well in matlab can be expressed straightforwardly in APL, too, if you have the right numerical routines. That's not true in the other direction though: there's a lot of stuff in APL you cannot express adequately in matlab at all. For example J (and these days Dyalog as well IIRC) have an operation called under which basically does this: u(f,g) = x => f^-1(g(f(x)). So you can write geometric_mean = u(mean, log). It is completely impossible to implement something like "under" in matlab. Admittedly the J implementation at least of deriving a generalized inverse for an arbitrary function f is a somewhat ill-defined hack, but this is still something that is both conceptually and practically quite powerful. Also, whilst Matlab is really clunky for anything that is not a 2D array and hardcodes matrix multiplication as the one inner-product, APL has more powerful abstractions for manipulating arbitrary rank arrays and a more general concept of inner products. Also, APL has some really dumb but cherished-by-the-community ideas that make the language less expressive and much more awkward to learn, e.g. the idea of replicating the terrible defect of normal mathematical notation where - is overloaded for negation and subtraction to every other function.
- henrikeh 6y ago> It is completely impossible to implement something like "under" in matlab. I’m a little curious about this. Does J have a notion of the relationship between certain functions and their inverse? What is it that enables “under” in J which makes it impossible in Matlab?
- klibertp 6y ago> Does J have a notion of the relationship between certain functions and their inverse? Yes. Many built-in words have inverses assigned, and you can assign inverse functions to your own words with :. https://code.jsoftware.com/wiki/Vocabulary/codot https://code.jsoftware.com/wiki/Vocabulary/codot EDIT: and here's a table with predefined inverses: https://code.jsoftware.com/wiki/Vocabulary/Inverses https://code.jsoftware.com/wiki/Vocabulary/Inverses
- yiyus 6y agoHow do you define expressiveness to arrive to that conclusion?
- alexpetralia 6y agoReminds me of these notes: https://github.com/hypotext/notation https://github.com/hypotext/notation
- emmanueloga_ 6y agoThanks for sharing! Lots of great pointers, including the stuff I commented too :-)
- emmanueloga_ 6y agoOn this subject I love this strangeloop talk [1]: the right notation allowed John Conway to solve in an afternoon a knot problem that took another mathematician (Little) 6 years to solve! Another example is juggling notation, that allowed not only the sharing of patterns but the discovery of new ones [2]. 1: https://www.youtube.com/watch?v=Wahc9Ocka1g https://www.youtube.com/watch?v=Wahc9Ocka1g 2: https://en.wikipedia.org/wiki/Juggling_notation https://en.wikipedia.org/wiki/Juggling_notation
- sxp 6y agoFor those unfamiliar with the power of APL, see this demo of someone livecoding the Game of Life: https://www.youtube.com/watch?v=a9xAKttWgP4 https://www.youtube.com/watch?v=a9xAKttWgP4 Its modern descendent are https://en.wikipedia.org/wiki/J_(programming_language) https://en.wikipedia.org/wiki/J_(programming_language) & https://en.wikipedia.org/wiki/K_(programming_language) https://en.wikipedia.org/wiki/K_(programming_language).
- moonchild 6y agoAPL itself continues to be developed; dyalog APL (the version demonstrated in that video) has added many of the features introduced by j. Roger hui (one of the original j developers) now works on dyalog. There's also bqn[0], among others. 0. https://github.com/mlochbaum/bqn https://github.com/mlochbaum/bqn
- dTal 6y agoAPL was amazing for the time, but array-oriented programming is mainstream now, while the notation never really caught on. A lot of the mystique of APL is because it's illegible, but at the end of the day it's nothing more than a DSL for 'numpy-like' code. You can code the same demo, in the same amount of time, using Julia, and the result is (in my opinion) much more legible: The opaque one-liner: using IterTools,ImageInTerminal,Colors;for g in iterated(a->let n=sum(map(t->circshift(a,t),product(-1:1,-1:1)));(a.&(n.==4)).|(n.==3);end,rand(Bool,(99,99)));imshow(map(Gray,g));print("\n\n");end The legible version where we give everything descriptive names so it's not cryptic and mysterious: using ImageInTerminal,Colors #the APL demo also uses a library for pretty display using IterTools #okay *technically* this is a minor cheat function nextgen(grid) neighborcount = sum(map((t)->circshift(grid,t), product(-1:1,-1:1))) return (grid .& (neighborcount .== 4)) .| (neighborcount .== 3) end function animate(grid) for gen in iterated(nextgen, grid) imshow(map(Gray, gen)) print("\n\n") sleep(0.05) end end animate(rand(Bool,(100,100)))
- eggy 6y agoI would argue that numpy is a dsl for apl-like code. APL and J are based on arrays at the fundamental level. J inspired Pandas per Pandas' creator. I still think learning mathematical symbols is better than spelling out mathematical formulas and likewise APL and J to me allow the same power of abstraction; it just takes some effort to learn them. A lot of friction is learning something new.
- fouronnes3 6y agoI recently came accross a math theorem that in my opinion perfectly illustrates how mathematical notation can sometimes reach harmful levels of abuse. E( E(X|Y) ) = E(X) This is known as "the law of total expectation", and as a programmer this notation is so weakly typed it makes no sense. The more correct notation is E_Y(E_X(X|Y)) If you can see that the outer E is summing over Y and the inner one over X, then the theorem is immediately clearer and very intuitive.
- Myrmornis 6y agoIn the inner expectation there’s only one choice: you’re conditioning on Y so it’s clear that X is the random variable whose expectation is being taken. In the outer expectation, there’s only one choice: X no longer exists as a potential random variable (as if it were a local variable in the inner expectation) so the outer expectation must be over Y. I’m not saying that you’re wrong that those subscripts could be used (they often are) but the meaning of the expression is clear after a little while working with expectations.
- st1x7 6y agoMy favorite example is from MIT's Intro to Probability and Statistics course: > Definition: The probability mass function (pmf) of a discrete random variable is the function p(a)=P(X=a). This only makes sense if you already know what the definition is.
- rscho 6y agoAs a lone data wrangler, I am dreaming of an "APL like R", i.e. geared specifically towards data manipulation and stats with an integrated columnar store (I am spoilt by J). People always say that such a thing will never fly in teams due to syntactic issues, but APL really is a productivity secret weapon for loners and small teams!
- chrispsn 6y agoIs it a matter of writing a comprehensive stats library?
- rscho 6y agoA comprehensive stat library for J would be close (there is an RServe lib), but the most important thing is the integrated data store. For big companies, it makes perfect sense to want a separate data store. But for small shops or loners, tight language integration is light-years better! With J, I am allowed a real database (no effing .csv) where I can use the same (terse) language as for the analysis. This is the killer feature. This is where you see that say, for example Julia, is made for serious industrial coding with teams of tens of people and not lone guys. Following the same principle, R dplyr allows you to seamlessly interact with the DB by using a translation layer. However, every time I open R I find myself having to write tens if not hundreds of loc to shape the data where I'd do that in a few lines of J. For single researchers, it's actually much easier to read your one-page of J code 6 months later than it is for your 500-loc R script (again IMO). Although I imagine it could be possible to really make a specialized APL geared towards data analysis as a strict DSL (APL is not a DSL). Meaning for example, making it more static and therefore statically compileable at the expense of losing things such as first-class environments (namespaces) or the "execute" primitive. One could also specialize the notation further towards statistics. There really is a whole realm of possibilities, here! In a word, there is a market for lone scientists. It would be nice to have tools for that market ;-)
- chrispsn 6y agoYou didn't mention it, so for avoidance of doubt: have you heard of k? Commercial k variants come with a columnar data store (see Kx's q/kdb+, Shakti's k9).
- ColinWright 6y agoAs mentioned elsewhere, the right notation[0] allowed us to discover new juggling patterns that had never been done[1][3]. I freely admit that current mathematical notation has problems, but most of the proposed reforms seem to lose the predictive and creative power, becoming mere notation and nothing more. The problem is that without experiencing that extra dimension it's impossible to see that, and you can't experience that extra dimension without investing the time and effort to learn mathematics to a significant level. Tricky. [0] https://www.numberphile.com/videos/juggling-by-numbers https://www.numberphile.com/videos/juggling-by-numbers [1] As far as we know. Without the notation we don't actually know what had been done, but when I took the new patterns to juggling conventions, no one knew them[2]. [2] Actually it's stronger than that. I showed people some of the new patterns at the British Juggling Convention in 1985 and no one knew them. Then at the European Juggling Convention just 4 months later, people from the USA were proclaiming them as the latest patterns that they had just learned, and were perplexed at how I not only knew them, but knew many, many more. [3] And actually Paul Klimek had beaten us to it, but hadn't been able to get others interested in the notation. As far as we can tell, Paul was the first to get the notation.
- fouronnes3 6y agoSiteswap is really wonderful. It's so good that many nerd jugglers (myself included) enjoy reading about weird and extreme patterns that are way beyond our skills (or even human skills) but technically possible.
- derangedHorse 6y agoI feel like this ties back to making general abstractions that anyone can make for any field. Software engineering is littered with abstractions to the point where 2 similar functioning applications can look wildly different when looking at their respective code bases. Even the abstractions we build into programming languages invites a certain way of thinking which is why there’s so many different paradigms like functional, imperative, logic, declarative, etc.
- jkhdigital 6y agoTuring machines all the way down... for every Turing machine there are an infinite number of alternative descriptions that provide the same result.
- cs702 6y agoIverson's famous paper introducing APL. A key takeaway for me is that computers make it possible to have unambiguous notation. Quoting from Iverson's paper: "The thesis of the present paper is that the advantages of executability and universality found in programming languages can be effectively combined, in a single coherent language, with the advantages offered by mathematical notation." Ambiguity is a real problem with much of conventional mathematical notation, which has evolved in fits and starts throughout history. Mathematical symbols are used, reused, and overloaded with different meanings again and again, in so many ways, that context is often necessary for understanding. Ambiguity hampers the use of mathematical notation as a tool for thought. The other big takeaway from this paper, for me, is that succinctness makes it easier to reason. That is, programming languages that enable us to express more with less code make it easier for us to reason about -- and with -- code.
- bjourne 6y agoI have thought about this in relation to chess. Most of us play chess by looking at an 8x8 black-and-white grid with pieces on it. That is a two-dimensional notation capable of expressing any chess position (castling, en passant, repeat-moves etc, excepted). What if you could invent a more efficient "notation" for chess? For example, FEN is a chess notation that is very efficient for computers. So maybe something similar exists for humans? Perhaps a three-dimensional notation, or perhaps a rearrangement of the board using knight moves and octagons instead of squares. Knights can jump in eight directions at most so a board using octagons would make it easy to see where they land.