Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: What do you use as a language litmus?

by princepawn (Parson)
on Jun 26, 2007 at 15:34 UTC ( #623440=note: print w/replies, xml ) Need Help??

in reply to What do you use as a language litmus?

I recently posted a similar question to comp.lang.misc. Basically, I am studying the J programming language.

It is a successor to APL and is remarkably concise. It is also a highly functional language. It has computer language counterparts to English parts of speech such as noun, verb, adverb, gerund, and conjunction. Besides concise operators, there is one concept, called verb rank, which went through more than 10 years of development and research to develop. It has a long history of development. I will now give a small taste of each of my overview statements.

descriptive, not proscriptive

In a descriptive language, it is convenient to describe a macroscopic action as opposed to proscriptive, where you must do each little part. I spent a good amount of time dabbling in Factor, a stack-based language before getting exasperated with the proscriptive nature of it. I had to continually focus on manipulating a stack as opposed to focusing on the problem at hand.

J is descriptive in a number of ways, but I will only go over one that is necessary to read the next section. It has to do with a concept called "verb trains"... In most languages, a series of functions implies function composition. In J, two functions in series applied to data gets rewritten like so:

(f g) data => data f (g data)
which means that f is a binary function which will take the pure data and the result of g data and operate on that. ... here we must note something else....

a brief aside

J verbs (functions) are monadic, dyadic, or ambivalent (meaning they have implementations for both monad and dyad cases). The monadic case looks normal:
fn data NB. function applied to data "NB. is comment in J"
but the dyadic case is just like in English sentences where you have Subject Verb Object:
5 + 5 NB. 5 adds_to 5 5 , 6 NB. 5 appended_to 6 4 { 1 2 3 4 5 NB. 4th element_of the_list_12345
So when you see
(f g) data => data f (g data)
the data f (g data) is Noun Verb Noun and is not like in perl where a function taking two arguments would have both nouns to the right of the verb.
What this means is that the common operation of copying data before operating on it, and then using the original and modified data on another function is highly descriptive.

Now three verbs in a row is called a fork. So

(f g h) data => (f data) g (h data)
And that's what you need to know for the next section

highly concise

J took the judge's prize in the 1998 ICFP programming contest. It ran faster than 17 compiled C entries. And is "astoundingly brief" --- only 113 lines and only contained one loop thanks to the fact that all operators have implicit looping capabilities.

Check out this J code to average a list of numbers:

avg =: +/ % #
+/ means to insert + between each member of a list... and the neat thing is that / is an adverb that can be applied to any verb. so / is a function which takes a verb as a function to produce a new verb!

% is simple. It divides 2 numbers

# is simple. It counts the number of elements in a list

So remember that a train of verbs gets rewritten? So basically what we have is

(+/ data) % (# data) (sum-of data) divided-by (number-of-elems data) results in average

the rest of J

Well, I'm a bit tired, and I havent really given a balanced overview like I meant to. Personally, I'm addicted to J and keep coming back for more. The J Bibliography is a great place to read on the origin of ideas behind APL and J as a certain way of looking at programming which puts conciseness at a premium. In particular see:
Falkoff and Iverson, The Design of APL, 1973. Falkoff and Iverson, The Evolution of APL, 1978. Iverson, A Personal View of APL, 1991.

Also Ken E. Iverson memoriam page has plenty of insight to APL and J language culture.

It's a very different language. And it will make you think differently, but I am enjoying my time with it.

The Cons

The cons about this language is the small community and lack of enterprise-ready deliverables/libraries. For instance, they are just now trying to get parsing of multipart form data to work properly.

Now even though the community is small, you can check the mailing list archives to see that there is a tremendous amount of activity amongst the small userbase.

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://623440]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-04-28 13:13 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (521 votes). Check out past polls.