[3171] in java-interest
Re: Handling of mathematical data structure
daemon@ATHENA.MIT.EDU (Bob Hoekstra)
Thu Nov 2 07:38:50 1995
Date: Thu, 2 Nov 95 09:47:23 GMT
From: Bob Hoekstra <roh@scuk.demon.co.uk>
To: walter@scsun.unige.ch, Elliotte@blackstar.com
Cc: java-interest@java.sun.com
> > Is Java able to handle N dimensional data structures ?
> >
> > 1) If a and b are two NxM matrices, is there a way to write
> > c = a+b without loops ?
>
> You could create a matrix class with an add method so that the rest
> of your code wouldn't see the loops. This sort of trick is one of
> the points of OOP. Still there need to be loops somewhere. Even
> languages like APL that hide the loops from the programmer still
> generate it in the assembly code.
As an APL programmer, I couldn't resist commenting on this. Yes, of
course the loop HAS to exist somewhere, but the less dross the loop
carries, the more efficient it is. Contrary to popular belief, this
is not the strength of APL, as there is a lot of overflow, underflow
type, etc checking that goes on, not to mention continuous memory
management (GC and other stuff). APL's main strength lies in short
development times. If you want to speed up the run-time application,
identify critical areas and recode them in a compiled language (e.g.
C) and call them from the APL.
I would expect the same to be true of java in principle, though the
call may not be as easy (or even impossible because of security
considerations).
> > 2) If yes, how the speed compares with a C program ? (is the
> > underlying
> > loop interpreted or handled at compiled speed)
>
> Poorly, at least for now.
As noted above, the compiled code is faster (often more than 100x),
but one loses ease of maintainability, bug finding, etc. In APL,
compiling of native code is a hot point at the moment and some
development is being done with promising results so far. I believe
that java will move in this direction as it matures, allowing
compilation of (part of) the java code into machine code to run a
lot faster. Examples like that given, where the operation is simple
and repeated many times (large M & N) seem ideal for this.
Note: These comments are my opinions. You are welcome to discuss
them with me, you may change my mind, but don't count on it!
---------------------------------------------------------------------
Bob Hoekstra Tel +44 1932 567311
Consultant Fax +44 1932 568145
SimCorp Ltd SnailMail address supplied on request
---------------------------------------------------------------------
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com