python: something completely different

Grant Griffin grant.griffin at
Mon Nov 8 17:40:15 EST 1999

Thomas A. Bryan wrote:
> Grant Griffin wrote:
> > I don't know if a Matlab-to-Python translator is currently available,
> > but if not, I don't think it would be all that hard to write one (in
> > Python, of course).
> I'm sure how useful such a thing would be.  Most people I know who
> seriously use Matlab use at least one of its toolboxes. 

It would be a shame if somebody were to translate a whole toolbox. 
(Don't try this at home, kids.... ;-)

> They also
> tend to output plots/graphs when they're done with their work, and
> Matlab actually makes some very nice plots.  I haven't looked at the
> state of Python plotting/graphing in about a year, but when I last
> looked, I judged that the effort to produce nice plots with Python
> would be considerable.

One could take a cue from Octave here.  Octave provides Matlab-style
plot commands which are simply wrappers to Gnuplot.  (However, Octave's
reliance on Gnuplot creates a significant installation barrier in the
Windows world.)

Speaking as someone who is very new to Python, I am impressed by the
variety of plotting schemes available for it, as well as somewhat
bewildered by them.  From a new user's point of view, one would like to
be handed "standards" (while still having choices).  Python's use of Tk
is a good example of this balance relative to GUI.  I believe that the
inclusion of some sort of high-quality, portable, easy-to-install,
standardized plotting system would go a long way to helping Python
invade Matlab's turf.  Perhaps one of the plotting systems currently
available meet all these needs, if only it were given the blessing by
being distributed with NumPy.

> That said, from what I remember of Matlab syntax, it probably would
> be a fairly straight-forward project to implement a translator for
> the basic vector/array/structure/scripting syntax (assuming that
> we're translating to a Python with Numeric Python compiled).  It
> might be a fun project, but it probably wouldn't move too many
> people away from Matlab until they could get colored, labeled,
> scaled plots from Python.  Most people would also have to be willing
> to code the few crucial routines that they've been using from a
> Matlab toolbox.  Of course, if the translator existed, maybe
> more people would try to move to Python.  That could spur a
> lot of growth in toolboxes for Numeric Python! :)

I guess the distinction is that Matlab really is a "system" (consisting
of a language, toolboxes, and plotting), whereas Python is primarily a
"language", which obviously is extensible _into_ a system (many systems,
actually).  Therefore, Matlab users aren't going to switch in large
numbers until a Python alternative becomes viable as system.  OTOH,
since Python would give them many advantages outside of the Matlab
paradigm (as well as being free/open), that's an inducement.

Python's extensibility already allows it to easily "co-opt" C code to
form new libraries, but the existance of a high-quality Matlab-to-Python
translator would largely solve the library problem, since existing
free/open libraries from Octave, Scilab, could be automatically
translated.  The most obvious way to write a translator like this would
be in Python itself, but perhaps the most expedient way to write a truly
robust translator would be to borrow the parser/lexer from Octave; given
a tree of Matlab syntax generated by the guts of Octave, one could then
"pretty-print" the tree into Python.  (Sounds like a fun project for you
language hobbyists out there...)

Last, since several plotting systems are already available for Python,
one could be chosen as a standard, then adapted as necessary to provide
functionality similar to Matlab's plots.


Grant R. Griffin                                       g2 at
Publisher of dspGuru                 
Iowegian International Corporation

More information about the Python-list mailing list