Calling J from Python

B

Bruno Desthuilliers

Gosi a écrit :
J is in many ways similar to Python.

J has very many advanced operations.

http://www.jsoftware.com/
"""
Our policy on source for our binaries is between the extremes of
Microsoft proprietary source and Linux open source. You can have the
benefits of open source for J binaries, but under a license and a fee.
"""

Good bye J.
 
B

Bruno Desthuilliers

Alexander Schmolck a écrit :
And why is that superior to this:

def avg(l):
return float(sum(l))/len(l)

avg([1,2,3,4])

2.5


Apart from being less to type 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
> 'as

Would my beloved wife's life depend on it, I just couldn't say what all
this garbage is supposed to mean. If that's supposed to be "superior",
I'm quite happy with my inferior favorite languages...
 
B

Bruno Desthuilliers

Diez B. Roggisch a écrit :
Gosi wrote:




What exactly do you call "similar to python" when the following is a program
written in it? Compared to that, even Perl is a wonder of readability...

m =: >@(0&{)
v =: >@(1&{)
h =: >@(2&{)
qu =: >@(3&{)
z =: i.@0:
ret =: |.@}:
init =: z;z;z;i.
f1m =: (m,{.@qu);v;h;}.@qu
f5m =: (z;(v,{:mad:m);h;qu,ret@m) @ (f1m^:5)
f1h =: (z;z;(h,{:mad:v);(qu,ret@v)) @ (f5m^:12)
f12h =: (z;z;z;qu,ret@h,{:mad:h) @ (f1h^:12)
perm =: qu @ f12h @ init
ord =: *./ @ (#&>"_) @ C.
days =: -: @ ord @ perm

Yuck. I'd rather program in b**k.
 
B

Bruno Desthuilliers

Alexander Schmolck a écrit :
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?

No, thanks. But hopefully we have Python :

Python 2.4.1 (#1, Jul 23 2005, 00:37:37)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on
linux2
Type "help", "copyright", "credits" or "license" for more information.
!-)
 
A

Alexander Schmolck

Bruno Desthuilliers said:
No, thanks. But hopefully we have Python :

Python 2.4.1 (#1, Jul 23 2005, 00:37:37)
[GCC 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

My calculuator even gives a pretty good answer if I divide them (without
importing anything from the __future__).

'as
 
G

greg

Alexander said:
For example I once wrote this (slow) code to display
part of a mandelbrot fractal:

load'viewmat'
viewmat+/2&>:|((j.~/~(%~i:)99)&+@:*:)^:(i.32)0

It'll likely require you more typing in python,

Yes, but with Python you wouldn't have to spend a
couple of weeks sitting and thinking before starting
to type that line...
 
E

Eric_Dexter


There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write?? The second is how do I use the j stuff
without learning all that much about j. I am just intrested in
stealing graphics libraries and using what I have already written in
python..
 
P

Paddy


Hii Gosi,
From reading what has gone before, you seem to have got it in the neck
from some pythonistas.
I'd just like to say from some but not all.

It is *A GOOD THING* that Python has bridges to other languages. Some
may not care to program in the other language - which is a separate
concer;. but a link between the language - be it Haskell or befunge or
J, makes Python better in my view. If your expert J programmers have
need for something that is hard to do in J they might now be more
likely to use Python.

We should remember that Python is a great glue language too, and links
to other languages and tools is how we maintain that position.

- Paddy.
 
D

Dennis Lee Bieber

The late Ken Iverson designed both J and APL (he has also written an number of
freely downloadable math books using J, see jsoftware.com).
Ah... Another cryptic language optimized for representing
vector/matrix math operations... <G>
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
G

Gosi

There are a couple of issue that should be adressed. Am I going to
jail if I write a program and then redistribute all the files required
to run the program I write??

J is free for anyone to download and use.

If someone is interested in putting you in jail it will not because
you distribute J or redistribute the J utilities.
The second is how do I use the j stuff
without learning all that much about j.

Just like Python then how much time you spend is uo to you.

If you want to be good at it you may have to spend some time.

You may also be just a casual user and dip into it now and again.

There are lots of Demos, Labs and Help files besides all the
utilities.

You can freely use the utilities and examples to create your own
application.

You can write code in conventional style and not spend any time on the
advanced functionality.

I am just intrested in
stealing graphics libraries and using what I have already written in
python..

There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.

The new grid classes in J are amazingly useful too.

I am just starting to learn Python and I find it interesting to
combine it with J.
I know a few people who are doing so successfully.

There are always some nicetise in any language that can be beneficial.
Combining them enhances both.

http://groups.google.com/group/j-programming
http://jsoftware.com/
 
G

Gerard Flanagan


As I understand it, the k language, which is similar to J, is used to
interact with streamed realtime financial data, where I imagine the
terseness of the language may make sense. I messed about with J for a
day or two, and found it interesting and in a way natural (given some
Higher Math background once upon a time).

Here's a link to a company who it looks like could value some
knowledge of J/K/APL type languages: http://www.kx.com/news/in-the-
news.php

All the best

Gerard
 
B

Bruno Desthuilliers

Gosi a écrit :
J is free for anyone to download and use.

But not to inspect or modify. This is "free" as in "free beer", not as
in "free speech".
Just like Python then how much time you spend is uo to you.
>
If you want to be good at it you may have to spend some time.

You may also be just a casual user and dip into it now and again.

This is easy with Python, which emphasis readability. I doubt one can
say the same about j.
 
B

bearophileHUGS

Gosi:
There are a number of graphics examples, utilities and demos you can
use in J and combine it with Python.

Some of those graphic examples are very nice, I have seen a big site
filled with complex fractals, chaotic attractors, etc.
Python Zen seems somewhat opposed to part of the J spirit, that's why
it's not easy to advertise J in this newsgroup. Python is open source,
and it values readability, it belives that it's better to write more
and be more readable/debuggable, than to be able to express many
things with few symbols. APL was an interesting language, powerful
too, and J looks more keyboard-friendly and it's probably better for
other things too. K seems even less readable than J to me. Probably J
has to be compared more to scipy than to Python itself, because they
share some purposes, the vector/matrix processing. If you need to do
lot of array processing the syntax of scipy (with the help of
MatPlotLib too, that's partially copied from MatLab) isn't (may be
not) high-level enough, the system isn't able to simplify things by
itself, etc. So in that situation a more functional language may be
fitter (maybe even F#, but probably there are better languages around
for that purpose, some modern ones coming from ML family).

Bye,
bearophile
 
G

Gosi

Gosi:


Some of those graphic examples are very nice, I have seen a big site
filled with complex fractals, chaotic attractors, etc.
Python Zen seems somewhat opposed to part of the J spirit, that's why
it's not easy to advertise J in this newsgroup. Python is open source,
and it values readability, it belives that it's better to write more
and be more readable/debuggable, than to be able to express many
things with few symbols. APL was an interesting language, powerful
too, and J looks more keyboard-friendly and it's probably better for
other things too. K seems even less readable than J to me. Probably J
has to be compared more to scipy than to Python itself, because they
share some purposes, the vector/matrix processing. If you need to do
lot of array processing the syntax of scipy (with the help of
MatPlotLib too, that's partially copied from MatLab) isn't (may be
not) high-level enough, the system isn't able to simplify things by
itself, etc. So in that situation a more functional language may be
fitter (maybe even F#, but probably there are better languages around
for that purpose, some modern ones coming from ML family).

Bye,
bearophile

Ken Iverson created APL and it ran first time on a computer 1966.
Ken Iverson then corrected several things and made it so different
that he could no longer use the name and the results was J around
1990.

J can be very short and effective.

I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.
 
M

Marc 'BlackJack' Rintsch

I like to use J for many things and I think that combining Python and
J is a hell of a good mixture.

I was able to follow this sentence up to and including the word "hell"… :)

Ciao,
Marc 'BlackJack' Rintsch
 
G

Gosi

I was able to follow this sentence up to and including the word "hell"... :)

Ciao,
Marc 'BlackJack' Rintsch


That is a start.

"Hell" is also what most example start with as in "Hello something"
Hell in northern countries is very cold.
Hell in middle east is very hot.
I do not know which is your Hell hot or cold.
Hell o veröld
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top