7 features that I would like to have in Perl 5

2016-11-23 10:28:19 mihai.szilagyi Guest blog posts 2 Comments

As a senior developer I work with Perl 5 every day. It’s my livelihood and my passion, but even though I love Perl, sometimes it makes my days dreary and dreadful. It’s a great language, it’s my language, but it’s not perfect. It doesn’t even have to be, I don’t believe there is something as a perfect programming language. They all have have their drawbacks, and Perl 5 is no different. That being said, there are a few features that I would love to have in Perl 5 because modern architecture requires these features to be able to program efficiently in the current environment.

Error solving - a major part of software development is bug fixing and to be able to handle this practically you need lots of warnings or a Perl debugger. I know it might not be possible, I know some of you might not want to hear this, but wouldn’t be great to have break points just like Java does? Perl has been the source of inspiration for many other language, but that doesn’t mean that we can’t look at others and borrow a few things.

Backward compatibility - if I download a module from CPAN right now I can’t be sure that it will work with my version of Perl. If I write a module and uploaded it to CPAN I can’t be sure that other programmers that use a different version of Perl 5 will be able to use. It would be awesome to have universal compatibility between different versions Perl 5.

Parallel sorting - Yes, I know, I’m looking at Java (8) again, but if it’s useful why shouldn’t I? The algorithm recursively breaks the array into pieces. Then it sorts them and then it recombines them concurrently and transparently.  This is very useful when sorting large arrays. It would be great to have as a built in feature.

OOP is good - It’s as simple as that. It might be just my humble opinion, but Object Oriented Programming works better than simple procedural programming. Try to debug and fix a 15 year old non object oriented legacy code and then me tell how did it all work out. Although we do have some OOP coding in Perl, it’s not a default feature. Moose is great but this feature should be in the core of Perl 5 (I know we do have it in Perl 6 now).

Real OOP features - carrying on the same idea, I want to have real objects, real and complete interfaces, real abstract classes and private attributes and methods. The surrogate works, but we shouldn’t just settle with works, we should be great in Perl 5 as well. Perl 6 might have this, but right now it’s not fully production ready.

Switch clause -  before settling in Perl 5, I worked in several other programming languages and most of them had a switch clause. We could use a performant switch clause without extra modules (Switch).

Asynchronous methods - this would be a time saver, running two or more methods at the same time, instead of waiting for each one in particular. Then collect the results correctly.

While doing some research for this article I managed to have a deeper look at Perl 6 among others. I know the last few features I mentioned exist in Perl 6, but right now that language is not fully production ready. Perl 5 is still the major player in the Perl family and it should have the same advantages that other modern programming languages have. These are just a few features that would help me in my daily development, if you do have some other suggestion please leave them in the comment section. Also I want to mention that Perl 6 looks really attractive to me right now and I hope it will get fully production ready as soon as possible. In the meantime, we still have Perl 5.

Leave a comment


    Perl 6 is production ready with a growing number of modules https:modulesperl6org and it is getting faster every month Tux has made a specific benchmark around his Perl 6 version of Text::CSV and it is a robust increase in speed see how many seconds it takes since he started in 2014 with the benchmark: http:tuxnlTalksCSV6speedlog Error solving in Perl 6 is much more precise and helpful than it is in Perl 5 The Perl 6 debugger perl6debug offers things like breakpoints and much more youd expect from a debugger Backward compatibility is always a problem most often gives a runtime error If a module that you make for the newest version of Perl 6 Rakudo Star 201611 for this moment uses a feature that was not available in an older release say 201601 and you run your module with that older release youd probably get a runtime error Work on the type of parallel sorting that you describe is being done in Perl 6 but not as ready as you would like it On the other hand many aspects of parallel concurrent and asynchronous programming in Perl 6 are quite transparent and easy to use Your two OOP items work fine in Perl 6 where everything is an object including the operators and if you for example are a math expert and need your own operators you just make them and work with them All you describe is available in Perl 6 and since the release in december 2015 very much production ready A switch clause is available in Perl 6 it is called given when I know they offer much more than just a switch clause Thanks to the module Inline::Perl5 you can use almost any code and modules from Perl 5 in Perl 6 so that bit of backward compatibilty should not stop you to try Perl 6 and have some Ofun

    Interesting list there Error solving the perl debugger already has breakpoints watchpoints and most of the usual features can you be more specific about whats missing here The UI options arent great but things like Devel::hdb are sometimes usable Backward compatibility generally Perl is good at this but universal compatibility between different versions Perl 5 that would seem to preclude ever adding new features Parallel sorting oddly specific Id suggest making that parallel operations in general Sorting rarely shows up as a performance bottleneck in my code but that doesnt mean much everyones codebase is different OOP is good does having Moose in the core really gain much And do you mean full autoboxing Rubystyle where you can call methods on everything Sometimes OO isnt always an ideal fit I wouldnt want to be writing List::Utilnewlistmax for example Real OOP features surrogate being Moo Moose Im guessing Anything specific youd change or add Switch clause thatd be Switch::Plain Asynchronous methods see Future and Future::Utils theres a series of posts about them starting in http:leonerdscodeblogspotcouk201312futuresadventday1html

Subscribe to our newsletter!

Make sure you never miss the interesting stories of Perl startups, apps and projects.