Perl 5.38.0 Released - An Appeal To New Blood? |
Written by Nikos Vaggalis | |||
Thursday, 06 July 2023 | |||
Perl, despite having fallen out of favor and tanking in terms of programming language popularity, still moves forward. It's business as usual with version 5. 38 just released. Maybe, just maybe, the new features introduced into the language in this newest version will attract much sought new talent. Perl is a language that while it doesn't attract new blood, is nevertheless resilient and embraced by a community of developers who really know the reasons that make it worth sticking to. Some of those reasons were nicely lined up in Why Perl?
I would add at position 6-The fun factor. Point number 5 is the one that gets the biggest revamping in this version, by the addition of the Class keyword. Yes, Perl while having always veen object-oriented for ever, officially gets classes: It is a core implementation of the class syntax similar to the one you would find in other programming languages. It isn't a ??bless wrapper, but a completely new system built right into the Perl interpreter. use v5. 38; class My::Example 1. 234 { ADJUST { method print_message { My::Example->new->print_message; Because Perl was so lax about its Object Orientation paradigm, various attempts have been made to bring it close to par with the rest of the traditional OOP programming languages. The most notable of these attempts are Moose and Moo but there are others too hence creating an environment of deep fragmentation, aka not beginner friendly. As such Corrina can be also considered as an attempt to unify the Perl OO paradigm simplifying things and making the onboarding of newcomers wishing to get started with the language much easier and straightforward. Moreover, now fields are visible in the scope of the class, with each class instance getting its own storage of them, independent of each other. That is private fields. To do the same the old Core way you had to implement your object as a closure. Hacky. Note that the Class keyword is part of the plan to bring effective OOP to the Perl core while still keeping Perl being Perl, in an effort collectively known as Corinna. The Corinna MVP then, is being implemented in 7 steps :
version 5. 38 instills the first one into the Core. However it remains an experimental feature, which is very much still under development and will be the subject of much further addition, refinement and alteration in future releases. So while Class would be the most important addition to this version, there were other more minor ones but pretty interesting nevertheless. Amongst them are : Support for Unicode 15 Defined-or and logical-or assignment default expressions in signatures Optimistic Eval in Patterns with the addition of (*{ . . . }) As a refresher, the (?{ . . . . }) construct essentially allows for embedding Perl code that gets executed upon every match of the pattern inside the regular expression. While ??{. . . } is like a regular code expression, except that the result of the code evaluation is treated as a regular expression and matched immediately. Because a lot of black magic was happening behind the scenes in order for those to work, certain optimizations where turned off. Not anymore if you choose so. Staying on the regex front, the next feature is a re-write to make its purpose cleaner. To reuse the last successful pattern match you would use the empty pattern. The following code: ?? if (m/foo/ || m/bar/) { can now be rewritten as follows if (m/foo/ || m/bar/) { making the intent clearer by deviating slightly from the "do what I mean" notion. It's little things like that that make a newcomer's onboarding easier. On the depracations front, we find: Use of ' as a package name separator is deprecated It had never occurred to me to use ' as the package separator, resembling something like "package Super'Bike;". Seems something like that was always allowed. Also, the battered "Switch and Smart Match" operator was finally deemed a failure and will be entirely removed from Perl in v5. 42. 0. With the version, some core modules got updated to their newest counterparts too. Non inclusive list :
For the full changelog check the latest perldelta.
More Information
Related ArticlesIt Was About Time To Find A Shared Vision Of The Perl Foundation Perl 5.36 Released - What's New?
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
|||
Last Updated ( Thursday, 06 July 2023 ) |