Live data from Hacker News

Notation as a Tool of Thought

jsoftware.com

11–20 of 44 posts

Re: Notation as a Tool of Thought

#11
post #3
post #2

This is Kenneth Iverson's 1979 Turing Award lecture.

Yes. 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.

If 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.

Re: Notation as a Tool of Thought

#12
post #11
post #3

Earlier quoted context omitted.

Yes. 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.

If 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…

> Admittedly the J implementation at least of deriving a generalized inverse for an arbitrary function f is a somewhat ill-defined hack

Have you seen the version used by dzaima/apl[1]? The equivalent of '(-&.:{:) i.5' works and results in 0 1 2 3 _4.

> 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

Klong[2] is a partial attempt to resolve this. I won't repeat the arguments in favour of ambivalent functions, as I guess you've heard them a dozen times before

> u(f,g) = x => f^-1(g(f(x)).

Other way round; it's g^-1(f(g(x)))

1. https://github.com/dzaima/apl

2. https://t3x.org/klong/

Re: Notation as a Tool of Thought

#13
As 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

[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.

Re: Notation as a Tool of Thought

#14
I 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.

Re: Notation as a Tool of Thought

#15
post #4
post #3

Earlier quoted context omitted.

Yes. 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.

There'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 lang…

“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.

Re: Notation as a Tool of Thought

#16

As 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 experi…

Siteswap 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.

Re: Notation as a Tool of Thought

#17

I 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 t…

In 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.

Re: Notation as a Tool of Thought

#18
As 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!

Re: Notation as a Tool of Thought

#19
post #11
post #3

Earlier quoted context omitted.

Yes. 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.

If 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…

> 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?

Re: Notation as a Tool of Thought

#20

I 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 t…

My 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.

Post reply on HN