3 ms·
From the way I often use Haskell, Matlab, and even crazy shell one-lines with lots of pipes, awk, sort, and other stuff, I often have the impression that array
by anyfoo 4y ago
From the way I often use Haskell, Matlab, and even crazy shell one-lines with lots of pipes, awk, sort, and other stuff, I often have the impression that array languages are exactly what I'm looking for for certain problems.
The question is... which array language should I pick? What are the reasons to pick one over the other?
- Avshalom 4y agoJ i guess. https://www.jsoftware.com/#/ https://www.jsoftware.com/#/ I don't really like J but the only serious APL left is the proprietary (though free, and fun) Dyalog; K, the official product, is also proprietary and because Arthur rewrites it every couple of years all the open source clones are of different versions so there isn't much of an ecosystem.
- anyfoo 4y agoHmm, so why J over Dyalog APL then?
- Avshalom 4y agoit's libre and gratis, if that's not something that bothers you (and to be sure if you're just writing code for your own edification it's not a practical problem) then i would recommend dyalog, although as a side effect of being open J has a (perhaps only slightly) larger free ecosystem and community. the down side is that subjectively some people (myself included) find J uglier, less effective as a tool of thought and due to some syntactic features (hooks and forks, but no proper lightweight anonymous function syntax)-prone to people posting impenetrably dense code as "examples"
- anyfoo 4y agoI see, thanks! Looks like I might try both. The "no proper lightweight anonymous function syntax" sounds weird to me, I would have thought that's paramount for an array language? Do I misunderstand?
- Avshalom 4y agoIn J if you want to do something fairly complex without writing a function you can pile up a bunch of verbs/operators into a big (point free) verb-train. You can't do recursion, loops or explicit flow control but in the Array Languages that's not much of a handicap, it can get pretty hairy to read though In dyalog you can (as of about v13) do that if you want, or you can just use curly brackets { and inside of them have lexically scoped variables, multiple expressions, recursion and if/then (no loops either though) }
- jpf0 4y agoJ recursion is $: You can do flow control in both scripting style and array style. Loops are loops.
- Avshalom 4y agois $ meaningful in verb trains? because that was what I was referring to when I said no loops/recursion/flowcontrol N.B. a sibling says J has added a direct definition construct while I wasn't watching which renders my comment largely irrelevant although the I feel general point that a lot of J 'example code' tends towards difficult-for-noobs to parse verb trains still holds.
- jpf0 4y agoYes. this one is fun. Recursive, memoized Fibonacci, the 155th integer precisely. {{(-&2 +&$: -&1) ^: (1&<) M. y}} 155x It'll run in your browser in 0.003 seconds. https://jsoftware.github.io/j-playground/bin/html2/#code=%7B%7B%28-%262%20%2B%26%24%3A%20-%261%29%20%5E%3A%20%281%26%3C%29%20M.%20y%7D%7D%20155x https://jsoftware.github.io/j-playground/bin/html2/#code=%7B...
- moonchild 4y agoThis was true historically, but recent versions of j introduced a 'direct definition' syntax similar to dyalog's dfns.
- Qem 4y agoDo you know if it's available from GNU/Linux repositories? One thing that bothers me with single letter language names is that it makes searching information cumbersome, due to lots of noise in search results.
- jim-jim-jim 4y agoI had a similar feeling, but ultimately found Haskell more maintainable. If you write it point-free with well chosen symbolic operators, it winds up being the best of both worlds. Not that I have any firsthand experience with the matter, but I think Morgan Stanley has been switching over from K to some Haskell-like dialect as well.
- scrawl 4y agoi love k. it's a much smaller and regular language than APL and some of its derivatives. you can look at John Earnest's oK. it's fantastically documented and a great learning resource. i would also recommend BQN. it has an active community and it's designer Marshall Lochbaum explicitly tried to address some of the warts in APL and j. he's done a great job. learning any of the array languages will be a tremendous learning experience if you haven't approached the paradigm before
- co_dh 4y agoQ/kdb, it is practical, and you can find a good pay job with it.