
NumPy another Iverson Ghost (2018) - tosh
https://analyzethedatanotthedrivel.org/2018/03/31/numpy-another-iverson-ghost/
======
michaericalribo
I think the J examples at the bottom illustrate perfectly _why_ it’s
preferable to force this type of array syntax into a language like Python,
rather than jumping ship for APL:

The J is inscrutable! But the Python is intuitive. Analytics code I’m writing
for work needs to not only operate on arrays, but also get the hell out of the
way! Understanding and communicating numerical routines is hard enough without
obfuscating basic procedures.

~~~
tosh
jeremy howard in one of the fastai lectures comments on what helped him to be
less scared of reading (the math parts) of papers:

learning the names of the greek and latin symbols (because then you can
pronounce them in your head!)

I have to admit this was not obvious to me before I heard it a few days ago
but it makes so much sense.

Code we can read (as in pronounce) seems less intimidating and if there are
words we might be familiar with can help (and hurt) because we associate ideas
with them.

Now I think this just underlines the beauty of APL, J, k and so on and why
they both seem so un-approachable and loved by those who immersed themselves.

obligatory link to Notation as a Tool of Thought

[https://www.eecg.utoronto.ca/~jzhu/csc326/readings/iverson.p...](https://www.eecg.utoronto.ca/~jzhu/csc326/readings/iverson.pdf)

~~~
mumblemumble
Somewhat relatedly, it would be nice to have a language with custom operators
that also requires you to annotate them with an actual word for a name. I'm
guessing it would be a boon to anyone who uses a screen reader to read code,
but would also really help others to just be able to talk about code more
easily, using more standardized language.

~~~
tosh
great idea!

------
scottlocklin
The author of this, who I know a little, maintains what I think is one of the
most important pieces of code nobody ever talks about; JOD[0]. It's an idea
that I guess used to be common in the APL world: code database. I've used it a
little, and plan on using it more and hopefully exposing it to popular
acclaim. At base, you can think of it as a fairly different way of dealing
with namespaces in a word-based language (J also has very powerful namespaces,
but I assume the ideas behind JOD predate those), but it ends up being more
powerful than that.

He's also right about Numpy. FWIIW Wes McKinney was also inspired by J when he
wrote Pandas and Arrow.

[0]
[https://bakerjd99.files.wordpress.com/2020/03/jod.pdf](https://bakerjd99.files.wordpress.com/2020/03/jod.pdf)

~~~
lordgrenville
> FWIIW Wes McKinney was also inspired by J when he wrote Pandas and Arrow.

Do you have a source for this? I always assumed it was based off of R, just
from the syntax.

~~~
scottlocklin
Source: I know Wes and talked to him about it a number of times online and IRL
(he was also pretty good pals with Kevin Lawler -we all lived in the Bay Area
at the same time: none of us do atm, which is anecdata for the perpetual
"fleeing bay area" thread). I originally got to know him as I was thinking of
participating in the startup he had done that eventually got bought by
cloudflare as he was explicitly hiring J dudes.

Anyway, ask him; he'll tell you!

data.tables in R has some strong resemblances to J notation as well; might be
one of those inevitable things (Greenspun's 10th applied to array
programming/APL), but I never talked to the author.

------
s1t5
I read the post and still have no idea what point it's trying to convey apart
from a general sense of smugness.

> At the end of my programming day, I want to look on something that is
> beautiful. I don’t particularly care about how useful a chunk of code is or
> how much money it might make, or what silly little business problem it
> solves. If the damn code is ugly I don’t want to see it.

I can't relate to this at all.

~~~
nerdponx
Seems on-brand for someone whose website subtitle is "Trust is for imbeciles."

------
stdbrouw
I don't really see the resemblance between J and NumPy the author claims is so
obvious. I mean, yeah, some of the snippets look similar but they do the exact
same basic array manipulations, what do you expect?

~~~
wodenokoto
He expects all array manipulation to originate from APL

------
isoprophlex
So theres numpy:

> b = np.arange(12).reshape(3,4)

> b.cumsum(axis=1)

or, would you prefer the following:

> b =. 3 4 $ i. 12

> +/\"0 1 b

Yeah, no thanks ...

~~~
kwhitefoot
I'm not familiar with either J or NumPy.

I have no idea what the first line does in either of these examples. And the
fact that NumPy uses an English word, axis, as a named argument means nothing
at all to me

I think it is an exaggeration to say that the NumPy is any clearer to the
uninitiated than the J. Once one has learnt J then surely it is as easy to
read as the NumPy? The NumPy just looks easier because the syntax is more
familiar.

~~~
dTal
>I'm not familiar with either J or NumPy... I have no idea what the first line
does

In that case, you owe it to yourself as a programmer to go and get familiar
with some APL-isms, for they are for numerical arrays what regexes are for
strings and are rapidly becoming ubiquitous[0]. I wowed my boss once because I
was able to mold an array into the shape we needed it in a few seconds... in
Mathematica, a language I had never used before that moment, because I knew
what to search the documentation for. It doesn't matter where you get it from,
just pick a language with APL-isms - I recommend NumPy if you like popular
stuff, and Q'Nial if you like esolangs - and work through Project Euler
without writing any loops. It'll be fun!

And of course, if you're unfamiliar with the core concepts, then naturally
both syntaxes will look equally opaque. That doesn't mean they _are_ though.
Once you understand what they are trying to express, then you will be in a
better position to judge.

[0] In Julia:

    
    
      b = reshape(1:12,(3,4))
      cumsum(b,dims=2) #Julia is 1-indexed

------
imglorp
I'm curious why APL hasn't met all the AI/ML work with Tensors. It seems like
a well suited marriage at first glance.

~~~
jpf0
I lead a company that has a large portfolio of AI/ML/optimization algorithms
in J (Monument). Happy to answer questions.

~~~
tosh
does J have support for using GPUs? or can you share a bit about how you use
J? I guess there are also some ways where GPU support is not as important
(different architectures or leaning more on transfer learning?).

can you share a bit about how you came to use J?

~~~
jpf0
We use J in all ML and data handling functions, everything except UI and viz.

We primarily focus on algorithms that require rapid sequential iteration
rather than parallelism. However: 1) we run an enhanced version of J that is
implicitly parallel on CPUs, and 2) it is possible to call GPUs (both CUDA and
openCL) through J (e.g. j-fire). We do not call GPUs or other accelerators
currently, though we may do so in the future.

Our goal with Monument is to create an Excel-like substitute for ML / AI. In
comparing across languages, we selected J as "the right level of abstraction"
for ML / AI because we wanted to write fast-running code, quickly.

J runs on virtually all CPUs and OSs, and it is highly tuned for minimized
cache misses and mis-predicted branches. It is well-documented, well-
supported, and the community is highly supportive.

Like Python, J makes it possible to run highly-optimized code without a great
deal of boilerplate in an interactive development environment. Unlike Python,
J is composed of reusable functions that readily express math. Our dev
productivity is extremely high, and often we're able to engage with
mathematicians who have little or no programming background.

Our team comprises polyglot programmers, and I strongly avoid "the language
wars," but overall we have found J to be well-suited to our needs.

------
mlthoughts2018
I would encourage the author to watch the talk “You Got What You Got” by James
Powell, on restricted computation domains.

[https://m.youtube.com/watch?v=wbYG9KTxwdE](https://m.youtube.com/watch?v=wbYG9KTxwdE)

------
bargle0
Why do so many APL articles show up on HN?

~~~
jpf0
There are interesting ongoings in array language-world.

People who do things are recognizing this.

...

