Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Learning Algorithms using Perl.

by vrk (Chaplain)
on May 09, 2017 at 10:03 UTC ( #1189871=note: print w/replies, xml ) Need Help??

in reply to Learning Algorithms using Perl.

Many replies already, but I would like to offer my own view... The OP is vague about the target depth in learning algorithms. If you're just starting out and have yet to develop algorithmic thinking abilities, Perl is a fantastic choice. As other monks have pointed out, a lot of the unnecessary distraction is hidden away and not relevant to programming in Perl (like memory management and types of variables). The fundamental data structures are part of the language, so you can immediately become used to the operations they support and how these fundamentals are applied in higher-level algorithms.

By "just" writing Perl programs, you'll get an intuitive understanding of lists, arrays, stacks, queues, hash tables, multidimensional data structures and operations on them without having to first study each one separately and in detail. Once you have that understanding, it's easier and faster to learn about the formal aspects of designing these data structures and algorithms on them.

If you're looking for the deepest algorithm expertise, Perl is still an interesting starting point, but it must be one among many other programming languages you know. For example, every time I read about or program in some other programming language, whether it's Pascal, Common Lisp, Haskell, C, C++, Go, Rust, Javascript, Python, R, XSLT, MMIX assembler or even GNU makefiles, I always learn something new that I can take and apply to programs I write in Perl.

There are some things that are hard to learn if you only know Perl. Memory management is one of them, as are references and the related ability to grasp indirection. You can simulate computer memory by allocating a large array and treating array indices as pointers to memory. But why would you do that in Perl? It serves no practical purpose. On the other hand, it's really hard to design efficient algorithms in Perl without understanding how it manages memory and what its benefits and drawbacks are, and it's hard to get an intuitive understanding of Perl's memory model without managing memory by hand.

So, you learn a lower level language without automatic memory management, like C. Even if you never become a full-time C programmer, that experience will influence how you design algorithms and how you write Perl programs. This influence goes both ways, because what you really learn after mastering the basics is different ways of thinking about computations. That knowledge and algorithmic thinking is transferable, and it doesn't matter in the end what programming language you use.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2023-02-08 06:13 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (40 votes). Check out past polls.