Re: Calling J from Python



Bjoern Schliessmann <usenet-mail-0306.20.chr0n0ss@xxxxxxxxxxxxxxx> writes:

Alexander Schmolck wrote:

Apart from being less to type

Cool. Less to type.

Yes. Readability is more important in many context, but for something designed
for interactive experimentation and exploration little typing is absolutely
essential. Would you use a calculator that would require Java-style
boilerplate to add two numbers?

I'd also venture that readability and typing ease are typically closely
positively correlated (compare python to C++) and although I would not claim
that J is particularly readable I'm also not an expert user (I doubt I would
even then, but I'm sure it *does* make a difference).

and it is superior in that it's
generalizes much better, e.g:

avg&.^. NB. geomtric mean
avg&.% NB. harmonic mean
avg M NB. column mean of matrix M
avg"1 M NB. row mean of matrix M

Is there any regularity in this? If it is, it's not obvious at all.

Sure. ``f&.g`` is like ``(f o g) o g^-1`` in common mathemetical notation.
``^.`` is log and ``%`` is inversion/division. Making ``&.`` (it's called
"under") available as a convenient abstraction is IMO one really useful
innovation of J.

As for the remaing two: it's similar to numpy in that one and the same
function can normally operate on arrays of different dimensions (including
scalars). In numpy you'd also write stuff like ``mean(M, axis=1)``, it's not
exactly the same, although the axis abstraction comes from APL (another cool
idea), J introduces a slightly different approach. The ``"1`` means "operate
on cells of rank 1" (i.e. vectors), rather than "operate along a certain
axis". For dyadic (2-argument) functions you can also specify different left
and right rank, so you could write the outerproduct v'w thus: ``v *"0 1 w``
(multiply each 0-cell (i.e scalar) of v with each 1-cell (i.e. vector, there
is only one) of w). Unlike the linear algebra notation this readily
generalizes to more than 1 dimensional objects.

BTW I don't think J is an ideal language, not even for numerical computing --
there are plenty of things I'd do differently and that includes measures that
would IMO greatly aid readability (like getting rid of "ambivalence"[1]). But
I have little doubt that, no matter what its flaws may be, APL (and J is
really just an updated, ASCII-based APL) is one of the most innovative and
important programming languages ever conceived. Anyone interested in the
design of programming language for scientific computing ought to take a look
at at least a look at it or one of its descendants.

'as

Footnotes:
[1] Basically almost every J function has a completely different meaning
depending on whether you use it as a unary or binary function (just as
conventionally "-" is abusively used for both substraction and negation).
.



Relevant Pages

  • Re: Once Again I Make Things Happen!
    ... understand typography for typography to improve readability for that reader. ... much anymore) and OS X and to me the font rendering on OS X seems much ... screen or print, just how to design for readability, and then then it is ... Screens can't produce curves, so other things have to be done to improve ...
    (comp.sys.mac.advocacy)
  • Re: slightly OT: error handling conventions
    ... - making a well design is more than the half work. ... goto is evil and should be avoided whenever possible ... break them down in nested fuctions increases the readability. ... the compiler knows better than you why it is crying. ...
    (comp.lang.c)
  • Re: "Humane" programmer interfaces
    ... > readability. ... Ruby supports negative indices in the same way as Python, ... which I personally classify as a design error (I don't think Python is ... exist or not, it's not obvious that they're design errors, not at all); ...
    (comp.lang.python)
  • Re: Silly errors in design or A vendor gets embarrased
    ... sunlight, and none of the CCFL units are good enough. ... I design systems for glider instruments, and we need visibility such that the display can be read at a glance, with the sun at any angle. ... I was personally impressed with the readability in full on light, but the best way is to get a sample and look at it yourself, of course. ...
    (sci.electronics.design)
  • Re: universal selector
    ... > My problem is that we usually write helper functions ... > to simplify coding and improve readability. ... > This also means less typing which unfortunately ...
    (comp.lang.cpp)