[Numpy-discussion] matlab vs. python question

belinda thom bthom@cs.hmc....
Wed Apr 25 16:53:31 CDT 2007


On Apr 25, 2007, at 12:46 PM, Bill Baxter wrote:

> On 4/26/07, Robert Kern <robert.kern@gmail.com> wrote:
>> Sturla Molden wrote:
>>> On 4/25/2007 8:34 PM, Robert Kern wrote:
>>>
>>>> The things that I get annoyed with every time I have to read  
>>>> some Matlab code
>>>> are the lack of namespaces and first-class function objects.
>>>
>>> Matlab does have first-class function objects. You can get a  
>>> handle to
>>> any function using the @ operator. Matlab has closures as well.
>>
>> I wish people would use them, then.
>
> I think part of the problem is that most people who learn Matlab learn
> it in school strictly as a computing tool rather than a programming
> language.  But there are many language features that people just don't
> know about, because writing nice programs is not usually the emphasis
> in the courses where Matlab is taught and used.
>
> Python is better generally as a language, although the self. thing
> makes me want to pull my hair out sometimes.  I find myself bending
> over backwards to avoid creating classes just because converting a
> function into a method generally results in an annoying amount of
> self.this self.that self.theother junk.

Agree w/most of what you've said, but will add one other thing that  
drives me nuts in python that hasn't been a problem in Matplotlib:

In Python, if interacting w/the interpreter as your primary IDE, and  
if you've got multiple files that depend on one another that you're  
modifying, then you need to restart the interpreter frequently b/c  
otherwise things in the interpreter can be stale; IOW, changes to  
several interdependent files aren't easy to import so that everything  
in your interpreted environment reflects the latest code. Yeah,  
there's reload tricks, but doing them in the right order and the  
right number of times can be a pain when dependencies are cyclic.

I realize in general that this issue of stale code is just difficult,  
that its not inherently a Python problem per se, for automatic  
percolation of code changes backwards in time is difficult in  
general, but I've never had the problem bite me when I was developing  
in Matlab. I just save whatever file, and it appears that whatever's  
latest on disk is what's executed. (Friends who know more about PL  
than I tell me I've been lucky.)

It was particularly a problem for me when I was using matplotlib  
interactively, which relates to this discussion b/c people often use  
Matlab for the graphing. W/that package, I couldn't use something  
like IDLE in such a way that it restarted its session every time I  
asked it to run a changed file. IDLE was nice, though, in that it had  
mouse-settable break points for debugging. That's the other big miss  
for me: Python's debugger is cumbersome to use.

Chris mentioned the IDE issue earlier. IMHO, IPython is a better IDE  
than IDLE, but its features (e.g. %psource prints code from disk, so  
most recent changes are displayed, but it doesn't reflect the code  
that an object actually executes) caused me even more confusion  
regarding stale code initially.

I've finally gotten used to developing w/IPython (using Francisco's  
debug_here() hack for better debugging integration), and I'm almost  
as productive as I was before, but it took several months to get there.

I've used Matlab's GUI stuff a bit and didn't find it as awful as  
others on this post claim. It also has the nice advantage of handling  
both GUI and figure-related threads in the same loop, so I could use  
it to write more sophisticated applications than one should do when  
using matplotlib+python alone. But I've yet to really use Python- 
based GUIs, which are probably much better than what Matlab has to  
offer.

HTH,
--b



More information about the Numpy-discussion mailing list