6 ms·
APL is an awesome language with one glaring flaw. It's impossible to read and you need a special input method to type. I enjoy reading about it but I can't imag
by zaphar 11y ago
APL is an awesome language with one glaring flaw. It's impossible to read and you need a special input method to type. I enjoy reading about it but I can't imagine I'd ever enjoy having to work with it.
- murbard2 11y agoThat's two glaring flaws. You may want to try J, which only has one glaring flaw.
- yummyfajitas 11y agoOr numpy, which from what I can tell is basically a readable version of J. As a concrete example, I've gotten partway through translating the APL examples in "Notation as a Tool of Thought" (http://www.jsoftware.com/papers/tot.htm http://www.jsoftware.com/papers/tot.htm) into numpy, and they work pretty much unchanged. If anyone knows APL/J/K well, and could show some programs where idiomatic APL/J/K does not directly translate into idiomatic numpy, I'd love to see them.
- murbard2 11y agoThey have vectorization in common, but the commonalities really stop there.
- yummyfajitas 11y agoCan you suggest a simple program for which idiomatic J differs significantly from idiomatic python/numpy? As I said, I've been unable to come up with one, or find one in aforementioned paper.
- murbard2 11y agoSure, this is how you compute Hofstader's Q sequence in J Q=: 1:`(+&$:/@:- $:@-& 1 2)@.(>&2)"0 M. http://rosettacode.org/wiki/Hofstadter_Q_sequence#J http://rosettacode.org/wiki/Hofstadter_Q_sequence#J
- Avshalom 11y agoI cant speak for J but this is the first APL program I ever wrote (it's in Dyalog) it take a wolfram code on it's right and an array of 1s and 0s on the left and returns the next generation for that one dimensional automaton (it treats the world as wrapping but it would be easy to clamp the sides to 1 or 0): ODAT ← {(⊂[1] ¯1 0 1 ⌽ (3,⍴⍵)⍴⍵) ∊ ((8 ⍴ 2) ⊤ ⍺) / ⊂[1] 2 2 2 ⊤ ⌽ 0,⍳7 } as a traditional function with comments and stuff its: NG←R ODAT S;N;P;PS ⍝ First construct the eight *P*ossible states: ⍝ Creates an array 7 6 5 4 3 2 1 0 (⌽0,⍳7) and converts to binary (2 2 2⊤) ⍝ 1 1 1 1 0 0 0 0 ⍝ 1 1 0 0 1 1 0 0 ⍝ 1 0 1 0 1 0 1 0 ⍝ Then encloses along vertical axis (⊂[1]) P←⊂[1]2 2 2⊤⌽0,⍳7 ⍝ Convert the *R*ule from wolfram number to binary ((8⍴2)⊤R) ⍝ 110 becomes 0 1 1 0 1 1 1 0 ⍝ Then choose *P*ropogating *S*tates (/P) PS←((8⍴2)⊤R)/P ⍝ Take *S*tate and triplicates ((3,⍴S)⍴S) and rotates (¯1 0 1⌽) to create a matrix ⍝ each colume is a cell and it's *N*eighbors ⍝ A state 1 0 1 1 0 0 becomes: ⍝ 0 1 1 0 0 1 ⍝ 1 0 1 1 0 0 ⍝ 0 1 1 0 1 0 ⍝ Then encloses vertically again N←⊂[1]¯1 0 1⌽(3,⍴S)⍴S ⍝ Now we have two arrays: ⍝ *N* which is the current generation of state/neighbor triplets ⍝ *PS* which is the triplets that produce a live cell in the *N*ext *G*eneration. ⍝ we create a new array by testing for membership (∊) of current generation ⍝ and *P*ropogating *S*tates NG ← N∊PS Some of that might be idiomatic python but the thing is I didn't write it as the multi-line function. I wrote it by modifying the one line function. Which I did because that's how APL's data-flowy syntax/semantics encourages you write things and doing that in one line sure as hell isn't idiomatic python. The determined programmer can write any language in any language. It's what we write when we aren't being determined fortran/smalltalk/whatever programmers that speaks to the difference in programming languages.
- vezzy-fnord 11y agoYMMV, but I find the readability of J and K to be far worse precisely because of the ASCII charset instead of the glyphs. The APL glyphs give me a concrete context switching mechanism that I'm operating within its "alphabet" and the semantics thereof. Whereas because I associate ASCII characters with plenty of other meanings already, I find J and K to look like complete line noise in comparison.
- joe_the_user 11y agoIt seems like translating J or K to a glyph format for reading would be a relatively simple matter.
- murbard2 11y agoWould have to be a one to many relationship. Part of the problem with K is that the meaning of an operator depends on the type of the operands. "?" can be "generate a random number" or "search for an element in a list" for instance. And yes, that is insane.
- joe_the_user 11y agoWell, a parsing display system still sounds like a reasonably simple piece of software. Still, while I met J author Roger Hui years ago in college, I've never run a line of J so I probably would be the one to create such a system.
- zaphar 11y agoIf we are being precise then It's two symptoms of the same flaw.
- vezzy-fnord 11y agoThis is a Solitaire game in Dyalog APL, ostensibly: http://aplwiki.com/SolitaireGame http://aplwiki.com/SolitaireGame It's certainly esoteric, but I wouldn't say it's unreadable. Given that APL is like a programming alphabet of sorts, it'd be interesting to see how quickly and tersely one could put together infrastructure with it. Too bad it has virtually no ecosystem.
- hirsin 11y agoReadable, understandable even (with a lot of "I bet this symbol does this"), but not writable. It may not be a meaningful comparison, but the commenting on the side is more reminiscent of assembly than a high-level language (i.e. the code itself is not sufficient to tell you what it's attempting to do). Is this how well-commented most APL turns out, or is this due to being a teaching piece of sorts?
- JasonFruit 11y agoOnce you get accustomed to it, it's not really that hard to read. My problem is that I get unaccustomed to it really fast.
- woofyman 11y agoI haven't done any APL since college in the late 70's. We used Decwriters http://www.columbia.edu/cu/computinghistory/la36.html http://www.columbia.edu/cu/computinghistory/la36.html that had the special APL character set.
- Dewie3 11y agoNon-standard character set aside; is the terseness (one-letter commands and such) partly because of the slow input devices at the time?
- mollmerx 11y agoI believe it's more likely to be partly related to the small console sizes that were typical at the time. I don't think typing was slower then. And most programming time isn't spent typing.
- Avshalom 11y agoThe terseness is because it was originally developed to be written on a blackboard while lecturing. As CS developed in the math world Iverson realized that the existing math was crap for describing computational processes. So he made his own and as it turned out it, with a little modification it was executable.
- RBerenguel 11y agoI have a secondary keyboard input method on my Mac for when I'm in APL mode. It just remaps my keyboard, and once I got used to it I know where most commands are (the basics, sure, some I have used less are harder to come by but I'm getting there slowly.) It's kind of learning vim or emacs: once you get the bindings you just forget about them and know by feel.
- brudgers 11y agoUnicomp sells USA layout APL keycaps. http://www.pckeyboard.com/page/Buttons/USAPLSET http://www.pckeyboard.com/page/Buttons/USAPLSET