17 comments

[ 14.1 ms ] story [ 123 ms ] thread
Is anyone using J as a component in a "modern" application? I am looking for an excuse to learn the language, but my current projects are more traditional web applications.

I could likely find an excuse for it in data analysis/manipulation, but that seems like the obvious application.

Once upon a time, around 8 years ago, I gave J a serious go as a hobby language. At the time I was subscribed to their mailing lists, they were very active and a quick perusal suggests they're still active. If you want to know more about what people are using it for I'd highly recommend checking out the archives or asking them directly. Data manipulation and visualization seemed to be big topics at the time. Many of the posts in the mailing list seemed to come from individuals who programmed only as a hobby or where it wasn't their actual job. They programmed to do work, but were not programmers for work (think accountants, teachers and the like, solving some receptive task with a program they put together rather than doing the mundane over and over and over again).

[1] http://www.jsoftware.com/forums.htm - the one called "programming" is what you'll be interested in.

I used J exactly for data manipulation[2] - it was really neat even for very simple things like grouping and aggregating rows of a table (or columns). The terseness of J makes it very well suited for interactive, incremental development; very unusual semantics of functions (monadic vs. dyadic, verbs vs. nouns vs. gerunds) make the language very composable. It's also pure - at least outside of special, implementation provided functions. And it's fast.

A typical script for reading a CSV file, manipulating it in some more or less complex way and dumping results back to file would take ~40 lines of Python (with native lists and csv module from stdlib), ~25 lines of Python with Pandas and about 5 lines of J. It obviously doesn't matter if the script is going to last for years, but if it's going to be used a few times and discarded[1], then working with J is a considerable advantage.

One thing of note, though: J is HARD. It's unlike any other language you could know and it's moderately complex. It's not that hard to pick up the basics - although my head exploded a few times before I understood how J even parses expressions - but it's entirely non-trivial to learn how the basic building blocks compose to enable you to do something useful. In my experience there's just no shortcut here - you need to start with basics and slowly work your way up. It took me a couple of weeks of learning in the evenings to get J enough to actually do something, but then it rapidly became very simple (both to do things and to learn more of J).

If you don't know any array-based language, I'd say give J a chance. Even if you won't use it itself very often, you'll learn some valuable skills, transferable to Python/Pandas or R. And if you do use it, you'll get significant boost in speed of development.

[1] Actually, J is not "write-only" language, it's just not meant to be read without the help of J environment. Reading J consists of pasting pieces of definitions into REPL and experimenting with them, and possibly using one of a few built-in ways to analyse the definition structure.

[2] Also for solving fizz-buzz: http://livescript.net/blog/fizzbuzzbazz.html#comment-1145818...

I think everybody who is using APL would have good reasons to use J (which is actually APL's successor and was also created by Ken Iverson). If one is interested in these kind of languages, he should definitely also check out Arthur Whitney's magnificent K and Q (https://en.wikipedia.org/wiki/K_%28programming_language%29).
I'm not sure, but I think I heard they are not open source?
I really appreciated the pacing of this talk. In depth, but not too much so, with just enough of a taste to make me want to find out more.
J is really fun. There are a lot of Project Euler problems you can hypothetically do as one-liners and that's highly amusing to me at least.

Edited to add examples: http://www.hakank.org/j/

Too many special characters. This is why I don't like Haskell. As a polyglot, it's really helpful to have a piece of syntax spell out what it does. Python is usually really good at this. I don't get how it can be so hard for language designers to learn this. Why use ":+" when you can use "append"? Now I have to google "Scala append" every time I start writing a new Scala program. Good job. But at least the Scala example uses "+", which is sort of understandable with lists. You can suspect that it has something to do with appending when reading code. What does ">>=" even mean? Or "(($){.R)"? WTF? I give up. I don't like languages that try to fight me.
Stop trying to fight a language, then? Just learn those few unfamiliar constructs the language is build upon and start using it. Actually, in J there is not that much of what you need to learn, here is the full list: http://www.jsoftware.com/help/dictionary/vocabul.htm

And here is a bit more involved explanation of what those words mean: http://www.jsoftware.com/jwiki/HenryRich?action=AttachFile&d...

If there is one thing I learned as a polyglot it's that language usage patterns differ and trying to use one language as if it was another is counterproductive. My advice is to learn more and practice more - at some point you'll start seeing higher-level patterns in language design and will be able to cope with many, now unfamiliar, features and design decisions.

I do see patterns in languages, it's just that the patterns are hidden below arbitrary nonsensical syntax that has to be relearned every single time I switch language. Some syntax, like Python's, is easier to remember and guess than other syntax. I conclude that Python's syntax is good and Haskell/J's syntax is bad.

Basically, I want the languages I use and have to constantly relearn to have a syntax that is quick to pick up after having partly forgotten it for the nth time. That requires memorable and guessable names and keywords.

I'd recommend reading Iverson's "Notation as a Tool of Thought" (http://www.jsoftware.com/papers/tot.htm) . Operator looks for APL - and then for J - were modelled after mathematical notation, which had to be extended somewhat towards computations. But can you imagine writing on a whiteboard, say, "samples_transposed" instead of A'?

You definitely can use words instead of many symbols in J. I highly doubt though you want to do that for the core language. Much more productive - IMO - is to learn the vocabulary - which is very finite. Yes, I know it's a great show stopper for those considering learning J.

Operators are probably written using special characters in order to provide a suitable level of terseness. I feel it really can make things more compact and easy to understand.

Of course, I'm very much of a C programmer, and C is kind of good too at using operators in a terse manner.

If C required

    foo >>= 4;
to be written as

    foo = foo shift_right 4;
then it just wouldn't be as nice and fun to program in. Even more so when using the pointer-dereferencing and pre/post-increment operators, or combinations.
All of the symbols are optional in J, except for =. and =: which are used for assignment. If you don't like % for division you can define

    divide=: %
and then only use divide. If you don't want to come up with your own names for all the built-in functions, you can just use the names suggested in the vocabulary (J's main help file). If you don't want to write all those definitions to give names to the built-in functions, there is already a module in the standard library that does it for you.

If you do decide to program in J, however, I recommend you just learn the symbolic names, they're so much shorter and fun. :)

I recommend installing a J interpreter on your phone or tablet. It's concision makes it a great choice for coding without a physical keyboard (specially with a specialized J virtual keyboard). It's great for, say, doing Project Euler problems while you're waiting in line.