[SciPy-user] Python evangelism question: procedural programming
Fri Aug 3 11:40:57 CDT 2007
On 8/3/07, Gael Varoquaux <email@example.com> wrote:
> On Fri, Aug 03, 2007 at 09:55:17AM -0500, Ryan Krauss wrote:
> > So, he wanted to know if Python could be used like Mathematica in
> > terms of writing rule and procedure based programs. I don't know how
> > difficult this would be.
> I think I understand what he means. Python can almost be used like this,
> but there is the UI missing. Ipython is currently working on a "notebook"
> UI that would address this problem. I have developped my own workflow
> using a home made script ("pyreport"
> http://gael-varoquaux.info/computers/pyreport/ ) to approach this
> workflow. Ultimately I want to merge this with ipython's effort in order
> to get nice notebook functionnality with html and pdf output, but
> xurrently I don't have time for this.
You better make time soon. Min has already written a plaintext dump
format for the notebook, you'll be getting an email about that in a
minute. We need you :)
But back to the OP, I think the issue Ryan's colleague has isn't
addressed by a notebook interface, nor by SAGE (as great as SAGE is).
Mathematica's programming model/language can be very tricky to wrap
your head around, but it allows you to do *phenomenal* things in very
concise way, that would be extremely clunky in Python or any other
language I can think of.
Mathematica is very lisp-ish in its model, and its syntax for building
complex programs can be quirky, and its encapsulation model is rather
poor. But for rule-based programming it's hard to beat, it exposes
every object it has in a completely uniform way so that you can do
abstract manipulations on them, and it has very rich transformation
facilities. Doing things like "take an arbitrarily nested object,
traverse it and replace every instance of '(x-y)^4' by a polynomial
over z^2" are one-liners in Mathematica.
Honestly I'd say that if Ryan's colleague has a lot of code like that,
Python is NOT the answer for him. Rather, he should learn to use
Python because it *complements* Mathematica very well. Python is
good, easy to use and convenient to work with precisely at many of the
things that Mathematica is clunky for. They obviously have a lot of
overlap, and I personally use Python where they overlap simply because
I'm more proficient in Python these days. I'm sure he could go for
Mathematica in that region for the same reasons.
But there is definitely a domain where Mathematica is simply
unbeatable, and that goes beyond the obvious triad of (notebook,
symbolics, easy-to-control pervasive arbitrary precision).
These days my working toolbox is more or less just Python+Mathematica,
for these very reasons (and Python obviously includes C/C++/Fortran as
needed for low-level/speed work).
More information about the SciPy-user