in reply to Re: Stereotypes about perl
in thread Stereotypes about perl

Furthermore your professor and TA are right in that Perl has a lot of overhead for complex math calculations. If I was doing a lot of numerical manipulation and performance mattered, then Perl would not be my first (or second..) choice. Part of the art of choosing the right tool for the job is knowing when your favorite tool isn't it.
Yes but no where is it made clear that Perl isn't the right tool for the job. Hell, I thought think Perl would be even better for this particular purpose as it lets you concentrate on the algorith itself. Since it's purely educational, it doesn't matter if the code compiles/runs in 1 second or 5 seconds, you can use the same algorithms and techniques in any language.

Now, if he had to do large amounts of mathematical operations in a really small amount of time such as breaking cyphers and so forth then I might agree that perl is not the right choice. But for writing basic algorithms to learn them, I have yet to see anything that suggests perl isn't the best choice.

Updated: Added "small amount of time" to further clarify my position.

Replies are listed 'Best First'.
Re: Re: Re: Stereotypes about perl
by tilly (Archbishop) on Feb 25, 2004 at 21:31 UTC
    Let me make it clearer why Perl is the wrong tool for the job.

    The exercise that had to be coded involved matrix calculations.

    In Matlab or Octave, matrices are native datatypes, and a variety of useful functions are available for manipulating them. Sure, it is easy enough to write a Perl implementation of matrices and basic matrix operations. But the notation that you will wind up with will be more verbose, and you will be open to the possibility that you are getting wrong answers because your routines are wrong. Furthermore when you get to more complex operations, you won't know enough to, for instance, come up with a good way to compute the eigenvalues of a matrix. Matlab already has that done for you. (I can find ways to compute it. I doubt that I would do it nearly as efficiently and accurately as Matlab does. A student just learning the subject would not be expected to do as well as I can.)

    There is great value in only writing the algorithms that you need without having to reinvent the wheel.

    In Perl you can resolve that problem if you know about PDL. But PDL is an installation dependency that whoever is grading you doesn't know, and has to go through. And furthermore they don't know whether to trust it (is the bug yours, or PDLs?). Also if you run into trouble, they can't help you with it since they don't know it, and they likewise don't know if the bug is with your code, PDL or your understanding of PDL's API. There is a huge advantage to using tools that people around you are able to help you with. Perl isn't that tool.

    Now C++ shares some of the disadvantages that Perl does. My guess is, though, that there is a standard math library that has been provided for C++ people. Any language with the right library gets back some of the advantages that Matlab has. If the instructors are familiar with it, it gets back most of the rest. (I would consider Matlab a better tool than C++ for this exercise - less conceptual overhead.)

    Furthermore for a Perl fanatic, there is another advantage of not using Perl. It is very easy to become overattached to your favorite tool. Yes, we all know that you can pick up more tools, and skills should transfer. But making that transfer takes practice at translating from thinking in language X into thinking in language Y. Therefore forcing yourself to use a different language from time to time is a good way to make sure that YOU have the valuable skill of adapting to a new language/environment.