[sage-devel] Re: python vs java for scientific computing

2009-02-06 Thread Ronan Paixão

Em Sex, 2009-01-23 às 09:49 -0800, rjf escreveu:
 
 
 On Jan 22, 6:26 pm, mhampton hampto...@gmail.com wrote:
 ...
  A python/
  cython/javascript spreadsheet for the Sage notebook would be great -
  unfortunately I'm not going to write one.  I think it would be hard to
  do it right.
 
  -M. Hampton
 
 I have heard that the major competition for Mathematica is not Maple,
 but Matlab.
 
 And that the major competition for Matlab is not Mathematica, but
 Excel.
 
 There are spreadsheet interfaces in Maple.  One is so you can use a
 spreadsheet
 paradigm within Maple.  Implementing a simple spreadsheet in lisp or
 Maple is not too hard;
 I assume the same holds for python.
 
 
  I wrote a paper with an undergraduate showing
 how to call Lisp (and therefore Maxima) from Microsoft's Excel.  The
 range data is
 transferred to and from Lisp in a standard form. Symbolic data must be
 strings. We also
 add to the spreadsheet, commands for lisp evaluation, and lambda
 expressions.
 
 Whether this is the right design or not, it is fairly obvious, and for
 someone who like Excel (+ Lisp)
 allows pretty much full access..
 
 Of course Excel can be used generally to allow access
 to all those numeric libraries in a way which may be comparable in
 convenience to any
 of your favorite languages.  I suspect that one could  mimmick all the
 scripting of
 python with an extremely thin layer of python between Excel and
 whatever, making
 those libraries appear to be available in Excel directly.
 
 Just as I can run MPFR, GMP,  from Excel using a very thin layer
 of Lisp.
 We found the key was to write a very very thin layer of visual
 basic.to get to Lisp.
 
 Probably VB totally, could link to numerics without lisp or
 python...

There are ways to integrate Python and Excel. I've never seen Excel call
python, but surely I've seen Python use Excel. Last month I tried for
the first time using comtypes... I've played a little and know that one
can even use Excel's text-to-speech features :)

Also, one has direct access to cells' contents.

By the way, even though I don't like Excel for any number crunching,
there are even books around which address the subject of using it for
scientific stuff.

Hell, I've even seen someone use Excel in some twisted way to make
semi-automatic macros for AutoCAD!

From what I've seen, those who have tasted R have switched with no
regrets (though I've never been one of those, but at least I use numpy).

Ronan


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-02-06 Thread Tom Boothby

  I wrote a paper with an undergraduate showing
 how to call Lisp (and therefore Maxima) from Microsoft's Excel.  The
 range data is
 transferred to and from Lisp in a standard form. Symbolic data must be
 strings. We also
 add to the spreadsheet, commands for lisp evaluation, and lambda
 expressions.

Wow Richard, that's really neat!  I'd bet you could write a Google
app, and tie Lisp into the Google Documents spreadsheet widget.
Upload Maxima into the cloud, and you'll have, with out a doubt,
quite the superlative computer algebra system!  I'd love to see the
Sage notebook on a system as large as Google's network, but I doubt
that could happen given the complexity.  I'd be curious to see what
you and your students could come up with,

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-23 Thread ahmet alper parker
What about the compiled java and python benchmarks? Is there someone who has
experience with compiling a java code to native code on an operating
system?
On Fri, Jan 23, 2009 at 4:26 AM, mhampton hampto...@gmail.com wrote:



 On Jan 22, 4:35 pm, Robert Bradshaw rober...@math.washington.edu
 wrote:

  I pity those who find themselves trying to do serious scientific
  programming with excel :). Though there are certainly a lot of
  rational arguments against it, there may be some out there that are
  as enthusiastic about Excel as we are about Python or you are about
  lisp.
 
  - Robert

 For scientific computing, of course we can laugh at Excel.  But there
 are many analysis tasks it is good at, and for which it is _extremely_
 popular.  One could win a lot of people over with a spreadsheet that
 was well-integrated with other tools in some language.  A python/
 cython/javascript spreadsheet for the Sage notebook would be great -
 unfortunately I'm not going to write one.  I think it would be hard to
 do it right.

 -M. Hampton
 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-23 Thread Harald Schilly

On Jan 23, 10:09 am, ahmet alper parker aapar...@gmail.com wrote:
 Is there someone who has
 experience with compiling a java code to native code on an operating
 system?

the standard java virtual machine by sun already compiles java
bytecode to native machine code. this is called hotspot compiler and
picks those parts at runtime, that are very often used and translates
them. This goes even so far, that long running loops are replaced
while they are still running - called on stack replacement. If you
have a big machine (multicore, = 2 gb ram) then you can run java in
the server configuration for additional optimizations.
http://java.sun.com/javase/technologies/hotspot/index.jsp
http://java.sun.com/javase/6/docs/technotes/guides/vm/server-class.html
also notice, that this approach goes some steps further in recent java
versions (6 and soon 7), where the sourcecode is analyzed and
rewritten to improve performance (things like dynamic inlining, lock
elusion, escape analysis ...
http://java.sun.com/javase/technologies/hotspot/publications/ )
http://java.sun.com/performance/reference/whitepapers/6_performance.html

From my experience, all other options are less stable and tested. Of
course, you still have all checks (i.e. there is nothing like in
cython where you disable checks) and the virtual machine is also still
used (but therefore you get garbage collection with a variaty of
different collectors and options)

For everything else you should consider JNI (that's the mechanism to
call native C code and how all basic java language features are
implemented)

h
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-23 Thread Alfredo Portes

On Fri, Jan 23, 2009 at 5:37 AM, Harald Schilly
harald.schi...@gmail.com wrote:

 For everything else you should consider JNI (that's the mechanism to
 call native C code and how all basic java language features are
 implemented)

By the way you may consider using JNA to access native libraries. I
have used it to
access the Win32 api and it works very well.

https://jna.dev.java.net/

JNA provides Java programs easy access to native shared libraries
(DLLs on Windows) without writing anything but Java code—no JNI or
native code is required. This functionality is comparable to Windows'
Platform/Invoke and Python's ctypes. Access is dynamic at runtime
without code generation

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-23 Thread Harald Schilly

On Jan 23, 3:47 pm, Alfredo Portes doyenatc...@gmail.com wrote:
 By the way you may consider using JNA to access native libraries.

thx, didn't know about that!
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-23 Thread rjf



On Jan 22, 6:26 pm, mhampton hampto...@gmail.com wrote:
...
 A python/
 cython/javascript spreadsheet for the Sage notebook would be great -
 unfortunately I'm not going to write one.  I think it would be hard to
 do it right.

 -M. Hampton

I have heard that the major competition for Mathematica is not Maple,
but Matlab.

And that the major competition for Matlab is not Mathematica, but
Excel.

There are spreadsheet interfaces in Maple.  One is so you can use a
spreadsheet
paradigm within Maple.  Implementing a simple spreadsheet in lisp or
Maple is not too hard;
I assume the same holds for python.


 I wrote a paper with an undergraduate showing
how to call Lisp (and therefore Maxima) from Microsoft's Excel.  The
range data is
transferred to and from Lisp in a standard form. Symbolic data must be
strings. We also
add to the spreadsheet, commands for lisp evaluation, and lambda
expressions.

Whether this is the right design or not, it is fairly obvious, and for
someone who like Excel (+ Lisp)
allows pretty much full access..

Of course Excel can be used generally to allow access
to all those numeric libraries in a way which may be comparable in
convenience to any
of your favorite languages.  I suspect that one could  mimmick all the
scripting of
python with an extremely thin layer of python between Excel and
whatever, making
those libraries appear to be available in Excel directly.

Just as I can run MPFR, GMP,  from Excel using a very thin layer
of Lisp.
We found the key was to write a very very thin layer of visual
basic.to get to Lisp.

Probably VB totally, could link to numerics without lisp or
python...

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-22 Thread rjf



On Jan 21, 10:25 pm, Robert Bradshaw rober...@math.washington.edu
wrote:
 On Jan 21, 2009, at 3:34 PM, rjf wrote:



  On Jan 21, 11:54 am, Robert Bradshaw rober...@math.washington.edu
... snip...
  In our case, linear  
 algebra is done via NumPy, which in turn uses a BLAS (with Sage we  
 ship ATLAS). On the other hand, if one is doing a problem that isn't  
 easily phrased as a linear algebra/differential equations/etc.  

Sure, calling a library program from Python can be a good way to
achieve efficiency, but that is not an argument that Python is good
for scientific computing. It is an argument that it is good for
scripting, or glue or something along those lines.

 question for which there is already an optimized library/code, that's  
 where Cython comes in, where one can compile code that operates on C  
 doubles directly (and, because it compiles down to C, is just as  
 efficient).

This is unconvincing.   Maxima code can be translated to Lisp (by a
command called translate).
The Lisp (if Maxima is running in GCL) can be compiled  (by a command
called compile), into C
and then into assembler/ binary code.  So by your argument, Maxima is
as efficient as C.
(Lisps that are not GCL compile into assembler, so maybe writing in
Lisp is as efficient as assembler??)



 It also fits in with the 90-10 philosophy, making it easy  
 to optimize only those parts one needs to (instead of writing the  
 whole thing in a more restrictive (depending on your tastes) language  
 just so your couple of inner loops can be fast enough).

I agree.  Which is why I use Lisp:
1. This 90-10 philosophy includes a need for careful profiling to find
out where the important parts are.
At least the lisp I use has superb profiling tools.
2. Optimizing code in Lisp generally can be done by increasing the
details of the (otherwise optional) declarations,
increasing the requested level of optimizing, thereby removing error
checks, etc.
3. Changing a huge system (e.g. Maxima) to use a different version of
function F, which can be interpreted or compiled,
is accomplished by evaluating what can be a single line of code, and
done in a very short time, independent of the size
of the system.

I think Java cannot do this. I have never used Cython.


 Getting back to the topic of the thread, I think a reason Python is  
 nice for scientific programming is that it's easy to learn, easy to  
 read, and easy to prototype in, and has a rich set of libraries to  
 work with.

If the only comparison is with Java, who knows.  I understand that
Excel is nice, too.

 On the other hand, when you need raw number crunching  
 speed there are good tools out there to interface with or write at a  
 lower level (e.g. Cython, or all that's been wrapped by SciPy and Sage).

As I pointed out, this not an argument for Python being good for
scientific computing,
but for Python being good for glue.  If you wish, you can see how to
glue MPFR or
GMP  or quad-double arithmetic  to lisp, google{fateman generic.lisp}

Regards
RJF


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-22 Thread Robert Bradshaw

On Jan 22, 2009, at 11:11 AM, rjf wrote:

 On Jan 21, 10:25 pm, Robert Bradshaw rober...@math.washington.edu
 wrote:
 On Jan 21, 2009, at 3:34 PM, rjf wrote:



 On Jan 21, 11:54 am, Robert Bradshaw rober...@math.washington.edu
 ... snip...
  In our case, linear
 algebra is done via NumPy, which in turn uses a BLAS (with Sage we
 ship ATLAS). On the other hand, if one is doing a problem that isn't
 easily phrased as a linear algebra/differential equations/etc.

 Sure, calling a library program from Python can be a good way to
 achieve efficiency, but that is not an argument that Python is good
 for scientific computing. It is an argument that it is good for
 scripting, or glue or something along those lines.

Yes. Given the large number of highly optimized, debugged, and widely  
used scientific libraries already out there, being a good scripting/ 
glue language is a big plus for doing scientific computing. Perhaps  
that's not as valuable to you.

 question for which there is already an optimized library/code, that's
 where Cython comes in, where one can compile code that operates on C
 doubles directly (and, because it compiles down to C, is just as
 efficient).

 This is unconvincing.   Maxima code can be translated to Lisp (by a
 command called translate).
 The Lisp (if Maxima is running in GCL) can be compiled  (by a command
 called compile), into C
 and then into assembler/ binary code.  So by your argument, Maxima is
 as efficient as C.
 (Lisps that are not GCL compile into assembler, so maybe writing in
 Lisp is as efficient as assembler??)

To complete this argument, one would have to look at how efficient  
the auto-generated C code is compared to a direct implementation of  
the algorithm in C, in other words, how much overhead is incurred by  
the translation. IMHO Cython can do a good job at this, but I'm of  
course an unbiased judge on that point. Just as you indicate below  
with lisp, additional declarations result in tighter code.

 It also fits in with the 90-10 philosophy, making it easy
 to optimize only those parts one needs to (instead of writing the
 whole thing in a more restrictive (depending on your tastes) language
 just so your couple of inner loops can be fast enough).

 I agree.  Which is why I use Lisp:
 1. This 90-10 philosophy includes a need for careful profiling to find
 out where the important parts are.
 At least the lisp I use has superb profiling tools.
 2. Optimizing code in Lisp generally can be done by increasing the
 details of the (otherwise optional) declarations,
 increasing the requested level of optimizing, thereby removing error
 checks, etc.
 3. Changing a huge system (e.g. Maxima) to use a different version of
 function F, which can be interpreted or compiled,
 is accomplished by evaluating what can be a single line of code, and
 done in a very short time, independent of the size
 of the system.

 I think Java cannot do this. I have never used Cython.

Python can do this, though the more one compiles the more gets  
statically bound.

 Getting back to the topic of the thread, I think a reason Python is
 nice for scientific programming is that it's easy to learn, easy to
 read, and easy to prototype in, and has a rich set of libraries to
 work with.

 If the only comparison is with Java, who knows.  I understand that
 Excel is nice, too.

I pity those who find themselves trying to do serious scientific  
programming with excel :). Though there are certainly a lot of  
rational arguments against it, there may be some out there that are  
as enthusiastic about Excel as we are about Python or you are about  
lisp.

- Robert


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-22 Thread mhampton


On Jan 22, 4:35 pm, Robert Bradshaw rober...@math.washington.edu
wrote:

 I pity those who find themselves trying to do serious scientific
 programming with excel :). Though there are certainly a lot of
 rational arguments against it, there may be some out there that are
 as enthusiastic about Excel as we are about Python or you are about
 lisp.

 - Robert

For scientific computing, of course we can laugh at Excel.  But there
are many analysis tasks it is good at, and for which it is _extremely_
popular.  One could win a lot of people over with a spreadsheet that
was well-integrated with other tools in some language.  A python/
cython/javascript spreadsheet for the Sage notebook would be great -
unfortunately I'm not going to write one.  I think it would be hard to
do it right.

-M. Hampton
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-21 Thread Harald Schilly

On Jan 21, 6:21 am, rjf fate...@gmail.com wrote:
 In my experience, people doing scientific calculations for a living
 will not tolerate a language implementation X whose programs are
 substantially slower than equivalent ones in a language implementation
 Y.

I don't know any details, but I think there are valid cases where one
wants calculation to act the same on all platforms. One possible
example are spacecrafts, where the calculations in space should act
the same way as they were developed on ground. This is part of robust
calculations, interval analysis and enclosures, and much more like
this. So, I think the developer/user has to think about the actual
goals, speed vs. reproducibility, and if possible control what
happens.
Also, since you can call C for a function from java or python pretty
easily, you can always gain more control about the behaviour.

h
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-21 Thread rjf



On Jan 21, 2:44 am, Harald Schilly harald.schi...@gmail.com wrote:
 On Jan 21, 6:21 am, rjf fate...@gmail.com wrote:

  In my experience, people doing scientific calculations for a living
  will not tolerate a language implementation X whose programs are
  substantially slower than equivalent ones in a language implementation
  Y.

 I don't know any details, but I think there are valid cases where one
 wants calculation to act the same on all platforms.

Sure.
 One possible
 example are spacecrafts, where the calculations in space should act
 the same way as they were developed on ground.

Sure. I can't imagine any engineer debugging a life-critical system on
a Mac and then running it on a PC,
putting one of them on a spacecraft and leaving one on the ground.

Surely your supposition that this is a justification for anything has
no support in reality.

This is part of robust
 calculations, interval analysis and enclosures, and much more like
 this.

The reproducibility of results on one computer with one language, but
at different times,
is already hard enough.  What are you willing to sacrifice for your
concept of robustness?
Will you, for example, freeze the version of the operating system
forever?
That would actually be a really good move for some applications,
including spacecraft.


 So, I think the developer/user has to think about the actual
 goals, speed vs. reproducibility, and if possible control what
 happens.

I am sure that some Sage people have thought about such things, but
probably not
enough. Which is why I try to poke holes in some of these comments!

 Also, since you can call C for a function from java or python pretty
 easily, you can always gain more control about the behaviour.

C does not run the same on every computer, and C does not provide
handles for
every feature of every computer in a uniform fashion. You can (I
think) also call
assembler from Java or Python, and that might be preferable. Of course
the assembler would
depend on the machine more obviously than the C depends on the
machine.


It would be much simpler for Sage if only one computer and operating
system were supported.
But the topic of this thread is supposed to be something about
comparing 2 languages for scientific computing.

Whatever that might be.

R.


 h
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-21 Thread rjf



On Jan 21, 11:54 am, Robert Bradshaw rober...@math.washington.edu
wrote:


  I am sure that some Sage people have thought about such things, but
  probably not
  enough. Which is why I try to poke holes in some of these comments!

 Sage has thought about this--we have models for both:

 RDF -- The real double field with provides wrappers around the  
 machine's native (double) floating point arithmetic, fast but  
 possibly machine-dependent
 RealField(n) -- n-bit mentissa real numbers, based on mpfr. Slower,  
 but every operation follows strict and reproducible rounding rules.

 There is also support for real interval fields, and the (now  
 deprecated for reasons very similar to the start of topic of this  
 thread) quad-double model, and even real lazy fields whose entries  
 are computed on the fly to whatever precision is needed.

 RDF, which appears to be a slow version of machine arithmetic,
presumably even
slower when accessed through whatever layers python has, is the
competition
for Java, which in this case would not be strictfp.

Neither seems likely to be very favorable for traditional scientific
computing, but perhaps you can provide an example with some timing?
A comparison with the same program/hardware in C might be helpful too.





 - Robert
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-21 Thread Robert Bradshaw

On Jan 21, 2009, at 3:34 PM, rjf wrote:

 On Jan 21, 11:54 am, Robert Bradshaw rober...@math.washington.edu
 wrote:


 I am sure that some Sage people have thought about such things, but
 probably not
 enough. Which is why I try to poke holes in some of these comments!

 Sage has thought about this--we have models for both:

 RDF -- The real double field with provides wrappers around the
 machine's native (double) floating point arithmetic, fast but
 possibly machine-dependent
 RealField(n) -- n-bit mentissa real numbers, based on mpfr. Slower,
 but every operation follows strict and reproducible rounding rules.

 There is also support for real interval fields, and the (now
 deprecated for reasons very similar to the start of topic of this
 thread) quad-double model, and even real lazy fields whose entries
 are computed on the fly to whatever precision is needed.

  RDF, which appears to be a slow version of machine arithmetic,

Not sure what you mean here, unless you're comparing to 32-bit C floats.

 presumably even
 slower when accessed through whatever layers python has, is the
 competition
 for Java, which in this case would not be strictfp.

 Neither seems likely to be very favorable for traditional scientific
 computing, but perhaps you can provide an example with some timing?
 A comparison with the same program/hardware in C might be helpful too.


Yes, manipulating individual C doubles wrapped as Python objects will  
be slow, no matter how efficient the wrapping. But if you're  
manipulating enough individual elements to worry about the speed,  
then chances are there's a higher-level structure involved. For  
example, if you make a matrix over RDF, the entries are not stored  
individually wrapped, but as a single double*. In our case, linear  
algebra is done via NumPy, which in turn uses a BLAS (with Sage we  
ship ATLAS). On the other hand, if one is doing a problem that isn't  
easily phrased as a linear algebra/differential equations/etc.  
question for which there is already an optimized library/code, that's  
where Cython comes in, where one can compile code that operates on C  
doubles directly (and, because it compiles down to C, is just as  
efficient). It also fits in with the 90-10 philosophy, making it easy  
to optimize only those parts one needs to (instead of writing the  
whole thing in a more restrictive (depending on your tastes) language  
just so your couple of inner loops can be fast enough).

Getting back to the topic of the thread, I think a reason Python is  
nice for scientific programming is that it's easy to learn, easy to  
read, and easy to prototype in, and has a rich set of libraries to  
work with. On the other hand, when you need raw number crunching  
speed there are good tools out there to interface with or write at a  
lower level (e.g. Cython, or all that's been wrapped by SciPy and Sage).

- Robert


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-20 Thread rjf

You might like to read
 How Java’s floating-point hurts everyone everywhere (1998)
by W Kahan, J D Darcy
and other papers (like Darcy MS thesis).
http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf
for arguments that suggest  Java has certain problems with floating-
point .

On the other hand, it may be the case that Python's floating-point
spec is worse,
and the same arguments hold against Python.
(I haven't studied it).

Certainly if you are concerned with the comparison you should be aware
of the paper by Kahan.
As I recall, some of the arguments by Kahan/Dancy may have been
ameliorated somewhat by
further Java refinements.

If the argument is whether python or java makes a better language for
scripting the access to
scientific libraries, perhaps the subject of this thread should be
something else, and the comparison
should not be between python and java.

My favorite scripting language is still Lisp, but I have used visual
basic, tcl, jscript, and some others.

And if you want to look at languages widely used for scientific
computing, there are several, some with the name FORTRAN,
like Fortran 90.
and also Fortress (from Sun).  Or C.



On Jan 20, 3:35 am, David Joyner wdjoy...@gmail.com wrote:
 Hi:

 This is not Sage-specific, but there is an interesting thread
 on the scipy-users list that some people on this list may like to
 follow:http://projects.scipy.org/pipermail/scipy-user/2009-January/019440.html
 In particular, this pagehttp://sites.google.com/site/almarklein/python-3
 (on python vs matlab) and this 
 pagehttp://sites.google.com/site/almarklein/quest
 (on Python as the best for a scientific platform) might be interesting
 to some on this list.

This last article says,
The most important argument is that in order to do scientific
computing, you need an interpreted programming language. Still, I
enjoyed coding C# and think it is a great language that allows making
applications in a very short amount of time.


This is quite interesting, but so far as I can tell, entirely
unsupported  by anything in the article.
It also suggests that the writer is kind of ignorant of programming
language technology. Perhaps
he means interactive rather than interpreted?
Or perhaps he means that for the last 50+ years since 1956, all those
people who thought
they were doing scientific computing in FORTRAN uh, really couldn't
have been doing that at all?

RJF


 - David JOyner
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-20 Thread Harald Schilly



On Jan 21, 12:29 am, rjf fate...@gmail.com wrote:
 You might like to read
  How Java’s floating-point hurts everyone everywhere (1998)
 by W Kahan, J D Darcy
 and other papers (like Darcy MS 
 thesis).http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf
 for arguments that suggest  Java has certain problems with floating-
 point .


Hello, I don't have time to read those 81 pages, but it is from 1998
and i can't find the strictfp keyword. This might be due to the
release of java 1.2 in dec. 98, where this keyword was introduced.
Have a look at http://en.wikipedia.org/wiki/Strictfp Things have
changed till then...
Aside that, there are other libraries for numerical maths that can be
used from java. Also, since 98 there was a lot of progress around
java. Therefore, I think such a publication from 98 must be adopted to
reflect all the changes up to the current version 6 or upcoming
version 7 to be valid.

h
--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-20 Thread Luiz Felipe Martins

My understanding is that, since Python is based on C, it is IEEE-754
compliant (as long as the CPU is, which I think is true for all the
modern CPUs).

Jython might be a different story. (Which, I just learned, is alive
and has a new version just released.)

Also, I think the Java changed its floating-point support a while ago.
From what I remember, the problem was that they wanted Java code to
produce exactly the same results in all possible platforms, and in
doing so, their floating-point became non-compliant. I guess now they
have alternative classes of floating-point routines.

On Tue, Jan 20, 2009 at 6:29 PM, rjf fate...@gmail.com wrote:

 You might like to read
  How Java's floating-point hurts everyone everywhere (1998)
 by W Kahan, J D Darcy
 and other papers (like Darcy MS thesis).
 http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf
 for arguments that suggest  Java has certain problems with floating-
 point .

 On the other hand, it may be the case that Python's floating-point
 spec is worse,
 and the same arguments hold against Python.
 (I haven't studied it).

 Certainly if you are concerned with the comparison you should be aware
 of the paper by Kahan.
 As I recall, some of the arguments by Kahan/Dancy may have been
 ameliorated somewhat by
 further Java refinements.

 If the argument is whether python or java makes a better language for
 scripting the access to
 scientific libraries, perhaps the subject of this thread should be
 something else, and the comparison
 should not be between python and java.

 My favorite scripting language is still Lisp, but I have used visual
 basic, tcl, jscript, and some others.

 And if you want to look at languages widely used for scientific
 computing, there are several, some with the name FORTRAN,
 like Fortran 90.
 and also Fortress (from Sun).  Or C.



 On Jan 20, 3:35 am, David Joyner wdjoy...@gmail.com wrote:
 Hi:

 This is not Sage-specific, but there is an interesting thread
 on the scipy-users list that some people on this list may like to
 follow:http://projects.scipy.org/pipermail/scipy-user/2009-January/019440.html
 In particular, this pagehttp://sites.google.com/site/almarklein/python-3
 (on python vs matlab) and this 
 pagehttp://sites.google.com/site/almarklein/quest
 (on Python as the best for a scientific platform) might be interesting
 to some on this list.

 This last article says,
 The most important argument is that in order to do scientific
 computing, you need an interpreted programming language. Still, I
 enjoyed coding C# and think it is a great language that allows making
 applications in a very short amount of time.
 

 This is quite interesting, but so far as I can tell, entirely
 unsupported  by anything in the article.
 It also suggests that the writer is kind of ignorant of programming
 language technology. Perhaps
 he means interactive rather than interpreted?
 Or perhaps he means that for the last 50+ years since 1956, all those
 people who thought
 they were doing scientific computing in FORTRAN uh, really couldn't
 have been doing that at all?

 RJF


 - David JOyner
 




-- 
The main things which seem to me important on their own account, and
not merely as means to other things, are knowledge, art, instinctive
happiness, and relations of friendship or affection.
   -Bertrand Russell

L. Felipe Martins
Department of Mathematics
Cleveland State University
luizfelipe.mart...@gmail.com

--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: python vs java for scientific computing

2009-01-20 Thread rjf



On Jan 20, 5:15 pm, Luiz Felipe Martins luizfelipe.mart...@gmail.com
wrote:
 My understanding is that, since Python is based on C, it is IEEE-754
 compliant (as long as the CPU is, which I think is true for all the
 modern CPUs).

There are many ways of being compliant with IEEE-754.  If Sage is
supposed to get the same answers on any computer it runs on, then
IEEE-754 compliant is no assurance of anything.  Indeed, if Sage
must get the same floating point answers on every computer, it will
run substantially slower than it should, on some.  And get answers
that are less accurate.



 Jython might be a different story. (Which, I just learned, is alive
 and has a new version just released.)

 Also, I think the Java changed its floating-point support a while ago.

I mentioned that in my earlier note.

 From what I remember, the problem was that they wanted Java code to
 produce exactly the same results in all possible platforms, and in
 doing so, their floating-point became non-compliant.

Actually this is quite well described in Kahan/Darcy, and I think the
principal result is sort of the opposite.

That is, you can make programs that produce exactly the same result,
except it will slow down the fastest
computers, produce less accurate results than would otherwise be
obtained, and reduce various parts of
the environment to the least powerful. That's what you get for
strictfp, and was the default behavior prior to
JVM 1.2 (according to wikipedia article).  Running strictfp makes some
(ordinarily much faster) Intel floating point
processors just as slow as Sun processors, and also makes the results
less accurate on Intel than would be ordinarily.
Both Sun and Intel are compliant in various senses, but note that the
IEEE-754 specifies the minimum number of bits in
registers for double-float exponents and fractions, not the maximum.


It may seem odd, but a programmer might want to have the best possible
results for each computer, even if it means
 DIFFERENT results on different computers.  This was what W. Kahan
convinced Bill Joy was the right thing to do.
I do not know if strictfp totally satisfied Kahan, or if it conforms
to Darcy's design of the Borneo language.

In my experience, people doing scientific calculations for a living
will not tolerate a language implementation X whose programs are
substantially slower than equivalent ones in a language implementation
Y.  (note that X and Y may be the same language but different
implementations!)  Comparing Java to Python but leaving out C is
therefore not terribly relevant.
(Except in scripting, GUI development, etc.)


--~--~-~--~~~---~--~~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---