As I prepare for my semesters teaching, I'm reminded of why I don't like teaching students python as a numerical calculation tool. Personally, I am very happy with python, and use it all the time. But I had allot of languages under my belt already when I learned it, which was well before numpy came into existence. Now, it's create to see things like Canopy emerging. But, if we really want it to accessible as a learning tool, we can leave huge sinkholes in the road of learning.
My complaint is that there is some simple but common inconsistencies that I
mess up all the time in scipy, and
will cause unnecessary nightmares for my students. Specifically, array size is
not specified consistently accross pylab. If you want to create a random 2x2
array, you call randn(2,2)
. But if you want to create a 2x2 array of all
numbers, you call ones((2,2))
. And there's no alternative that's consistent!
Both rand((2,2))
and ones(2,2)
generate errors, in the latter case it's a
cryptic error. Why cann't we have a little consistency!
A second complaint is the failure to adequately deal with the difference between arrays with a single element, and scalars. Having to manually convert between the two is a pain, but the bigger issue is that it forces students to learn about the intricacies about typing in a context that really isn't approprate for that -- we're just trying to do some simple computations, and want to leave the computer science to the computer scientists.
Both issues may seem rather minor, but remember that syntax errors are a huge headache for students just learning to program, and type errors are atleast a degree harder to deal with. These are the very kinds of issues that drove me to python in the first place, and now they are driving me away.
UPDATE 2014-06-09: This blog post expresses similar frustrations, allong with some possible practical solutions. Good to be part of a chorus.