Hacker News new | ask | show | jobs
by jjmaestro 3045 days ago
I've read a bit about APLs and I've seen them popping up in HN a few times. They do seem incredibly awesome and the products around it (K/KDB+ etc) amazing.

However, in case I ever felt like learning one of these, I'd always wanted to know: the syntax crazyness, "a la brainfuck", is it a feature? a bug? Is it really needed? Can't they make an APL "look like Python" but using the same concepts, etc? Or is it "a thing" / something ultra-core to these languages, to be extremely terse / cryptic and intensely dense (each line packs a ton of punch!)?

e.g. just read http://www.jsoftware.com/help/dictionary/didot.htm and some of the stuff in there can be translated quite well:

i. 5 --> list(range(0, 5))

i. _5 --> list(range(0, 5))[::-1] or list(range(4, -1, -1))

i. 2 _5 --> [list(0 + j, 5 + j)[::-1] for j in range(0, 10, 5)]

P.S. any pointers to content / books about the philosophy and ideas behind these programming languages are welcome! :D

5 comments

Certain things translate, but not everything. In J when almost everything is an array and you're using points free form, you can pretty much combine everything without having to build classes...etc. Those python examples are much longer even for simple stuff. As far as books go, Dyalog APL has "Mastering Dyalog APL" for free and although Dyalog costs money, a hobby license is free. There is a guy who writes programming languages and books for a living. He recently wrote an array language called "Klong" and a book on it. J has several books. There's not a whole lot on the philosophy, but using it teaches you what you need. It looks like line noise at first, but you start to recognize idioms and phrases. Aaron Hsu did two HackerNews discussions on here and a YouTube broadcast on his "co-dfns" GPU compiler for Dyalog APL. That was pretty amazing. He talks about trying to write it in Scheme, Java,etc...but APL lets him put it all on a few pages to where he sees everything at once. At his level, abstractions aren't necessary.
I did a cursory Google search for Klong after your mention. The author of the language (and its book) posts his writings to t3x.org

Thank you for the brief mention -- I've been perusing his website and writings and am enamored. There's something about niche, obscure tools (and their authors) that give me some profound joy.

I was thoroughly impressed as well. It would take me years to read all his stuff. Klong us actually written in his other language. That is impressive.
The density is very much a feature. Some previous discussion from an APL'er about this:

https://news.ycombinator.com/item?id=13565743

https://news.ycombinator.com/item?id=13797797

For the ideas and philosophy behind J have a look at the paper [Notation as a Tool of Thought](http://www.eecg.toronto.edu/%7Ejzhu/csc326/readings/iverson....) by Kenneth Iverson. He originally presented this paper as his Turing Award Lecture in 1979.
I prefer J for this specific examples. The python versions rely on 'non-obvious' syntax with the ::, and argument ordering to the range function.
> The python versions rely on 'non-obvious' syntax

...really?

Look, I like APL and J much more than the next guy, but I can't find a single angle from which that is a reasonable argument.

> Can't they make an APL "look like Python" but using the same concepts, etc?

Perl 6 has some APLish array-oriented features in something arguably closer to what is common syntactically. Of course, it's not an APL with alternative syntax, but an extremely multiparadigm language with that as one of many influences.

People make fun of Perl6 for adding Unicode operators, variables and such like having them would just be totally insane when APL has been doing that since the 60's and it works well lol.