Hacker News new | past | comments | ask | show | jobs | submit login

A bit more convincing: http://www.kparc.com/edit.k

Properly formatted and with comments, it almost looks readable.

The insistence to use one- or two-letter identifiers that you then have to look up the meaning of in a comment makes it look pretty childish, though. "Look ma, it's still super terse even when doing something real!" Yes kid, it is when you refuse to do the one obvious thing that could actually make it readable.




Single-letter identifiers are a natural thing to object to when coming from other language paradigms, i.e. nearly every programming background out there, but this is a category error. What seems ridiculous in one context can be sensible in another. The objection turns out to be parochial.

It reminds me of how people think that parentheses are a significant aspect of Lisp, when in practice they're not. The parens look grotesque at first, but once past the novice stage they fade completely into the background and impose no cognitive overhead. Because of their regularity, the parens free you to program without thinking about syntax, allowing you to think more about the problem at hand—a highly liberating experience—yet to someone who hasn't worked with the language long enough to get that experience into muscle memory, they look absurd.

Short identifiers are preferred in APL-style languages because longer ones obscure the code. As you get familiar with the idioms of the language, you can pick them out in visual chunks to grok what a program is doing. You're not reading the program operator-by-operator, but phrase-by-phrase.

That wouldn't work if the programs used longer identifiers, because then the programs would consist mostly of identifiers, making it harder to scan the phrases, making it harder to grok the code. That's why people don't do it. You can simulate that in more familiar languages:

  for (ridiculously_long_name = 0; ridiculously_long_name < 100; ridiculously_long_name++)
No one writes like that because beyond a certain length, the identifiers distort the code. That's what's going on in APL languages too; it's just that the "certain length" turns out to be 1 or 2.

In other words, the reason why APL-style programs adopt this style is not because the programmers are childish, but because the ergonomics of the language make it optimal. This is hard to understand, but only because mainstream languages have completely different ergonomics.


Writing APL (or J/K) with the ascii character set is like coding C in Morse code.

I wrote plenty of J code for my masters in particle physics and the only way I could use it without going insane was to write a noweb filter for literate programming when using latex symbols for the functions. The woven document was close to mathematics, the actual source code was editable source code.


One or two characters for identifiers is optimal? What kind of programs are being written with APL/K? At some point you'll have more concepts in your program that available letters unless you're dealing with tiny programs.


The more experienced programmers in this thread can answer this better, but I believe top-level functions tend to get longer names.


Are APL programs normally clumped together, as they are commonly presented to show off their terseness, or do they normally have comments and line breaks to indicate structure?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: