Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Perl Programming

Perl 5.38 Released with New Experimental Syntax for Defining Object Classes (phoronix.com) 48

Perl 5.38 was released this week "after being in development for more than one year," reports Phoronix. "Perl 5.38 brings a new experimental syntax for defining object classes where per-instance data is stored in 'field' variables that behave like lexicals."

"Maybe, just maybe, the new features introduced into the language in this newest version will attract much sought new talent," writes the site I Programmer, noting the argument that Perl is installed by default everywhere — and has the "fun factor... The class keyword is part of the plan to bring effective object-oriented programming to the Perl core while still keeping Perl being Perl."

The Perl docs warn that "This remains a new and experimental feature, and is very much still under development. It will be the subject of much further addition, refinement and alteration in future releases." But "Since Perl 5, support for objects revolved around the concept of blessing references with a package name," notes updated documentation, which points out this new class syntax "isn't a bless wrapper, but a completely new system built right into the perl interpreter." The class keyword declares a new package which is intended to be a class... classes automatically get a constructor named new... Just like with other references, when object reference count reaches zero it will automatically be destroyed.
Phoronx notes that Perl 5.38 also brings a new PERL_RAND_SEED environment variable "for controlling seed behavior for random number generation," along with some new APIs. And I Programmer adds that Perl 5.38 also adds support for Unicode 15.0, adding 4, 489 characters, for a total of 149,186 characters. Other additions include enhanced regular expressions, plus defined-or and logical-or assignment default expressions in signatures.
This discussion has been archived. No new comments can be posted.

Perl 5.38 Released with New Experimental Syntax for Defining Object Classes

Comments Filter:
  • by Ecuador ( 740021 ) on Saturday July 08, 2023 @11:01AM (#63668277) Homepage

    This is the first part of the modern OO Perl framework called Corinna [github.com]. While Perl supports OO via the "bless" method, people who wanted a complete system had to use the 3rd party Moose/Moo/Mouse frameworks.

    Corinna is designed to be better and faster and become part of Perl's core (and also out-class if you allow the pun other languages' OO systems). If you remember 3 years ago "Perl 7" was going to come out (which would auto-enable the latest features that come in Perl 5 but require you declare some pragmas to not break old code), but it was decided to keep the 5.xx going on for now. I think the general feeling is that once Corinna makes it into core, Perl 7 will be released.

    Now, while only the experimental Class syntax has made it into core on this release, you can actually use the new object system (and quite a few people do, even in production systems), as the prototype is available on CPAN as Object::Pad [metacpan.org]. There may be refinements by the time it makes it into core, but the syntax is mostly decided, so your Object::Pad code will be pretty much compatible.

    • OO was something they should have done 20 years ago. Now everyone is moving on to functional features.

      Although I must say that Perl has some of the best array operations by default of any language, probably better than the traditional functional approach.
      • by narcc ( 412956 )

        OO has mostly been an expensive mistake. Perl doesn't need it as is better off without it.

  • "Perl is installed by default everywhere" It is? 23 years ago when I did something for our webservice in Perl it certainly wasn't, and I never heard about it for windows. But just give it up, perl is so outdated and doesn't add anything to the already crowded world of development languages. Any sensible company would have redesigned its service/application away from perl 15-20 years ago. Just convert it to the, IMHO, abysmal python, javascript or C#, at least that way you know you can get more developers t
    • 23 years ago when I did something for our webservice in Perl it certainly wasn't

      If you were on Linux, it almost certainly was. What may not have been installed was mod_perl.

    • by micheas ( 231635 )

      "Perl is installed by default everywhere" It is? 23 years ago when I did something for our webservice in Perl it certainly wasn't, and I never heard about it for windows. But just give it up, perl is so outdated and doesn't add anything to the already crowded world of development languages. Any sensible company would have redesigned its service/application away from perl 15-20 years ago. Just convert it to the, IMHO, abysmal python, javascript or C#, at least that way you know you can get more developers to continue it.

      Wow! That's a seriously old quote.

      FreeBSD dropped perl from the default install with FreeBSD 5.0, which was 20 years ago.

      • by jonadab ( 583620 )
        Yeah, I used FreeBSD for a while, right around version 5 IIRC. (It was during the "Debian hasn't been updated since three major kernel versions ago" era.) As I recall, it doesn't install bash by default either. Worse, if you do install it, it installs it in the wrong location (under /usr/local), which breaks shebangs. Same with perl. Same with basically everything. Worst of all, basically nothing is pre-compiled, it's all just "ports" (a lot like Gentoo portage), so you end up recompiling half the wor
    • by jonadab ( 583620 )
      > and I never heard about [Perl being installed by default] for windows

      Nothing (well, nothing useful) is installed by default on Windows. That's literally Windows' whole schtick: you have to separately obtain and install every single piece of software you're going to use, and then each individual piece of software is going to have its own automatic-updates-installer running out of the system tray, and you're supposed to *like* it that way.
      • Clearly a windows hater because what you say is just completely wrong. Also what you say goes the same for Linux and MacOS.
        Why would I need Perl installed if I never gonna use it? it should not be installed by default. The less installed the better, it needs to be installed when needed.

        • by jonadab ( 583620 )
          > Also what you say goes the same for Linux and MacOS.

          You've clearly never used any of the major Linux distributions; because no, they're not like that. What is included in a default install varies from one distro to another, but it's generally a lot more extensive than on Windows. And *none* of them (unless you count LFS) require you to separately obtain and install every piece of software individually. At worst, you just search for what you want in the package manager and push a button. Sort of lik
  • Most of the messages here talk about features in Perl and/or/vs Python.

    Hash tables, multiple values, exception blocks (such as try/finally), keyword arguments, abstract file/directory interfaces, etc. Not to mention objects, lists, and garbage collection.

    Also naming (package/module identifiers and references).

    In other words, basic features from Lisp circa 1980.

    Of course, Lisp has lots of other features not mentioned above.

    There's anonymous functions (which many languages have picked up at least some notion

    • The only thing Lisp lacks is a syntax that doesn't make one's eyes bleed. For me and, I suspect, many, S-expressions are incredibly ugly, so IMHO that's one of the main reasons, if not the major one, few people use it. And so they go and reinvent it in a way, any way, that looks more reasonable, some such reinventions being explicit proposals for alternative ways to write Lisp.

    • by jonadab ( 583620 )
      Perl has had format since, umm, I think version 4? Before the blue camel, anyway.

      I'm not aware of a single documented case of anyone ever *using* the feature, but it's there.

      The feature I want from a lisp variant, is text buffers (and, relatedly, markers), from elisp.
  • by PPH ( 736903 )

    this new class syntax "isn't a bless wrapper ...

    Was something wrong with the Perl bless function?

    ... but a completely new system built right into the perl interpreter."

    IIRC, bless is a builtin. So, not really a valid reason (not that this stops people from changing things).

    • by jonadab ( 583620 )
      > Was something wrong with the Perl bless function?

      Mostly, it's _different_ from the way C++ and Java do things, and that annoys people who come from those linguistic backgrounds.

      Personally, the language whose object model and syntax I have always admired most is Inform 6. It's not (and not intended to be) a general-purpose language that you can use for most things; but its OO system is great.
  • ...its syntax was born experimental.

  • Why not just keep making Perl better at what it does, instead of trying to make a silk purse out of a sow's ear?

    • by UPi ( 137083 )

      Short answer: Yes.

      Longer answer: Yes, I want it because OO makes polymorphism easier, and that helps with a range of programming tasks.

      Yet longer answer: Perl gives you more than one way of doing things, it always has. Those who like perl tend to favor this approach, detractors point at it as a fault. You can use OO or not in your own code, the choice is yours. A fair number of CPAN modules give you both OO and non-OO interfaces.

      Oh, and perl is already excellent at what it does, on that there is cons

As the trials of life continue to take their toll, remember that there is always a future in Computer Maintenance. -- National Lampoon, "Deteriorata"

Working...