Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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? :)


In reply to Re: Why learn another language? by PhiRatE
in thread Why learn another language? by AcidHawk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-19 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found