'Open' languages: e.g., MATLAB 
Author Message
 'Open' languages: e.g., MATLAB

I've recently had occasion to use 'MATLAB' (tm The Math Works, Inc.), which
is a little language that gives access to some linear algebra and other
numerical analysis routines.  Apparently, it is used in undergraduate
university courses in linear algebra, numerical analysis, linear systems
theory and signal processing, and perhaps some statistical analysis courses.

Although the MATLAB language leaves a _lot_ to be desired in terms of its
elegance and clarity -- especially when compared with some of its
competitors -- e.g., APL -- it does have some interesting features which
make it easier to use.

(I haven't studied the MATLAB language thoroughly, nor do I know any of
the details of how it is implemented, so some of the items below are
educated guessing on my part.)

1.  There seems to be a 1-1 relationship between functions and files.  While
this leads to extremely small files, it also allows for the file system itself
to be part of the language 'name space'.  Apparently, when MATLAB is started
up, it searches the appropriate directories and _automagically_ builds the
appropriate 'autoload' capabilities, so that when a function is referenced,
it knows where to find it.

For those who have had to keep 'autoload' properties in Lisp systems
consistent with the locations of files, this greatly reduces that work.

This function=file relationship gives MATLAB more of a feeling of a
Unix 'shell' language, because the programmer does not have to go to any
trouble keeping the file system and the internal name space consistent.

MATLAB itself seems to go to a lot of trouble to keep the file & the function
consistent.  Although MATLAB provides its own function editor, one is
also allowed to use another editor -- e.g., Emacs -- and MATLAB apparently
notices when one of its files gets updated.

2.  MATLAB provides a 'named' scheme for multiple returned values.  If a
function produces multiple values -- e.g., the singular value decomposition
for matrices, which produces U, S, V, where U,V are unitary/orthogonal
matrices, and S is a diagonal matrix -- then one defines the function like so:

function [U,S,V] = svd(M)

and then references U,S,V by name within the function.  This is almost
a return to the yesteryear of fortran 1, where one assigned the function
name itself with a value to be returned.

Those in the prolog/logic community will find this old hat.  Those from
the Pascal/Ada community will probably be confused, since it appears
that the returned values are all constructed within the function and
passed out; these apparently are _not_ 'var'/'inout' parameters.

I'm not sure how this is implemented in MATLAB.  In particular, I'm not
completely sure what happens when a multi-valued function is used
'functionally' -- I think that perhaps only the first value is then used.

(This is one of the big problems with MATLAB -- the documentation is
woefully inadequate at explaining the intricacies of name binding,
semantics of parameter passing and value returning, etc.  For a language
that is aimed somewhat at _mathematicians_, such ambiguities and sloppiness
are unforgiveable.)

3.  MATLAB does go to substantial effort to try to get the 'right'
semantics for 'NaN's' ("Not-a-Numbers").  It may be the first language
since the Lisp Machines that really put in an effort to do this right.

4.  MATLAB shows that if the underlying subroutines are high quality, people
will put up with a lot of inelegancies in the 'scripting' language.  Some
would say that the graphing/plotting capabilities alone are worth the price of
admission.

-------

On the negative side, MATLAB's integration with the Maple symbolic
algebra package is a bad joke.  Although the Maple system itself is actually
quite good, one would have a difficult time coming to that conclusion after
trying to use Maple within MATLAB.  Apparently, the only communication
between MATLAB and Maple is in the form of character strings, so there's
a _lot_ of parsing and unparsing going on!

Also, Maple uses an entirely different set of names for operations than
does MATLAB -- e.g., MATLAB uses the single quote "'" for the transpose
(conjugated), while Maple uses the 'transpose()' function.

MATLAB understands complex numbers very well, but Maple (at least as
incorporated into MATLAB) doesn't seem to understand complex numbers
at all.

--------

In summary, MATLAB is a useful tool because of its high quality library of
built-in functions and graphing/plotting capabilities, and because it allows
a relatively simple programming model which hides many of the
problems of the internal v. file-system issues.

It is a shame, however, that 'scripting languages' like MATLAB didn't
learn a bit more from languages like APL in the areas of generalized
arrays and array-indexing, and from languages like Lisp/etc. in the
areas of data structures more sophisticated than arrays for symbolic
algebra.

I'm somewhat concerned that non-CS undergraduate students will come to
the conclusion that MATLAB is 'state of the art' in terms of computer
language design, and that misconception would be a real shame.  Perhaps the
company could at least include a disclaimer regarding the MATLAB/Maple
interface, and tell the students that they realize that it is kludgey, and
that they will attempt to improve this in the future.

--
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html



Wed, 16 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

<an interesting review of MATLAB followed by this paragraph>

Quote:
>I'm somewhat concerned that non-CS undergraduate students will come to
>the conclusion that MATLAB is 'state of the art' in terms of computer
>language design, and that misconception would be a real shame.  Perhaps the
>company could at least include a disclaimer regarding the MATLAB/Maple
>interface, and tell the students that they realize that it is kludgey, and
>that they will attempt to improve this in the future.
>--
>www/ftp directory:
>ftp://ftp.netcom.com/pub/hb/hbaker/home.html

I'd be more concerned that CS-undergrads will create languages that
mimic this kind of kludgery and attempt to ``extend it with object-
oriented capabilites''

The latter statement should be taken as a challenge to any computer
company producing software that they *know* is a kludge.  Has any
done this?



Thu, 17 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

   1.  There seems to be a 1-1 relationship between functions and files.  While
   this leads to extremely small files, it also allows for the file
   system itself to be part of the language 'name space'.  Apparently,
   when MATLAB is started up, it searches the appropriate directories
   and _automagically_ builds the appropriate 'autoload' capabilities,
   so that when a function is referenced, it knows where to find it.

   For those who have had to keep 'autoload' properties in Lisp systems
   consistent with the locations of files, this greatly reduces that work.

   This function=file relationship gives MATLAB more of a feeling of a
   Unix 'shell' language, because the programmer does not have to go to any
   trouble keeping the file system and the internal name space consistent.

To me this is actually a painful feature of Matlab.  In most serious
use of Matlab you would want to define many functions.  But it simply
takes too much time to handle this hurd of functions, and you quickly
start using silly names in order to avoid name clashes.

I find myself writing scripts in situations where I would have divided
the problem into functions if I were using a real language, like
Scheme.  I also miss Scheme's excellent support for higher order
functions. In Matlab you have to pass functions as function name
strings, and use a special syntax when you use them:

   feval(fname, arg1, arg2 ... argN);

Also, it's silly not being able to define local functions.  There is
virtually no support for mudularization of your problem in Matlab.
You want to be able to put several functions in one file, and being
able to have control over which are visible globally.  Yesterday I
was talking to an experienced Matlab user (a professor of numerical
analysis) who solves the problem by putting several functions in one
file and uses an extra argument in the file-function to select the
subfunction actually evaluated...  Of course this is ugly but, given
Matlab's limitations, I find it a smart hack around the problem.

/mdj



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

Quote:

> 4.  MATLAB shows that if the underlying subroutines are high
> quality, people will put up with a lot of inelegancies in the
> 'scripting' language.  Some would say that the graphing/plotting
> capabilities alone are worth the price of admission.

Quite so.  When I first used it (about 10 years ago), it was much
worse.  Things would inconsistently not work if you tried to nest
control structures (this was said to be because the parser was kludgy
and written in Fortran).  But the tool as a whole was still very much
worth using: even with all its problems, its value for testing
algorithm ideas was undeniable, and it was invaluable for the
undergraduate course in numerical analysis that I learned it in.
--

Utrecht University              | telephone: +31 30 2534630
Department of Mathematics       | telefax:   +31 30 2518394
P.O. Box 80010, 3508 TA Utrecht |
The Netherlands                 |


Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

RE: Matlab "programming":

I had the unfortune to have to use Matlab in a linear algebra course.
Programming the darn thing was absolutely painful -- no local variables
no local functions, no case, no scooping, no nothing to make the language
even reminiscient of civilized languages.

Matlab has an im[pressive array of features, but fora CS-student with a t
least a little (10 years+) experience of "real" languages, Matlab just
is something I will try to avoid for the rest of my life.

Why can't more people use functional languages for maths? Much simpler to
implement and extend that hacked-togehter languages. Matlab STINKS of being
hacked and cobbled together, feature for feature without systematics.

/jakob

----------------------------------------------------------------------------

                 presently an ERASMUS exchange student in Stuttgart, Germany


 homepage: http://www.csd.uu.se/~jakob



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

Quote:
> Why can't more people use functional languages for maths? Much simpler to
> implement and extend that hacked-togehter languages. Matlab STINKS of being
> hacked and cobbled together, feature for feature without systematics.

1) As far as I know, nobody have yet hooked a set of really high
   quality numerical subroutines to a functional language and
   packaged it like a sellable product.

2) If you hold your nose it _is_ possible to do high quality _work_
   in MATLAB, even if the _code_ you produce probably will not be
   very pretty (at least according to CS-standards for such things ;-)

It would be nice if someone hooked a set of routines like Matlab's to
a really portable ML or Scheme implementation, but today the most
likely candidate for such a venture is probably Java.

--

                                                    (Rmz)


Phone:+47 22855802!Universitetet i Oslo, Norway !ICBM: N595625E104337



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

Quote:

> Why can't more people use functional languages for maths?

Because people who want to use things like matlab aren't generally
familiar with functional languages.  What they want is an interactive
language similar to Fortran/BASIC/C with lots of well-tested routines
for doing mathematical things; they (we, even!) want something that
doesn't involve much learning.  The last time I looked, pure
functional languages (and in general, languages without assignment)
had problems with arrays, and in any case often the goal of using
matlab is to develop an algorithm which then gets hacked in Fortran or
C.

Quote:
> Much simpler to implement and extend that hacked-togehter languages.

You say that as if it's a bad thing to be hacked together!  It would
be interesting to look at octave, designed to be a free alternative to
parts of matlab, so it's supposed to be more-or-less compatible, but
may well be cleaner in parts.

Quote:
> Matlab STINKS of being hacked and cobbled together, feature for
> feature without systematics.

I think that's a bit unfair.  Mostly it hangs together quite nicely.

I think there's a real chance for an alternative to succeed, however.
If Guile (the FSF's Scheme-like language) goes well, and gets lots of
matrix operations and nice interfaces to gnuplot thrown in, together
with a less Lispy optional syntax, then that might do well.
--

Utrecht University              | telephone: +31 30 2534630
Department of Mathematics       | telefax:   +31 30 2518394
P.O. Box 80010, 3508 TA Utrecht |
The Netherlands                 |



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

   > Why can't more people use functional languages for maths? Much simpler to
   > implement and extend that hacked-togehter languages. Matlab STINKS of being
   > hacked and cobbled together, feature for feature without systematics.

   1) As far as I know, nobody have yet hooked a set of really high
      quality numerical subroutines to a functional language and
      packaged it like a sellable product.

   2) If you hold your nose it _is_ possible to do high quality _work_
      in MATLAB, even if the _code_ you produce probably will not be
      very pretty (at least according to CS-standards for such things ;-)

   It would be nice if someone hooked a set of routines like Matlab's to
   a really portable ML or Scheme implementation, but today the most
   likely candidate for such a venture is probably Java.

   --

                                                       (Rmz)


   Phone:+47 22855802!Universitetet i Oslo, Norway !ICBM: N595625E104337

Check out

http://nis-www.lanl.gov/~rosalia/gnudl-doc/gnudl_toc.html

It an effort to implement some useful numerical routines in
Guile (dialect of Scheme). I personally think that Common Lisp
would be much nicer to use for this, especially because there
exists Maxima ported to GNU CL at ftp.ma.utexas.edu.

But Matlab has too many useful for numerical analysis features
--- it can easily save data in binary files, it has good
graphics, etc... In short, it is incredibly ugly but quite
useful. There are a lot of "MATLAB"-like languages around, my
favorite right now is Yorick. It has more data structures (even
lists and arbitrary structures), binary I/O is very good,
graphics is decent, it is very fast and free.

Numerical people tend to stay away from Lisp, ML, etc. because
they believe that these languages are very slow compared to
C/Fortran and very difficult to learn (both statements are wrong
for those who does not know, BTW), so there is not enough good
quality numerical algorithms for them.

If someone hacked together interface to NetCDF binary data
format library to LAPACK and to some decent graphical library
for GNU CL and began to shout about it very loudly at each
corner, situation could certainly change.

Followups are trimmed a bit.



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

[ Newsgroups and followups trimmed. ]

Bjorn> It would be nice if someone hooked a set of routines like
Bjorn> Matlab's to a really portable ML or Scheme implementation,

FWIW, I have interfaced an ad-hoc collection of LAPACK to O'Caml
(INRIA's beautiful ML dialect) and I'm using it in a matlab like
fashion.  For example:

    external svd :
      float array array ->
        (float array array * float array * float array array) =
      "f77_svd_matrix_bytecode" "f77_svd_matrix_native"

    external diagonalize :
      float array array ->
        (float array * float array * float array array * float array array) =
      "f77_diagonalize_matrix_bytecode" "f77_diagonalize_matrix_native"

This is _very_ convenient, because I have a nice interactive top-level
and a decent programming language available at the same time:

# let (wr,wi,_,vr) = diagonalize g;;
# let (u,s,_) = svd vr;;

etc.

I positively do not have enough spare time to turn this into a
polished program and I probably lack the skills required for a proper
design.  But if anybody want's to follow up on this, I can donate
(send me mail) my tested C routines for shipping O'Caml arrays and
matrices to LAPACK and back.  The only non-trivial part is keeping the
garbage collector happy.  The package should work with all Fortran
compilers with f2c compatible calling conventions.  Modifications for
other compilers should be trivial.

Cheers,
-Thorsten
--
Thorsten Ohl, Physics Department, TH Darmstadt --- PGP: AF 38 FF CE 03 8A 2E A7
http://crunch.ikp.physik.th-darmstadt.de/~ohl/ -------- 8F 2A C1 86 8C 06 32 6B



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB


   RE: Matlab "programming":

   I had the unfortune to have to use Matlab in a linear algebra course.
   Programming the darn thing was absolutely painful -- no local
        variables

Sure there are!

   no local functions, no case, no scooping, no nothing to make the language
   even reminiscient of civilized languages.

Local functions are just really not all that useful for numerical
linear algebra. Not to say that they don't have their place, but...

All matlab really seems designed for is numerical analysis, in
particular numerical linear algebra. For this it works well. That's
all I use it for, so that's all it needs to do.

--Mike Gertz



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB


    RE: Matlab "programming":

    I had the unfortune to have to use Matlab in a linear algebra course.
    Programming the darn thing was absolutely painful -- no local variables
    no local functions, no case, no scooping, no nothing to make the language
    even reminiscient of civilized languages.

    Matlab has an im[pressive array of features, but fora CS-student with a t
    least a little (10 years+) experience of "real" languages, Matlab just
    is something I will try to avoid for the rest of my life.

    Why can't more people use functional languages for maths? Much simpler to
    implement and extend that hacked-togehter languages. Matlab STINKS of being
    hacked and cobbled together, feature for feature without systematics.

    /jakob

    ----------------------------------------------------------------------------

                     presently an ERASMUS exchange student in Stuttgart, Germany


     homepage: http://www.csd.uu.se/~jakob

This is the reason that I wish TMW would copy a few features from
"civilized scripting languages", e.g. Tcl. Acceptance by the CS bigots
would do a lot to move MATLAB into the software mainstream. As it is,
MATLAB is just about perfect for systems engineers. But the CS folks turn
up their noses because it shares more attributes with English than with
Latin. Of course, we all know what happened to Latin.

Surely, static local variables, for instance, can't be that hard.

Tom



Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB


Quote:

>> It would be nice if someone hooked a set of routines like Matlab's
>> to a really portable ML or Scheme implementation, but today the
>> most likely candidate for such a venture is probably Java.

g> The one problem with this idea is Java's lack of performance and
g> parallelism.

"Java's lack of performance" is at least a little of a myth.

- JIT compilers currently give acceptable performance for many
  application domains.

- With use of appropriate storage and garbage collection models, there
  is no need to box primitive types.

- As far as parallelism is concerned, Java explicitly supports a
  multithreaded programming model (although current implementations do
  not yet map threads to OS-level LWPs).

- There is nothing to stop a smart compiler from performing the same
  kind of automatic loop parallelisation as can be done for
  carefully-written numerical C code.

In short, while a lot of work remains to be done to make use of Java
acceptable for efficient numeric crunching tasks, there is nothing
intrinsic to the language that makes it a worse candidate for such
tasks than are, say, C or C++ for such tasks.  It would take some work
on the language definition in order to make the kinds of optimisations
that Fortran compilers can get away with safe in Java, though.

        <b

--
Let us pray:





Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB



t> This is the reason that I wish TMW would copy a few features from
t> "civilized scripting languages", e.g. Tcl. Acceptance by the CS
t> bigots would do a lot to move MATLAB into the software mainstream.

This is an interesting perspective on how to get acceptance.  As a "CS
bigot", I would run even farther from a Matlab that incorporated
Tcl-esque features than I am likely to from its current incarnation.

t> But the CS folks turn up their noses because it shares more
t> attributes with English than with Latin. Of course, we all know
t> what happened to Latin.

Insults tend to be somewhat more effective when they don't display
quite such ignorance of their intended targets.

        <b

--
Let us pray:





Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

Quote:

> 1) As far as I know, nobody have yet hooked a set of really high
>    quality numerical subroutines to a functional language and
>    packaged it like a sellable product.

Of course one can do "functional-style" programming in Wolfram's
Mathematica--see Chpt. 6 of John W. Gray's "Mastering Mathematica:
Programming Methods and Applications"--though the Mathematica language is
fundamentally rule-based. It would probably not be very difficult to
implement a scheme interpreter in Mathematica either.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/




Fri, 18 Dec 1998 03:00:00 GMT  
 'Open' languages: e.g., MATLAB

Someone:

Quote:
> Why can't more people use functional languages for maths? Much simpler to
> implement and extend that hacked-togehter languages. Matlab STINKS of being
> hacked and cobbled together, feature for feature without systematics.

> 1) As far as I know, nobody have yet hooked a set of really high
>    quality numerical subroutines to a functional language and
>    packaged it like a sellable product.

How about Sisal. It would come pretty close to this description. When the
development environment is released (which is supposed to be soon) it will
come even closer ..

Quote:
> It would be nice if someone hooked a set of routines like Matlab's to
> a really portable ML or Scheme implementation, but today the most
> likely candidate for such a venture is probably Java.

The one problem with this idea is Java's lack of performance and parallelism.

graham

   --
                    we howled into Berlin
                    tore the smoking buildings down
                    raised the red flag high
                    burnt the Reichstag brown



Sat, 19 Dec 1998 03:00:00 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. 'Open' languages: e.g., MATLAB

2. 'Open' languages: e.g., MATLAB

3. 'Open' languages: e.g., MATLAB

4. opening 'file open' dialog from console

5. MATLAB style 'sort' function

6. Cincom Open Sources 'Frost'

7. Intellimouse Returns 'File Not Open'

8. Can't open xxxx.DBF error in Summer '87

9. open 'no-exist' rescue true - idiom

10. 'Open' on WinNT and Win95

11. cannot open include file 'param.inc'

12. Opening a file with ACTION='READ'

 

 
Powered by phpBB® Forum Software