4 ms·
I've long been a big fan of APL, since I learned it many years ago. I started by studying on the classic book by Gilman and Rose and trying to use the scarce fr
by etatoby 8y ago
I've long been a big fan of APL, since I learned it many years ago. I started by studying on the classic book by Gilman and Rose and trying to use the scarce freeware/shareware implementations available at the time. At the time it was hard or impossible to get anything working for free on a Linux computer.
Nowadays there is a great, free, and actively maintained implementation: GNU APL. That, combined with the widespread use of Unicode and the APL support in Linux/XOrg keyboard definitions, make it so much easier to get started than in the past.
I have used APL mostly for fun, that is, for learning the language itself, solving mathematical puzzles, and taking part in "code golf" games. I find the language exquisite, especially its programming model based on multi-dimensional arrays, its graphical symbols, and its grammar. But it is somewhat "impractical" to use nowadays.
J is a great successor (designed by the same mastermind behind APL) but I found it harder to learn (and to read) due to its ASCII "line-noise" look and to the prevalence of point-free or tacit function definitions, which I find inferior in readability.
I'm only now learning NumPy and TensorFlow, and I bet their authors were inspired by APL.
Does anybody have any benchmarks of J's performance against NumPy?
As for K, I wouldn't recommend picking it up. It's closed-source and documentation-less, meaning good look if you run into any trouble; its error messages are notoriously infuriating; it overloads its operators with a ton of meanings, depending on context, even more so than APL and J; and its fundamental programming paradigm is not based on multi-dimensional arrays.
On the other hand, writing an APL-like frontend for TensorFlow looks like a nice project!
- etatoby 8y agoUpdate: I ran a quick benchmark (large matrix multiplication) between GNU APL, J, and NumPy (standard pre-compiled linux amd64 packages, all running single-core.) Here are the results. GNU APL (1.7) ⍴+.×⌿?2 3000 3000⍴1e10 - size 3000: 65s, 9GiB RSS (crash on bigger sizes) J (8.07) $(+/ .*)/?2 3000 3000$1e10 - size 3000: 2s, 0.2GiB RSS - size 10000: 60s, 3.7GiB RSS (crash on bigger sizes) NumPy (1.13.3, blas/lapack 3.7.1) import numpy a=numpy.random.randint(0, 1e10, (2,3000,3000)) print((a[0,] @ a[1,]).shape) - size 3000: 25s, 0.2GiB RSS - size 10000: (>15m, I killed it) 2.3GiB RSS Conclusions: J's implementation is surprisingly performant! Easily beating NumPy on speed alone by a factor of 10 or more! (And I thought blas/lapack were already heavily optimized libraries!) J's memory usage is comparable to that of NumPy. GNU APL had the worst memory and cpu profile of them all.
- etatoby 7y agoJust thought I'd add the same benchmark on the latest Dyalog APL. Dyalog APL/S-64 (17) ⍴+.×⌿?2 3000 3000⍴1e10 - size 3000: 6.6s, 0.5GiB RSS - size 10000: 101s, 5.4GiB RSS Conclusions: J's implementation is still the fastest at this particular task (matrix multiplication of huge matrices on a single CPU thread--granted, not the most significant of benchmarks.) Dyalog APL comes close behind. GNU APL and NumPy lag much more behind that.
- Volt 7y agoI'm trying this with Dyalog 16 (Mac OS X) and I'm getting WS FULL. Do you know why that might be? BTW, what kind of machine are you testing on?