Re: Calling J from Python
- From: Alexander Schmolck <a.schmolck@xxxxxxxxx>
- Date: 05 Feb 2007 20:00:35 +0000
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).
.
- Follow-Ups:
- Re: Calling J from Python
- From: Bruno Desthuilliers
- Re: Calling J from Python
- From: John Salerno
- Re: Calling J from Python
- References:
- Calling J from Python
- From: Gosi
- Re: Calling J from Python
- From: Diez B. Roggisch
- Re: Calling J from Python
- From: Gosi
- Re: Calling J from Python
- From: Bjoern Schliessmann
- Re: Calling J from Python
- From: Larry Bates
- Re: Calling J from Python
- From: Alexander Schmolck
- Re: Calling J from Python
- From: Bjoern Schliessmann
- Calling J from Python
- Prev by Date: Re: Missing member
- Next by Date: Re: Calling J from Python
- Previous by thread: Re: Calling J from Python
- Next by thread: Re: Calling J from Python
- Index(es):
Relevant Pages
|