Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Learning Algorithms using Perl.

by Laurent_R (Canon)
on May 08, 2017 at 22:46 UTC ( [id://1189840]=note: print w/replies, xml ) Need Help??


in reply to Learning Algorithms using Perl.

I disagree so much with your colleague that I just wrote a book aimed at teaching programming using Perl (well, it's using Perl 6, not the more common Perl 5 version, but that's very secondary in this discussion). BTW, it went to the printer last Friday and will be out very soon now (See New Perl 6 book coming out with O'Reilly for details). But the bottom line is that I believe that you can learn programming with Perl.

True, using a high level language such as Perl has the advantage that the language implements for you things that you would need to implement yourself if you were using a lower language such as, say, C or Assembly (or MIX). So, you don't really need to learn how these things are implemented, well, most of the time. But that doesn't mean that you can't learn them if you wish. And sometimes, you actually have to learn them.

One example: hashes are a very efficient data structure in Perl, so that you most of the time don't have to implement your own search algorithm. And so what? Who cares, if you can do your job without having to roll out your own implementation of an efficient search algorithm? Having said that, I should point out that sometimes you need to implement your own version of a given basic algorithm. I came across such a case a few months ago on a forum, where the poster (a very good Perl programmer) had to deal with ranges for a genetic problem. Using hashes for that turned out to be impossible. And given the size of the input, the program was taking several days to run. I suggested a binary search algorithm which turned out to return the results within about one hour.

I certainly think that developers need to know basic algorithms. But that does not mean that you need to implement them each time they are needed. If your language or a library implements it for you, use it!

In my book, I explain the binary search algorithm and request the reader to implement it as an exercise. Because it is important to understand it. Even if the language offers ways to implement more effective search solutions in 99% of the case.

Just another example. Perl has a built-in sort function. So you may use the Perl sort function and never care about how it works. Then you'll never learn about sort algorithms. But Perl does not prevent you from learning them. My book shows pure Perl implementations of three different sort algorithms. The fact that the language can do it for you does not prevent you from learning these algorithms if you wish.

Finally, I agree that Mastering Algorithms with Perl is a great book. Get it, by all means. Another interesting one is Computer Science & Perl Programming.

Update: fixed a typo.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 04:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found