[HN Gopher] Why Perl?
___________________________________________________________________
Why Perl?
Author : susam
Score : 56 points
Date : 2023-04-20 21:28 UTC (1 hours ago)
(HTM) web link (two-wrongs.com)
(TXT) w3m dump (two-wrongs.com)
| Scubabear68 wrote:
| Years ago I coined the phrase "Perlaphobia", the fear that Perl
| will come back into my life again and again, and every time it
| happens I have to relearn it all over again almost from scratch.
|
| Still happens about every five years, although I am reaching for
| Python more and more in those situations.
|
| What always kills me is the weirdness of the basic data
| structures, array/stack function calls, and the truly
| impressively weird ways Objects are done.
| forgetfulness wrote:
| I worked briefly at a shop that maintained a complex outsourced
| project by Yahoo (some ad bidding optimizations pipeline).
|
| As it turns out, they used Perl, one of the few sanctioned
| languages at Yahoo.
|
| The coding style handed over from the client forbade every
| other thing that Perl fans tell you that make the language warm
| and endearing to them; you were allowed to use about a few of
| the sigil variables, all the data structures were to be used in
| their "object reference" form, because it sidestepped the
| "contexts" functionality of Perl, which was to be avoided at
| all costs.
|
| I remember the tedium of having to maintain your own
| stacktrace, because all you got was a the `$@`, `$!` and `$?`
| variables, which contained precisely the last of various types
| of error encountered during execution within the process. If
| you encountered errors while performing error handling, the
| original error would be lost, so you had to keep a backup.
|
| Edit: man, the contexts, the fans sweared by them, making
| analogies to natural language; I'm sorry to sound elitist, but
| they often came across as enthusiastic amateurs rather than
| people with a formal background in Computer Science. They
| claimed that things like passing an array to a place where an
| integer is expected to get the length was _richness_ , not
| insanity.
| xupybd wrote:
| I'm also shock that in Perl you can alter your return type
| based on the type of variable the caller is putting your
| result in.
|
| https://perlmaven.com/wantarray
|
| That always appeared as madness to me. Why would you make
| things that cryptic to understand?
| jsrcout wrote:
| As a Perl developer, I never once used that feature. It
| does make some sense in the context of how Perl's own
| operators work, making them "do the right thing" for
| different cases. But for user code... not needed.
| recycledman wrote:
| This article just seems biased, the author likes Perl therefore
| he/she will pull the strings to his/her side. For me it's just as
| simple as that.
| dale_glass wrote:
| Sadly Perl has fallen on hard times. I think the Perl 6 debacle
| is mostly at fault.
|
| As it stands, unfortunately CPAN is full of rotting modules.
| While it may be a maintained and usable language still, that puts
| a huge damper on any non-trivial development, because at any time
| something important might turn out to be broken or unmaintained,
| or without an API at all.
| worik wrote:
| > Sadly Perl has fallen on hard times. I think the Perl 6
| debacle is mostly at fault.
|
| I agree hard times. Hubris is at fault.
|
| Perl did too much and reached for the stars. Its happy place
| was a sane job control language. A niche Python is filling.
|
| I have used both, Perl extensively, Python when I must. Perl is
| much better, but being better is not enough.
|
| Perl did "everything". Python was "object orientated". People
| wanted the shiny "object orientated" and, sadly wisely, did not
| want a language that could do anything and everything.
|
| I blame Larry Wall, the genius, both for Perl's success, and
| Perl's failure. If only I could fail so brilliantly!
| PaulDavisThe1st wrote:
| > Its happy place was a sane job control language
|
| maybe that was _your_ happy place for Perl, but it certainly
| wasn 't mine or that of lot of Perl users I've known over the
| years. #!/bin/perlish while (<>) {
| /* regex match */ /* do some stuff, with variables or
| the file system or whatever */ }
|
| Awk theoretically is a close match for this basic structure,
| but Perl is closer, most of the time.
| worik wrote:
| Yes.
|
| I mispoke. "A happy place" I shold have said
|
| I never learnt awk or sed bedcause I knew Perl.
|
| That loop, often in a command line invocation `perl -e
| 'while(<>){chomp;......}'`
|
| My point is its happy place was not application
| programming, gui systems. AS I commented elsewhere here
| processing every Apache hook.
|
| Pythin suffers the same problem. It too is brilliant at the
| little jobs, yet there are many GUI junk piles written in
| it, just as happened with Perl back in the day
| antisthenes wrote:
| > Perl did too much and reached for the stars. Its happy
| place was a sane job control language. A niche Python is
| filling.
|
| > I have used both, Perl extensively, Python when I must.
| Perl is much better, but being better is not enough.
|
| > Perl did "everything". Python was "object orientated".
| People wanted the shiny "object orientated" and, sadly
| wisely, did not want a language that could do anything and
| everything.
|
| I don't know what kind of Python you've tried using, but it
| seems you got some defective ancient 2.x version. Python is
| exactly the kind of language that should be replacing Perl,
| simply because it's the best glue language out there right
| now, with modules that are actively being maintained and
| developed.
|
| And, as a cherry on top, actually has human-readable syntax.
| worik wrote:
| > Python is exactly the kind of language that should be
| replacing Perl, simply because it's the best glue language
|
| When tabs and spaces have different syntactic meaning, I am
| suffering quite a bit of revulsion.
|
| I have to do it, but I want to control my own white space
| for my own purposes.
|
| It comes down to taste, I guess. I am not wrong, but
| neither am I correct
| dale_glass wrote:
| > I agree hard times. Hubris is at fault.
|
| I don't think it was so much hubris as bad communication.
|
| Perl 6 was understood to be that: Perl 6, a definite
| successor to Perl 5. But besides being very, very late it
| turned out not to truly be Perl 6, but a new, incompatible,
| Perl-ish language.
|
| I think the decision to rename it to Raku was a good one, but
| came too late. By then the world had already moved on.
|
| Done early enough I think it'd have fixed things. It'd have
| created the clarity needed to understand that Perl 5 wasn't
| going away, and that it was pointless to wait for a
| successor.
| kstrauser wrote:
| Python ruined Perl for me. As soon as I convinced my self
| that pass-by-object-reference really was _that simple_ , and
| I didn't have to deal with pass-by-sigil-maybe, I never
| looked back.
|
| Write a Python function that writes an object's string
| representation to a file: def write(obj):
| open('/tmp/foo', 'w').write(str(obj))
|
| Call it on an integer: write(123)
|
| and it works. OK. But what if I want to call it on a list of
| strings? write(["spam", "eggs"])
|
| That was too easy. I know - let's see if we can write a dict
| of tuples to sets of ints!
| write({(1,2):{3,4,5},('spam','eggs'):{6,7,8}})
|
| That freaking worked? And I didn't have to change the
| function to accept a hashref? You just pass an object... and
| it passes the object?
|
| At first, I thought I had to be missing something, like maybe
| it was impossible to do trickier things because they made the
| simple things so easy, but no. It just turned out that some
| of Perl's design decisions increased my cognitive load way
| more than strictly necessary. That's clearly not true for
| everyone, but it sure was for me. The first day I wrote
| Python was the last day I wrote Perl.
| psychphysic wrote:
| What is it about these very short articles that HN loves?
|
| (Short, subjective but presented objectively).
|
| Or is it just loved by those who agree with the premise in this
| case Perl die hard?
| worik wrote:
| I like short stories on HN.
|
| The most interesting part are the HN comments, and without
| reading the story first, it is rude and less interesting
| commenting.
|
| So short stories are a plus for me!
| burnished wrote:
| The article is clearly presented as a matter of personal
| opinion with the framing as the answer to the question 'why
| does the author use Perl so much'.
|
| I liked it because it is interesting to read other people's
| examined opinions on topics that I am ignorant of.
| nnadams wrote:
| I like short articles in general, but this one is short and
| shallow, plus subjective without explanation as you mentioned.
|
| I spent too much time trying to guess at the author's reasons.
| Why are Python and JavaScript not extensible but R is?
| owl57 wrote:
| > published 2023-05-26
|
| Hmm...
| yakovsi wrote:
| I think it's because he is using Perl.
| HeckFeck wrote:
| Yep, Time::Piece can access the future. We weren't supposed
| to know now but obviously something's slipped back...
| brk wrote:
| I'm sure the author will still feel the same way in a month.
| munchler wrote:
| > It is installed by default everywhere.
|
| For some values of "everywhere". Pretty sure this is not true on
| Windows, for example.
| OJFord wrote:
| For extremely limited values of 'everywhere' which shake its
| definition.
|
| I don't think a basic Arch Linux installation includes perl.
| Windows as you say would surprise me. 'the major Linux
| distributions' (plus I think macOS, perhaps inherited from BSD,
| no idea) might be fair, but certainly not 'everywhere'.
| sdfghswe wrote:
| published 2023-05-26
|
| cool story bro
| xyzzy4747 wrote:
| IMO it's better to just use TypeScript anywhere that you'd
| normally use Perl. The type safety helps later on when you
| revisit old code plus I think it's more productive overall,
| having used Perl many times in the past.
| worik wrote:
| The Javascript ecosystem (to which Typescript belongs) makes
| the Perl ecosystem of twenty years ago look modern and
| streamlined.
| yamtaddle wrote:
| Nooooo. Python's the clearest front-runner in the Perl
| replacement game. I wish it were Ruby, but it's pretty clearly
| Python. TS changes too fast and requires too many tools, it's
| not even a serious contender in this category, though I much
| prefer it to any of the above for large programs.
|
| Python has some semi-decent type hinting, these days. It's not
| so bad, it'll keep you out of _most_ of the same trouble that
| TypeScript does.
| koito17 wrote:
| While I see benefits of TypeScript's type system, I think the
| lack of a special compilation step is a big win for Perl, at
| least in the author's eyes. (Yes, I know Deno is a thing, but
| I'm not sure of the extent which the author considered it).
| xyzzy4747 wrote:
| You can run ts-node to execute TypeScript to run it without
| having to manually compile it first. Although if you have a
| large TypeScript program with a lot of dependencies or on an
| older machine, I guess it could take some time. With my own
| scripts I've only seen it take a few seconds at most.
| dgunay wrote:
| I can't seem to convince myself to use Perl anymore for serious
| applications, but I do still whip it out occasionally for
| essentially the "shell scripts with sane control flow" use case.
|
| IMO it is still mostly unmatched in that area. Most other
| languages, while just as capable, require far more line noise to
| interact with streams and use regexes. I admit though I have
| studiously avoided learning awk and sed over the years.
| juanse wrote:
| I do exactly that but with ruby
| doubled112 wrote:
| I don't think I have ruby on any system I administer, but
| perl is almost always there.
| ElectricalUnion wrote:
| dpkg requires perl, so perl is around .deb systems even if
| perl itself is not directly used.
| jrochkind1 wrote:
| Ruby works great for this, but is unfortuantely not installed
| on many systems -- but this isn't just bad luck, I think it's
| a consequence of the fact that ruby code written two years
| ago has a pretty good chance of _not_ running on the recent
| version; and code written for the recent version without
| thinking about backwards compat also has a good chance of
| _not_ running on ruby of two years ago...
|
| Means as a language it's not suitable for "have it installed
| on every system and then just throw code at it that will
| work, and keep working" like Perl. Even if you could convince
| all the distro maintainers to include it, you'd never have
| the version you want/need. Which would be different for
| different scripts, and you'd have to be constantly updating
| all your routine maintenance scripts you just wanted to put
| there and have them keep working -- which with Perl you
| could.
|
| I wish ruby were more about backwards and forwards compat,
| but it isn't.
| jsrcout wrote:
| Years ago Larry Wall presented a graph of programming languages
| with the axes labeled "whipupitude" and "manipulexity". Perl
| excels at both. It's still my go-to for tasks requiring a lot of
| text manipulation, or with just a bit too much complexity to be a
| shell script. Perl code does look odd at first, but it gets an
| unfair rap on that point - there are plenty of popular languages
| that are hard to mentally parse without some background.
| worik wrote:
| There is a very interesting talk [By Rasmus Lerdorf
| ](https://youtu.be/wCZ5TJCBWMg) on the occasion of the 25th
| anniversary of PHP.
|
| He addresses the issue of why PHP not Perl became the "winner" on
| the web. (About ten minutes into the talk)
|
| In his opinion it was due to the Apache modules that build PHP,
| alternatively a Perl, interpreter into the Apache server
|
| PHP's implementation implemented just enough to make it work
| (document generation hook), while Perl implemented all bells and
| whistles, including path translation. This made all the Apache
| hooks available to the Perl programmer.
|
| On shared servers using a single Apache server and virtual host
| with several websites running on one Apache server this meant a
| Perl programmer could hijack the whole server
|
| Hubris
| robbywashere_ wrote:
| For a bit of fun, I'd recommend starting off with an ugly bash
| script when you just want to hackily and happily get something
| done, then asking chatgpt to convert it to another language(go?
| perl? ruby?) It is interesting to see the trade-offs.
| ParetoOptimal wrote:
| Seems fun, let's try it.
|
| > ChatGPT> Rewrite the following as concisely as possible in
| perl, perl 6, J, Haskell, with no explanation and only code:
| history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' |
| sort -rn | head
|
| Perl: `history | perl -ne '/^\s*\d+\s+(\w+)/
| && $a{$1}++; END { for $i (sort {$a cmp $b} keys %a) { print
| $a{$i}." ".$i."\n"; } }' | sort -rn | head`
|
| Perl 6: `history | perl6 -ne
| '/^\s*\d+\s+(\w+)/ && $a{$1}++; END { for $i (sort keys %a) {
| say $a{$i}." ".$i; } }' | sort -rn | head`
|
| J: `head sort |. |:+/ ,.~ [: ~. stdin -:
| i.0"1 <@:". ]
|
| Haskell: `reverse . take 10 . sort . map (\x
| -> (length x, head x)) . group . sort . map (words) $ lines <$>
| readFile ".history"`
|
| from https://www.commandlinefu.com/commands/view/604/list-of-
| comm...
| winrid wrote:
| What companies are still using Perl on the backend?
|
| I know FastMail does. IMDB was in Perl before Amazon acquisition,
| and was told was rewritten in java over several years. Any other
| interesting mentions?
| ojhughes wrote:
| Booking.com is known for using perl
| forgetfulness wrote:
| Yahoo used it a lot, but I'm not sure if they still do.
| aeruder wrote:
| Large parts of the ziprecruiter website are still powered by
| perl.
| equivocates wrote:
| PACER -- the system that runs electronic dockets and service
| for all federal courts runs on perl.
| HeckFeck wrote:
| www.spareroom.co.uk
|
| Slashdot
|
| The Register
|
| BBC iPlayer, at least originally
|
| Also I'm sure someone recently wrote a text-based MMO in Perl
| but I forget the name of it
| tribby wrote:
| craigslist is the first one that comes to mind
| lukasb wrote:
| perfect
| thesh4d0w wrote:
| perlfect
| xyzzy4747 wrote:
| Athena Health's entire backend is/was in Perl as of the mid
| 2010s (note: I didn't work there, only interviewed once).
| ParetoOptimal wrote:
| duckduckgo?
| LinuxBender wrote:
| I am not permitted to name them but there is a large company
| that is heavily involved in the movie industry that uses
| perl+Oracle quite heavily in ways I never imagined to give
| Hollywood execs a lot of real time data.
| quags wrote:
| CPAnel is popular with shared hosting and is predominantly
| Perl. Companies like godaddy and eig as well as thousands of
| shares host still use this. Certainly a shrinking market but it
| has a number of years in it. Apache spamassassin is written in
| Perl. Other than those I rarely ever see a Perl project and if
| I do it was originally written in 2000.
| [deleted]
| jeron wrote:
| I ask my company this question and the answer is mostly "it's
| what we used 20 years ago"
| worik wrote:
| That is a good answer.
| drelihan wrote:
| Comparing Python to Perl ( assuming equal experience with both ):
|
| If you are a good programmer, you will write good Perl and Python
| code. If you are a bad programmer, you will likely write terribly
| horrendous Perl code and slightly less horrible Python code.
| HeckFeck wrote:
| Currently I am doing the coding for a prospective startup in
| Perl. Mojolicious plus DBIx::Class are quite powerful, though I
| wish the latter was better documented. A 'how to do join tables
| without incurring hairloss' tutorial is a must for every ORM.
|
| Mojo covers a lot of what you'd expect from modern web
| application development, and it does so with finesse. I hope it
| gets more attention. It seems many unfairly still associate Perl
| web development with a hodgepodge of bad CGI scripts.
| biomcgary wrote:
| My two favorite languages: Perl and Go. Both have very simple one
| file deployment, but my favorite use of Perl requires no file
| deployment, just one-liners on the command line.
| throitallaway wrote:
| How's that true with Perl since the interpreter is still
| needed? In that case the same could be said about Ruby, Python,
| et al.
| biomcgary wrote:
| If you work on Linux or MacOS, you can generally count on the
| interpreter being present. Even minimal installs of Linux
| tend to include Perl. Python might be as ubiquitous, but Ruby
| certainly isn't.
| xupybd wrote:
| While I don't agree with the author's opinion on Perl I'm in awe
| of their design. I love the look of their personal site.
|
| Perl is only ubiquitous in the Linux/Unix world. Try running it
| on Windows. You have to install some half working package.
|
| I have a strong dislike for Perl as I worked with it for many
| years. Much of that is that I knew nicer tools existed and I
| wanted to use them but some was they syntax. I hate the terse
| syntax and the gotchas.
|
| Issues like this
| https://stackoverflow.com/questions/7515029/cant-turn-off-bu....
|
| If you are new to Perl what is $|=1; going to mean to you?
|
| Then there is the fun of "Wide strings"
| https://stackoverflow.com/questions/9299941/perl-unicode-wid...
|
| You of course have to know the operators in Perl. There is a good
| reference https://perldoc.perl.org/perlop but I remember before I
| found that page in the docs I was lost.
|
| Then there is the use of references. Do I need a \% here or just
| a % no wait I need a \$. It's not that hard but it's a friction I
| got sick of.
|
| Yes all languages have their warts but I did not like Perl's even
| after almost a decade of working with it.
| jefftk wrote:
| I'm confused about the compatibility X for Python. A few years
| ago, sure, but for an article published a month from now? You
| write python3 and it's installed everywhere.
| t-3 wrote:
| Python isn't actually everywhere by default, but neither is
| perl (but perl at least is usually named perl, while python may
| commonly be python or python3). Neither is consistently in the
| same location and shebang issues are pretty common. If script
| portability is actually a concern, /bin/sh is still the best
| way to go.
| pavon wrote:
| Perl is mostly forwards and backwards compatible (or less
| generously it has frozen). Python is backwards compatible, but
| continues to add new features, and some packages are rather
| enthusiastic about adopting these features quickly, and ending
| support for older versions of Python. It isn't as bad as other
| language communities (I'm looking at you Rust), and I would
| have at least given it an asterisk, but it certainly isn't as
| stable as Perl.
| superkuh wrote:
| Python's dependency hell due to changes between versions in
| both modules and core is so bad there's even a python
| dependency manager hell of chosing which env wrapper or
| containerization you're going to use because the system python
| sure as hell won't work. And if you do have the gall to update
| a system python package system stuff will break. Whereas with
| perl the system libraries will work, no need for containers.
|
| Python's popularity hurts it for use when you want
| compatibility. Containerizations can only mitigate this so
| much.
| culopatin wrote:
| Is it available in windows by default?
| recycledman wrote:
| I'm sorry but my windows doesn't have Perl by default either
| perhaps I misunderstood your comment :)
| gkbrk wrote:
| You probably have it if you have Git Bash installed. Perl
| is a dependency of Git IIRC.
| recycledman wrote:
| Then it's not by default right? I must have git installed
| !
| [deleted]
| roblabla wrote:
| No, but then neither is perl. On windows you've got
| powershell, batch, VBScript and JScript pre-installed.
| midasuni wrote:
| Is Perl?
| koito17 wrote:
| No, but Perl at the very least is available on the latest
| versions of Mac OS. Python is not. So as far as "being
| bundled with the latest OSes" goes, Perl beats Python.
|
| NOTE: I am (probably mistakenly) assuming that Perl is
| still bundled in most Linux distros by default.
| OJFord wrote:
| Python is available by default in macOS. Not latest
| version python, but available. (Both 2 & 3 I think, or
| maybe they've dropped 2 now.)
| koito17 wrote:
| A minor update of macOS Monterey[1] removed
| /usr/bin/python, but /usr/bin/perl still exists. Xcode's
| Command Line Tools will install Python 3, but I do not
| count as being bundled by default with macOS.
| Unfortunately, I can't find any Apple documentation to
| prove this. You'll just have to check with a fresh
| install of macOS Ventura yourself (or, at your own risk,
| uninstall Xcode and/or the Command Line Tools)
|
| [1] https://developer.apple.com/documentation/macos-
| release-note...
| OJFord wrote:
| Is perl? That's an honest question/honestly surprises me.
|
| But honestly installing anything like that (without WSL
| probably - haven't used it recently) on Windows is painful,
| it's not python's fault, it's just a different paradigm. Run
| with a different environment variable for example.
| worik wrote:
| Last install of Windows 11 I did (triggering) Perl was
| installed by default
| xupybd wrote:
| It is not installed by default on any of the systems I
| work with. We have around 10 office staff that all use
| windows, and 2 windows servers. No Perl by default on any
| of them.
|
| To the best of my knowledge you must install one of two
| main distributions of Perl for Windows.
| https://www.perl.com/article/downloading-and-installing-
| perl...
|
| You can also use WSL.
|
| Edit: It sounds like, from other comments, that Perl
| comes with Git Bash as well.
| ElectricalUnion wrote:
| Are you sure it is "installed by default" or it happens
| to be inside WSL? Because WSL is not the default.
| prosaic-hacker wrote:
| I believe not now but Perl 5.004 was installed on Window NT
| (3.5 or 4) by default. That made the case for its use on
| project that could not afford the IBM AIX or Silicon Graphics
| systems we were using at the time.
|
| We used Netscape Fasttrack as the server.
| prosaic-hacker wrote:
| Perl does not die easily because of the way many of us learned
| it. We started to used it for sysadmin automation (prehistoric
| DevOps) and then the early Web showed up and we used it for that
| too.
|
| After 15 years (much more the 10,000 hours of use) it was hard to
| forget. And that over 15 years ago. Once you have it in your
| brain it does not go away easily.
|
| I teach Python but I still think in Perl.
| jefftk wrote:
| I wonder why this is dated a month from now?
| ashton314 wrote:
| Damian Conway once wrote a module called Timeline::Curves, if I
| remember right, that took the program back in time. I'm sure
| this explains it.
| ape4 wrote:
| perl script off-by-one mistake, presumably.
___________________________________________________________________
(page generated 2023-04-20 23:03 UTC)