Why choose Python (subtitled: the lure of the tool)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Why choose Python (subtitled: the lure of the tool)

Peter Bowyer
Hi,

As you may remember from previous posts, I am researching ways to
improve the teaching of programming to physics students.

In the past as with most physics departments the course was taught as
an introduction to C or Basic.  This worked fine up to the late 90s
when most students had experience of programming.  The structure here
has been to have an introductory course in the 2nd year teaching
people how to program, and then an optional course in the 3rd year
introducing computational physics.

My idea was to teach the basics using Python and scientific
modules.  However, the question I am consistently coming up against
is "Why not teach the students Matlab?".  It's a very good point and
one I can think up no clear answer for.  If the students stay in
Physics or a related field they will be using Matlab (and
C/C++/Fortran if needed).  therefore is there any reason not to teach
this as the introduction to programming?

My arguments at present are that Matlab is a proprietary tool so the
cost to students in obtaining copies will be not inconsiderable
(considering it will only be used for a short course), and that
Matlab is a specialised tool, so those not interested in going on
into a physics related field will not find it of any use (unlike Python).

The arguments for Matlab are stronger:
1) It's a standard tool, widely used
2) It is easier to install and maintain (discounting the Enthought
edition for a moment, Python is CRAP compared with other langauges -
where is the Package manager to make life easier?)
3) The editor has a good interface (v7 and above) which IDLE lacks
(no data inspector 'right there')
4) Integrated help for all the scientific functions

Are there any reasons you can think of that Python makes a better
choice than Matlab?  I myself would far rather use Python (I have
ideas about how VPython can help the students understand Python) but
need a more robust reason than a handwaving argument about
"3D...easier for students to visualise...".

Toby Donaldson made a good point in his post on 17/10/05:
>Python's a good choice of language when you want to talk about
>"programming as computation" to people who don't have a lot of CS or
>math background. It's also good for talking about algorithm
>correctness. And I use it all the time as pseudocode and one-shot
>scripts.
>
>It's not so good for talking about "programming as exploiting your
>computer", i.e. when it comes time to implement an algorithm
>*efficiently*.

The people doing my course know absolutely nothing about programming,
but at the same time being physics, every member of staff mentions
efficiency in the same sentence as programming :-)  With that said,
now the grounds are switched from teaching C/Python to Matlab/Python
it doesn't appear to be such a valid argument.

Regards
Peter

--
Maple Design - quality web design and programming
http://www.mapledesign.co.uk 

_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

David Boddie
On Wed Oct 19 10:25:12, Peter Bowyer wrote:

> As you may remember from previous posts, I am researching ways to
> improve the teaching of programming to physics students.

[...]

> My idea was to teach the basics using Python and scientific
> modules.  However, the question I am consistently coming up against
> is "Why not teach the students Matlab?".  It's a very good point and
> one I can think up no clear answer for.  If the students stay in
> Physics or a related field they will be using Matlab (and
> C/C++/Fortran if needed).  therefore is there any reason not to teach
> this as the introduction to programming?

The question is: would you use Matlab in an introductory programming
course for students in other disciplines? I think it's worth separating
general programming skills from computational techniques.

> My arguments at present are that Matlab is a proprietary tool so the
> cost to students in obtaining copies will be not inconsiderable
> (considering it will only be used for a short course), and that
> Matlab is a specialised tool, so those not interested in going on
> into a physics related field will not find it of any use (unlike Python).

I think these are both strong arguments against it, though you might
find some resistance to the second. After all, these students are being
educated as physicists in the assumption that at least some of them will
stay in the profession.

> The arguments for Matlab are stronger:
> 1) It's a standard tool, widely used
> 2) It is easier to install and maintain (discounting the Enthought
> edition for a moment, Python is CRAP compared with other langauges -
> where is the Package manager to make life easier?)

Are you talking about distributions of the actual language runtime and
standard library, or installing packages, or something else?

> 3) The editor has a good interface (v7 and above) which IDLE lacks
> (no data inspector 'right there')
> 4) Integrated help for all the scientific functions

It sounds like you need some kind of IDE, with possibly specialized
support for scientific or mathematical computing. I'm afraid I'd can't
suggest one for Python, although I'd be interested in hearing just
which features you think it would require.

> Are there any reasons you can think of that Python makes a better
> choice than Matlab?  I myself would far rather use Python (I have
> ideas about how VPython can help the students understand Python) but
> need a more robust reason than a handwaving argument about
> "3D...easier for students to visualise...".

I keep coming back to the licensing issue. The most motivated students
will want to experiment in their own time. If they have to spend that
time in a computer lab then that might impact their motivation.

> Toby Donaldson made a good point in his post on 17/10/05:
[...]
> >It's not so good for talking about "programming as exploiting your
> >computer", i.e. when it comes time to implement an algorithm
> >*efficiently*.

You can still learn about efficiency in Python. The result just might not
be as fast as you would like. :-)

> The people doing my course know absolutely nothing about programming,
> but at the same time being physics, every member of staff mentions
> efficiency in the same sentence as programming :-)  With that said,
> now the grounds are switched from teaching C/Python to Matlab/Python
> it doesn't appear to be such a valid argument.

I don't believe that I was all that great at physics or mathematics at
university, but I found that I enjoyed experimenting with different
programming languages.

As a physics student, I was initially taught Pascal, then Fortran, and
finally 8086 assembler and the language used in Maple, but none of these
have been particularly useful. Later on, I needed to use Matlab and found
my way to RLaB, which I'm happy to see has recently been brought back to
life as a different project:

  http://rlabplus.sourceforge.net/

In the end, I went from RLaB to Python precisely because Python is a more
general purpose and extensible language. For anything that required
intensive computation, I used C with the help of the Numerical Recipes book
and processed the results with Python. In an ideal world, I'd have used
an ODE solver from Python.

To conclude, I'd say that Python gives you lots of opportunities to
experiment with non-scientific libraries and tools (such as GUIs and web
interfaces) while still supporting some scientific computing. Matlab may
cover the scientific domain more extensively, but it might be tricky to
integrate with other tools (assuming that you have the time and inclination
to explore that avenue).

I still think that RLaB is worth checking out. Although it didn't have
the integrated environment that you presumably get with Matlab, I seem to
remember that it was fairly nice to use, and it provided some reasonable
basic visualization (plotting) facilities.

David
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

Dethe Elza

On 19-Oct-05, at 5:01 PM, David Boddie wrote:
> You can still learn about efficiency in Python. The result just  
> might not
> be as fast as you would like. :-)

Coding in Python and using external libraries is pretty damn fast.  I  
know of one government physics lab that uses Python wrappers around  
their Fortran libraries, for instance.

> In the end, I went from RLaB to Python precisely because Python is  
> a more
> general purpose and extensible language. For anything that required
> intensive computation, I used C with the help of the Numerical  
> Recipes book
> and processed the results with Python. In an ideal world, I'd have  
> used
> an ODE solver from Python.

I don't know if it includes an ODE solver (since I don't know what  
that is), but have you checked out Matplotlib (http://
matplotlib.sourceforge.net/), which aims to reproduce at least some  
of the functionality of a Matlab/Mathematica/Maple? It is also part  
of the larger SciPy project (http://www.scipy.org/About/) which  
appears to be even closer to your "ideal world."

HTH

--Dethe

"And you think you're so clever and classless and free"
— John Lennon on prototype-based programming


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

Peter Bowyer
In reply to this post by David Boddie
At 01:01 20/10/2005, David Boddie wrote:
>The question is: would you use Matlab in an introductory programming
>course for students in other disciplines? I think it's worth separating
>general programming skills from computational techniques.

Good point

>Are you talking about distributions of the actual language runtime and
>standard library, or installing packages, or something else?

I'm talking about packages.  Coming from PHP with a package manager,
and having used Debian, the lack of this hurts!  It makes upgrading
on Windows something to be dreaded rather than welcomed - which is
why I'm still on 2.3.

>It sounds like you need some kind of IDE, with possibly specialized
>support for scientific or mathematical computing. I'm afraid I'd can't
>suggest one for Python, although I'd be interested in hearing just
>which features you think it would require.

I really appreciate having an inspector window to show me the values
of variables, either all of them or ones I've asked it specifically
to watch.  This saves me from having to put in print statements or
(at the interactive shell) to keep typing the variable names to see
what happened after the last equation was executed.

I'll think about the rest, there have been other things.  I like an
integrated searchable manual for a number of reasons.

>You can still learn about efficiency in Python. The result just might not
>be as fast as you would like. :-)

Heh, very true although I hold the learning will not be similar to
the optimising needed for a C program!

>...I needed to use Matlab and found
>my way to RLaB, which I'm happy to see has recently been brought back to
>life as a different project:
>
>   http://rlabplus.sourceforge.net/

There seem to be a lot of these around, Scilab and Octave just to
mention two others.  This always annoyed us, as one professor would
make us use Scilab while another used a very old version of Matlab
(not teaching the syntax for either).  It's one reason I support a
one tool fits all situation.

>In an ideal world, I'd have used an ODE solver from Python.

How about scipy.integrate.odeint :)

Peter

--
Maple Design - quality web design and programming
http://www.mapledesign.co.uk 

_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

Laura Creighton

Given that you are talking about enriching the experience for the
physics student, be advised that they use computers in two very
different ways.

The first way works fine living inside a closed system such as
SAS, Matlab or whatever.  You have your data, and you take it into
the world-of-matlab, and then you do whatever it is that the designers
of Matlab thought would be cool and useful things to do.  Courses such
as 'how to get the most out of Matlab' are extremely useful and
justifiably popular.

But the other thing to use computers for is to build our own models,
libraries, worlds and what-have-you.  This, be definition, cannot
be done in sombody else's world.  The skills to do this have to come
from somewhere else -- and this is where a course in Python might be
most useful.

But they are different skills.  And the baby-step things they have
in common mostly don't have to be taught at all -- physics students
can learn these things by reading the appropriate manuals.

My person al belief is that most physicists would get more joy out
writing programs and get better results if they learned to do
test driven development when they wrote their own code, so if your
goal is to improve the experience for the physics major, I would
start there.

Laura
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

David Boddie
In reply to this post by Dethe Elza
On Thursday 20 October 2005 06:19, Dethe Elza wrote:
> On 19-Oct-05, at 5:01 PM, David Boddie wrote:
> > You can still learn about efficiency in Python. The result just
> > might not be as fast as you would like. :-)
>
> Coding in Python and using external libraries is pretty damn fast.  I
> know of one government physics lab that uses Python wrappers around
> their Fortran libraries, for instance.

Sure, but then you're learning about efficiency with Fortran. :-)

> > In the end, I went from RLaB to Python precisely because Python is
> > a more general purpose and extensible language. For anything that
> > required intensive computation, I used C with the help of the
> > Numerical Recipes book and processed the results with Python. In an
> > ideal world, I'd have used an ODE solver from Python.

Just to add an explanation: Wikipedia appears to have a fair amount of
material on ordinary differential equations (ODEs). I suppose the
following page would be a fairly good place to start reading about them:

http://en.wikipedia.org/wiki/Ordinary_differential_equation

> I don't know if it includes an ODE solver (since I don't know what
> that is), but have you checked out Matplotlib (http://
> matplotlib.sourceforge.net/), which aims to reproduce at least some
> of the functionality of a Matlab/Mathematica/Maple? It is also part
> of the larger SciPy project (http://www.scipy.org/About/) which
> appears to be even closer to your "ideal world."

I don't do this sort of thing much any more. I think it doesn't really
need to be said but, if I was to repeat the university experience, I'd use
Python a lot more. :-)

At this point, I don't even know whether the original poster is still
reading, or whether he's already resigned himself to teaching programming
with Matlab.

David
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

Peter Bowyer
At 21:45 20/10/2005, you wrote:
>At this point, I don't even know whether the original poster is still
>reading, or whether he's already resigned himself to teaching programming
>with Matlab.

Still here.  I posted a reply to your previous message, have you not
seen it on the list?  The threading for this particular thread
appears pretty messed up in Eudora, not sure what's happened there.

Peter

--
Maple Design - quality web design and programming
http://www.mapledesign.co.uk 

_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Why choose Python (subtitled: the lure of the tool)

David Boddie
In reply to this post by Peter Bowyer
On Thu Oct 20 18:23:28, Peter Bowyer wrote:

[IDE features]

> I really appreciate having an inspector window to show me the values
> of variables, either all of them or ones I've asked it specifically
> to watch.  This saves me from having to put in print statements or
> (at the interactive shell) to keep typing the variable names to see
> what happened after the last equation was executed.
>
> I'll think about the rest, there have been other things.  I like an
> integrated searchable manual for a number of reasons.

It would be good to have a decent general IDE to use as a platform on which
to add more specialized features. I imagine that most IDEs have some kind of
plugin architecture to allow this.

> >   http://rlabplus.sourceforge.net/
>
> There seem to be a lot of these around, Scilab and Octave just to
> mention two others.  This always annoyed us, as one professor would
> make us use Scilab while another used a very old version of Matlab
> (not teaching the syntax for either).  It's one reason I support a
> one tool fits all situation.

Yes, it may be difficult to justify choosing any given Matlab-like
environment over the others.

> >In an ideal world, I'd have used an ODE solver from Python.
>
> How about scipy.integrate.odeint :)

That would probably have done the trick, but I can't remember if that was
available at the time.

David
_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig