Jay Phrase Book

The JayLanguage has a rich set of built-in operators which can be composed without the introduction of superfulous variables. For example, + will add two numbers, +/ will sum a vector, and #%~+/ will find a vector's arithmetic mean. The + in each case is the same addition function. The additional characters of the later examples apply that addition in more complex settings to achieve more complex results.

Needless to say, J can be quite cryptic to those who have not learned its basic syntax and idiomatic usage. Conversely, J can be amazingly expressive to those who have. We can get a feeling for its expressiveness without learning J by simply browsing the large collection of J idioms called the J Phrase Book. Here is an online version of the book.

The heart of the phrase book is the two column tables that list the phrases and their meanings. Each prase is given one or more short names that may be used by other phrases in the table. J's definition operator is =: so the arithmetic mean phrase might be writtern as

	a =: # %~ +/	NB. arithmetic mean
If you are browsing the phrase book without learning the language, don't expect to understand these phrases. Still, you can get a sense of how complex a phrase is by its length, and that will be easier to judge when you know that the leading characters are just there to give the phrase a name. Here is the page of the phrase book that includes arithmetic mean.

Notice the similar structure of geometric mean. Learning to read J requires learning to recognize such structure and variation. Here is a page from the phrase book that has many phrases about string/array manipulation.

I recently tried to write an expression in perl that would tell me at what character position two strings first disagreed. I was hoping I wouldn't have to write a loop. When I couldn't figure it out I polled the local PerlMongers? and received several pointers to CPAN modules.

The J Phrase Book is like CPAN for J idioms. Not only is there a tremendous collection of functionality, like perl, it is available in source. The J programmer reads the idioms like a perl geek reads modules: to learn to be a better programmer. Each says, "oh that's interesting, I wonder how they do that?"

I just scanned the locate-select pages of the J Phrase Book looking for "index of first mismatch". I didn't see it right away. But I did see lots of things that were close. And even as a novice J programmer, I could see how their structure applied to my problem. It made me feel like programming. -- WardCunningham


View edit of July 25, 2008 or FindPage with title or text search