For those of you who don't know anything about J, it's a modern dialect of APL; an extremely concise functional programming language based on function concatenation and vector operation. The APL languages are very interesting, but have historically been proprietary and somewhat insular.
Thanks. For those who prefer PDFs, that book and more material are available at http://www.jsoftware.com/jwiki/Books . (Had to dig around a bit, because, in spite of the original URL, the book was not listed in the help page.)
Question: I have a vague memory of seeing a web page named something like "A Garden of ..." with neat examples, either for J or K. However, my search-fu is failing me.
Yes, that's probably it, thank you. (There's a couple of brain cells in the back muttering that the page was less dense and tan colored, but I told them to shut up ;-)
P.S. The credit at the bottom of the J Sudoku piece led me here: http://www.vector.org.uk/ . Seems an interesting place to visit. It even features articles headed "APL is not for programmers" (quote: "At this point the average programmer turns off, drops out, gets his coat and leaves the building, heading for mom and the kids. We, on the other hand, will continue.")
Very cool, I should look into this. IBM APL2 was one of the first languages I spewed out lots of code in (the others being awk, C, scheme and some proprietary database langauges, ). The APL workspaces I worked on were some of the largest in existence, according to IBM consultants we had on-site (tens of thousands of lines of code, if I remember correctly). Whew.
I glanced over the J for C table of contents to find out where J keeps anything like product and sum types, but I found no promising headlines. Is that just J's way of saying "if it's not a matrix, don't use J", or am I missing something fundamental here?
Box/open are the primitives you want. Box wraps other values (possibly with different types or sizes) in one array, kind of like a C struct. Open extracts sub-elements.
There is already an open source K implementation called kona https://github.com/kevinlawler/kona , and now J is joining. There are old J source codes floating around, but the latest is from 1993 if I'm not mistaken.
Yes! I've been experimenting a LOT with kona.* K seems more my style, but I'm really excited about J being opened too! The APL family is way too interesting to have it confined by extremely expensive licenses and niche industries.
* Also, from communicating with the author: it's a clean re-implementation based on experience with it, not an open-sourced version of "real" K. (I've never used K or Q.)
I got the '93 J to work, too (on OpenBSD), but it's evolved a lot since then, and having the official version open will draw a lot more attention.
Also, thanks for answering some of my questions about J, K, and valence/rank a while back.
K is a lot more my style too: J has the kitchen sink. K provides closer to the "bare necessities". And yet, K programs are often shorter, simpler and more verbose.
Also, K operators often rhyme with the C meaning of the same characters: &=and/min, |=or/max, monadic*=first (like C dereference when applied to a vector; trenary?=[vector]choose. I think there are a few others.
I didn't know about Kona. Thank you thank you thank you! My transition from the sidelines into the pit of vector-oriented programming seems to be accelerating.
This is the reason to learn J. It is a clean, fast course in a programming style that puts linear algebraic concepts at its heart. If you are interested in functional programming, work through this book. The "tutorial" part is about 60 pages, which should be worked through, and the dictionary part about 150 pages, which can be dipped into.
Anyone who does any significant amount of work in J care to comment? It seems like a super-niche language, which would take more time to come up with and mentally-parse existing code than the same operations in other languages. Of course, once you're fluent, you're fluent, but it looks like Vim to the Vim'th power...
We have a guy at work who uses J for everything, since he came of age doing data analysis in APL, when APL was the only interpreted and powerful matrix language out there. (Fortran was compiled and low level.) He loves it, but he doesn't know any other languages.
Personally, I found J a very interesting interesting exercise, and APL is historically SUPER important, but for practical uses they have been way superseded by matlab/ Octave/ R and the T/P/R* scripting languages. (At times my friend will say something like "in J you can compute the sum of a matrix IN JUST ONE LINE... and I will point to "sum(A)" in matlab, as opposed "$&$%^%$%M" in J, or whatever it is.)
K may be more brain friendly than J. But as far as I am concerned, J makes assembler and badly written Perl look easy to read.
Sum in J is +/ not, $&$%^%$%M. Is +/ really too hard to comprehend? I agree with you that APL is historically important, but J is Ken Iverson's last and greatest gift to the programming community. He used the 26 years between the release of APL and J to address many of the shortcomings of APL. Take a look at http://bit.ly/hMmGWV for some background.
It's not semantically different from sort [] = []; sort (x:xs) = sort (filter (< x) xs) ++ filter (== x) xs ++ sort (filter (> x) xs) in Haskell (modulo laziness). The parallel structure in the J code should be plainly evident even if you don't know anything about J.
It's a lot like math notations. To draw an analogy, it's hard to go back from "a*b" (i.e. k/j/apl) to "a multiplied by b" (i.e. lisp) to "start with zero, add a, add a again, ....., repeat b times (i.e. java/cobol) once you've gotten used to a concise notation. And even if you _do_ go back to verbose, you are overall much better for knowing what's a concise way to putting everything, and converging towards that with your limited tools.
It's more general than you'd think -- though it is a drastically different way of looking at problems. You have to set your sights a bit further up the scope of the problem, and that takes a lot of getting used to. Thinking in terms of the whole instead of the step is a lot different from most other programming!
(I'm only a novice J programmer, but I quite like the language.)
As someone who is not exactly in the know about this subject: is there a cleaner way to write this stuff, or is that the usual way to do it? (I can write nasty Perl, but choose to write pretty Perl, because I like my job. What would an APL user do?)
By cleaner, do you mean more verbose? For example, the well known phrase for average in J is (average=: +/ % #). You would have no problem assigning names to the parts of the function, i.e. (sum=: +/), (divide=: %), (tally=: #) and defining the function as (average=: sum divide tally). It is tempting to learn J this way, but once you are familiar with the primitives, it makes more sense to just use them. You can pack a lot of thought into very few character, which is one of J's strengths.
That is actually quite cool, I do remember seeing all the crazy solutions to projecteuler when I was doing those and it even made me try to grok some of what J did and you don't even need an APL keyboard to write it.
Excellent! I've been intrigued by J for a while, but I won't use languages which don't have at least one free/open-source implementation. Now I'll need to take another look at it!
* http://jsoftware.com/
* http://en.wikipedia.org/wiki/J_%28programming_language%29
* A good intro - _J for C Programmers_ (http://www.jsoftware.com/help/jforc/contents.htm)
* A more casual intro - "Mind if I do a J?" (http://jeffzellner.com/miidaj/)