by oalders on 12/19/24, 12:49 AM with 131 comments
by kamaal on 12/19/24, 4:12 AM
Perhaps at the core of this just how many what we called regular programming tasks are just knowing how to work with text and unixy operating system. Perl is just unbelievably awesome at this. Another big edge of Perl is commitment to backwards compatibility, most people who learned Perl early in their careers decades back can use it on-demand basis. Its universally installed, fast and scripts written from the earliest days continue to run with 0 changes, despite endless OS upgrades.
Early enough in the timeline Perl was full unix hackers, and you learned a lot from them, this culture further bolsters Perl's productivity credentials. Not a week passes, that I have to whip up a Perl script to do something for someone has a 2 people and a month budget to do. And they are often amazed it can be done this quickly.
CPAN is another big edge Perl has. No other language apart from JS/npm ecosystem has anything close, and these are basically competing in very different domains so to that end CPAN really doesn't have a competition till date.
If you are looking to build using Perl do checkout the Camel book and HOP by mjd.
by temporallobe on 12/19/24, 5:18 AM
by oniony on 12/19/24, 12:30 PM
But then I had to change the code behind a different database table and the function that backed it did not exist in the codebase. I found the code that called the function, but the function definition itself was nowhere. I was literally stumped and spent hours thinking our versioning system (Source Safe) had failed, or that I had been given the wrong codebase or that there was some library being called into, to no avail. (We were using TextPad back then, no IDE.)
And then I found it: AUTOLOAD. If you're not familiar, if you call a function that does not exist in Perl, then Perl will call a sub-routine called AUTOLOAD if you define one. In there you can do whatever you want and the developer who had written this particular system was parsing the function name to identify the database table and fields. So something like `set_customer_name` would set the `name` column of the `customer` table. It was both genius and horrifying.
by dmd on 12/19/24, 1:49 PM
by pjmlp on 12/19/24, 1:12 PM
This was more approachable in Perl, than Tcl or later Python, as Perl does expose most of UNIX API on its standard library in a more C like fashion.
My Perl 5 camel book got a fair use back in the day.
by petesergeant on 12/19/24, 12:53 PM
These days I write TypeScript full-time, which I like, and there’s a lot I miss about Perl, while absolutely loving the types in TS. The few months I spent writing Python professionally didn’t convince me it was any simpler or better than Perl, and I quit that job to go back to writing in TS.
by mikeInAlaska on 12/19/24, 6:32 PM
I do not write it to win an obfuscation contest. I like it to be read as easily as possible. It is a joy to watch the core objects of the system work together so cleanly.
by wodenokoto on 12/19/24, 5:00 AM
The general advice here seems to be “learn Perl while young”
by classichasclass on 12/19/24, 4:18 AM
by dpb001 on 12/19/24, 2:34 PM
by jwilk on 12/19/24, 11:30 AM
by bm98 on 12/19/24, 4:02 PM
The Camel book was so well-written. It was my introduction to Perl, which became my "superpower" in the 90's and far longer into the 2000's than I tend to admit. I eventually switched to Python because it's the closest thing that is considered an acceptable "modern" choice. I really enjoy Python too, but the obligatory XKCD about Python[1] rang true for me about Perl first.
For me the #1 superpower strength of both languages is the first-class treatment and syntactic sugar for associative arrays (a.k.a. hashes, dictionaries).
Perl did the same for regexes and file I/O; Python did not.
I have come to appreciate Perl's backwards compatibility -- that old scripts still run unchanged -- though maybe that's largely because Perl 5 has been in maintenance mode for so long.
by wruza on 12/19/24, 7:28 AM
I can name: dynamic scoping, implicit filehandles, implicit $_, strange contexts, keyword-like list functions. That’s basically it, and while it sounds fun, it doesn’t do much in a sense of code reduction.
$. $? $$ etc, well you can split lines with .split('\n'), get status as a part of result, call os.getpid().
<>, you can open() or createReadStream().
$_ is just a kids toy. “print if /…/“. Cool.
Lots of global modes under dynamic scoping is questionable. Value semantics and corresponding sigils are horrible, really. Bless is ugh. Subs are meh.
It’s all just regex. Add regex as a language construct and you get the power of perl in it. /…/.test(s), s.match(/…/), s.replace(/…/, '$&') that’s 90% of Perl. Regex saves most lines of code, everything else is just esoteric extra that doesn’t do much. Also no GC.
by artemave on 12/20/24, 5:10 PM
by cafard on 12/19/24, 4:27 PM
by replwoacause on 12/19/24, 2:17 PM
by romanobro56 on 12/19/24, 5:03 AM
by marcrosoft on 12/19/24, 3:35 PM