Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Returning to Perl after almost 3 decades

by NERDVANA (Priest)
on Aug 15, 2024 at 04:25 UTC ( [id://11161109]=note: print w/replies, xml ) Need Help??


in reply to Returning to Perl after almost 3 decades

I'd say the two biggest developments in the language are named parameters on subs, and native try/catch. Or, perhaps, those were the two most deficient absent features in early perl which perl now has. Perl gives you access to the new features various ways, but the best is use v5.40; which gives you a feature-bundle of everything considered stable and not-deprecated as of version 5.40. This includes strict and warnings, so less boilerplate at the top of your scripts.
use v5.40; # strict, warnings, many features use Moo; # lightweight object system use Log::Any '$log'; # my favorite logging system has field1 => ( is => 'rw', required => 1 ); sub method1($self, $z=undef) { try { $self->field1($z) if defined $z; $self->field2($z // 5); } catch ($e) { say $e; $log->error($e); } }

I don't mean to speak ill of the new in-core object system, but if you give it a try you can decide for yourself whether it meets your needs better than Moo.

Oh, and one of my favorites are indented here-docs:

sub foo { my $x= <<~END <-This is the start of the line END }
And for a brief overview of the CPAN landscape,
  • DBI is still the standard for interfacing with databases
  • DBIx::Class is still the best way to automate queries
  • Template::Toolkit is going strong, but Text::Xslate is I think the current fastest template system
  • There are four major IO loops for event-driven programming: POE (old, complicated), AnyEvent (best for minimalism, but has social baggage), IO::Async, and Mojo::IOLoop (part of Mojolicious, and my favorite). This fragmentation of the module landscape is unfortunate, but then, you can do almost everything you want with a normal blocking-style worker pool.
  • Mojolicious is the only web framework that fully supports asynchronous requests, especially for websockets. It comes with its own massive kitchen-sink collection of libraries, but they're all well-written and efficient/minimalist.
  • Plack / PSGI make a nice system for plugging together web-app middleware, but they don't support websockets very well.
  • Catalyst is still alive and well, but honestly it's more complicated than Dancer and Mojo
  • Of the object systems, you have Moo, Mouse, Moose, Zydeco, the new "Cor" being built into the language, and various others. Moo is still my favorite for pragmatism. Mouse is faster, Moose is more "meta", Zydeco looks better and removes boilerplate for common stuff, and Cor will soon be built-in, though it lacks features I consider important.
  • Data::Printer is an amazing dumper of perl structures for debugging.
  • Carp::Always shows you stack traces
  • Log::Any or Log::Contextual are my recommendations for logging. There are many others.
  • Type::Tiny is a great ecosystem for validating data. I recommend test coverage instead of enforcing types at runtime, but Type::Tiny certainly has its uses in input validation.
  • Test2 is a core module now! It's an excellent domain-specific language for writing tests.
  • Cpanel::JSON::XS is the current recommendation for working with JSON
  • DateTime is still the best date module, but Time::Piece is lighter weight. My favorite parser is DateTime::Format::Flexible.
  • Devel::NYTProf is an excellent profiler for detecting performance hotspots
  • Email::MIME and Email::Sender module collections are the standard for constructing and sending mail
  • Path::Tiny and Path::Class streamline filesystem access, and check out IO::All if you like to live dangerously
Of course, CPAN is almost infinite, but these are just the ones that I use on a regular basis, and some of their competitors that I know other people like.

Replies are listed 'Best First'.
Re^2: Returning to Perl after almost 3 decades
by DaWolf (Curate) on Aug 15, 2024 at 09:20 UTC
    Thank you so much for such a comprehensive answer!


    Er Galvão Abbott
    www.galvao.eti.br

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2025-06-20 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.