Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Why learn another language?

by PhiRatE (Monk)
on Nov 16, 2002 at 04:05 UTC ( #213350=note: print w/replies, xml ) Need Help??

in reply to Why learn another language?

A language is a tool, designed to solve a particular set of problems. General purpose programming languages are extremely versatile tools, and no doubt perl is one of the more extreme examples of that genre.

Even so, there is still, what I like to call, the "perl" viewpoint. It is the viewpoint of least resistance as it were, the place you tend to stand when looking at a problem to solve in perl.

The benefit of learning other languages is that they provide you with different places to stand. This is not restricted to programming languages, a good grounding in math will provide you with a particular place to stand when looking at certain types of problems. The advantage of having a large number of different places to choose from is that you are more likely to find the place that provides you with a view that makes the optimal solution obvious.

Let us take, for example, another node discussion that has recently been operating, on efficiently determining the positions and lengths of all the character runs in a particular string. A number of solutions were proposed initially, all perl, with varying degrees of efficiency.

Having done a considerable amount of programming, I was aware of two particular things about the problem proposed:

  1. The optimal algorithm was simple, there were no fancy statistical tricks that could be employed to gain speed.
  2. Therefore, the efficiency of the algorithm was the prime concern, notably avoiding any kind of copying or expensive assignment that was not necessary

My initial entry therefore was written using the Inline C module. Using this, I knew that I could control very closely the allocation of memory and avoid any unnecessary waste. The results spoke for themselves, my first example outperformed the best perl solution by a factor of two.

This is not so interesting as one of my subsequent experiments, in which I attempted to create a pure perl implementation which was as close as possible in its operation to that of the C version. A few small changes had to be made, but the end result was extremely effective. While it could not avoid entirely the costs imposed by perl itself, it was one of the two fastest perl implementations.

Thus it was my ability to stand and look at the problem from a C point of view, which led me to produce a somewhat counter-intuitive program in perl which actually performed extremely well.

This applies to many many languages.

Learning a pure OO language will provide you with an excellent place to stand when looking at problems which fall nicely into OO designs.

Learning a functional language will screw with your mind before providing you with a number of extremely effective methods of solving complex analysis and parsing problems.

Learning a stack based language will provide you with an understanding of the costs of various kinds of operations, as well as how to do things without recursion.

Learning assembler will teach you about the benefits of cache locality, how registers are used and their implications, and the implications of instruction ordering.

Learning C will teach you about allocating memory all in one chunk instead of a bit at a time, the costs, needs and implications of the various styles of memory management, the advantages of processing data in-place, and why you miss perl so very very much.

At the end of it all, you will (most likely) come back to perl with a new appreciation for the services it provides, a drive to experiment with features you never understood before (that have been hijacked from some of these languages and provide a toolkit that can be used to do "x-ish" solutions in perl), and a better understanding of your programs place in the system in general.

You will be a better programmer for it. No question. The main question you need to ask yourself is, do you want to be a better programmer? :)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://213350]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2023-05-31 00:05 GMT
Find Nodes?
    Voting Booth?

    No recent polls found