8 ms·
The four noisy horsemen of Perl hate
- socialist_coder 5y agoI like the author's list. Very solid and some of the same arguments I try to use when people tell me they don't want to ever mess with Perl because it's unreadable. I still haven't found another language as easy and fast to do text manipulation, parsing, calling out to the shell, regex, whatever. For scripting, Perl is awesome. Recently I've been using Python instead, simply because I feel like I'm the last person in tech who likes Perl. This stuff is all doable in Python but I still miss my good ol' Perl. My 2 biggest complaints with Python vs Perl are 1) regex's - the perl syntax is so much faster and easier, and 2) running other command line programs from the shell and reading their output. Perl makes both of those things absurdly quick and easy to do.
- petepete 5y agoI wrote Perl (badly) for a few years before moving to Ruby in the mid 2000s. You can really see Perl's influence in Ruby when it comes to text manipulation, everything you need is likely in the standard library. If you're not yet fully sold on Python, Ruby might be worth a try. It's like Perl's elegant, sensible cousin.
- socialist_coder 5y agoRuby... thanks for the suggestion. I'll give it a try next time!
- forgotmypw17 5y agoYou're not the last, and I feel the same way. Perl is popular enough that there is enough documentation out there, stable enough that all that documentation is good, even if it's 20 years old, and niche enough that most of it is written by knowledgeable people. With Python, I first have to ensure that the page I'm reading is no more than 2-3 years old, then the copy and paste requires me to re-fix the code, since the syntax is too brittle to stand up to whitespace changes.
- tzs 5y ago> With Python, I first have to ensure that the page I'm reading is no more than 2-3 years old, then the copy and paste requires me to re-fix the code, since the syntax is too brittle to stand up to whitespace changes. I find that I also often have to re-fix the code because so many Python example writers present their examples as REPL sessions, with the code I want to actually copy littered with ">>>" prompts and the output from each individual line's execution.
- jamal-kumar 5y agoI never got why this was such a huge deal for people to do. In vim it's super easy to just select a bunch of text you've pasted in, elimiate all the whitespace with some << commands, and then select what you need to be indented and >> it back into place. Takes like 5 minutes top even for larger amounts of text... beyond that, what are you even doing copying and pasting that much in? That said I do like perl for many things python just isn't as elegant at and your comment about old documentation still staying fresh is pretty true
- singingfish 5y agoI was reading something about a particularly bad enterprise service bus product where I learned in the comments that everything being a global variable is OK, you just have to clean up after yourself when the job finishes. This comment strikes me as similar - here's a design decision that makes a simple task more complex, and error prone. Not that copying pasting large volumes is a good thing.
- jamal-kumar 5y agoIdk... if it's all tabs v for visual mode, select text :%s/\t/ /g boom selected text to PEP8 standard from tabs same if it's spaced otherwise evenly (Interpreter will give you a hard time if it isn't and won't execute the script, so what even is it if not that). your tabstop settings set to this should be fine for the << >> method. It's really not that hard?
- cutler 5y agoRuby is much closer to Perl than is Python.
- singingfish 5y agowhich is interesting because perl and python are mostly the same (although it's only really possible to implement the python object model in perl than it is to do the opposite)
- cutler 5y agoHow are Perl and Python remotely "mostly the same"? Python has crippled lambdas, ugly dunders, indentation for structure and no built-in regex support.
- mikeryan 5y agoI spent some time in the late 90s struggling with picking up perl for ye olde cgi-bin. It was definitely harder to grok then most, I think if you come up from the shell at that time with a large familiarity with awk and sed it was easier to grok. I think it quickly fell down when it became the way to do dynamic web applications for which it wasn’t really suited. As horrible as php was (then) from a language perspective it’s purpose built nature, made it way easier for early web uses. It did a good job of solving one problem and stayed in its lane. It’s interesting that it seems, for the most part, that Ruby was mostly relegated to it’s use in Rails. It was probably one of the easiest and most intuitive languages I’ve picked up (I never got into python) and it quickly became my defacto scripting language though now I pretty much just use node since JavaScript is my day to day and I'm so familiar with the ecosystem.
- jitl 5y agoMy reason to not like Perl is that the language does not support function arguments explicitly. What? People wrote web apps in a language with bash-style argument handling. You have to shift your arguments off the @_ argv array. That, and my student job was maintaining ISP software written in the 90s in Perl by several generations of new programmers. It was very educational. :)
- socialist_coder 5y agoThat's one of my complaints too. But, you can use this kind of trick to get around it and make your code more readable: sub pretty_print { my ($filename, $text, $text_width) = @_; Not as good as if it was just built into the language itself but better then the alternative.
- chovybizzass 5y agoIts no different than es6+: `const { foo, bar, baz } = someObject;`
- civilized 5y agoThis is a unique and staggeringly awful aspect of Perl. What other mainstream language lacks function arguments?
- bloblaw 5y agoPerl doesn't lack function arguments. You can pass various arguments to a subroutine like you do in any other programming language and they can be acessed inside the function using the special array @_. Thus the first argument to the function is in $_[0], the second is in $_[1], and so on. #!/usr/bin/perl # Function definition sub Average { # get total number of arguments passed. $n = scalar(@_); $sum = 0; foreach $item (@_) { $sum += $item; } $average = $sum / $n; print "Average for the given numbers : $average\n"; } # Function call Average(10, 20, 30); reference: https://www.tutorialspoint.com/perl/perl_subroutines.htm https://www.tutorialspoint.com/perl/perl_subroutines.htm
- xrd 5y agoThere was an article recently extolling the virtues of glue code. Perl was the duct tape of the internet for a long time. And, it deserves acknowledgement for that fact.
- cutler 5y agoLincoln Stein's CGI.pm was the default. More like sticky tape.
- da_chicken 5y agoOkay, but if Perl wasn't going to implode it probably would have stopped collapsing before now. Honestly this feels like being told not to speak ill of the dead.
- bartvk 5y agoThe line noise argument is still funny to me, and I've been a happy Perl developer for years. Recently I wanted to draw an irregular circle and bumped into this Stack Overflow answer that expressed the answer in some LaTeX dialect -- boy I found that hard to parse. \documentclass[tikz]{standalone} \newcommand\irregularcircle[2]{% radius, irregularity \pgfextra {\pgfmathsetmacro\len{(#1)+rand*(#2)}} +(0:\len pt) \foreach \a in {10,20,...,350}{ \pgfextra {\pgfmathsetmacro\len{(#1)+rand*(#2)}} -- +(\a:\len pt) } -- cycle } \begin{document} \begin{tikzpicture} \coordinate (c) at (0,0); \coordinate (d) at (1,2); \draw[blue,rounded corners=1mm] (c) \irregularcircle{1cm}{1mm}; \draw[red,rounded corners=1mm] (d) \irregularcircle{1cm}{1mm}; \end{tikzpicture} \end{document} Unfortunately I ran out of time and still have no idea what the final 3 lines of the irregularcircle command do, or why the \pgfmathsetmacro\len{} is repeated twice. Source: https://tex.stackexchange.com/a/126179 https://tex.stackexchange.com/a/126179
- grayclhn 5y agoI like Perl, but if the best argument for its readability is that it’s better than using an archaic macro-only typesetting DSL for graphics…
- redis_mlc 5y agoWhich is false for more than half of the CPAN modules. You can pick a random module and the code is as readable as any other language - I find idiomatic python and rust much harder to read than perl, actually.
- pvaldes 5y ago> still have no idea what the final 3 lines of irregularcircle do, or why the \pgfmathsetmacro\len{} is repeated twice. Divide the circle in angles of 10 degrees. Each one will be a node for drawing the line. Then go to 10,20,30,40 degrees etc until reaching 350 degrees and assign a length for the radius in each node This length will be is the desired radius of the circle plus a small amount of irregularity that is randomly assigned but starting at a value provided as second argument. Finally we need to close the circle with -- cycle. The polygon is defined as a -- b -- cycle, or in this case: starting_node -- {iteration} -- closing_node. Iteration is a list of values for the radius each ten degrees. If I'm not wrong, we need to use the macro two times because the first time we use a starting value with angle = 0 and then we iterate over the whole circle. We need to assure that we start and end exactly at the same radius value (the radius provided as first argument) so the polygon line will close correctly. Therefore the first and last node can't have any irregularity.
- sonofhans 5y agoPeople don’t hate Perl, they’re indifferent. I agree with what the author says, but it doesn’t matter. None of these reasons are significant when people today choose a language to build a new thing. His quote at the end is ironic: “There are only two kinds of languages: the ones people complain about and the ones nobody uses.” I don’t hear people complain about Perl much. Mostly I see blogs about how people should use it more.
- xupybd 5y agoI'd like to avoid Perl at all costs. I've used it professionally on and off most of my career. I hate it.
- bionoid 5y agoI cut my teeth on Perl back in the day, and while I have stopped using it completely by now, I am no hater. But this article does not contain the word "bless", and I wonder why it was left out. If I had to guess, it's not as easy to defend as the nice features.
- gerikson 5y agoI think Perl not having OO built-in hurt it a lot when the trend towards OO started. Of course Perl is more functional than OO so maybe it's time for a comeback now the pendulum has swung back...
- warpspin 5y agoActually I think, it was killed by its strange standard library. A good base OO module in the standard, proper datetime modules, a good exception standard, proper iterators and the like, would have gone a long way to avoid the massive fragmentation which is CPAN nowadays. Then another breaking factor was, I think, actually the long slow Apache 2 and mod_perl 2 migration back then, leaving Perl in one of the areas where it used to dominate in limbo for a long time as other alternatives like standalone appservers and the like simply were not very common initially, so there was no clear migration path. I still think, this was worse than the Perl 6 confusion. In the end, we're now in some kind of downward spiral, where Python, Ruby, PHP have MASSIVE advantages in regards to the scope of their package repositories, while CPAN support of modern things, especially interfaces to Web APIs, is permanently half assed and unfinished.
- gerikson 5y agoYou raise a lot of good points. I believe it is a combination of factors.
- cutler 5y agoThe Perl elite spent too many years futzing over whether to include a MOP (meta object protocol) in the stdlib and, if so, which one. Clunky Catalyst, with its weird subroutine signatures, was also no match for Rails, PHP and Django.
- krylon 5y agoCompared to, say, Python, Perl requires a more conscious effort to write readable code, but in my experience it is a) possible and b) not that big of an effort. One can write equally unreadable gibberish in any language if one has the mind to do so (the International Obfuscated C Contest is an impressive, scary, and hilarious monument to this). I don't write much Perl these days, I suppose the language will always have a spot in my heart, and whenever I need to quickly whip up a script that is too complicated for my puny shell-foo, I know where to turn to. :)
- orev 5y agoI think this is the real point about Perl code readability: it gives you enough flexibility to do things however you like, and as a result many programmers are faced with a mirror that reflects their own bad practices back at them.
- xupybd 5y agoThe list sums up most of the reasons I don't like Perl. It's not a bad language, I just find the syntax annoying and unnecessarily confusing. That is a personal preference. I dislike the experience of working in Perl and will not work with it again if possible.
- xiaodai 5y ago``` $addresses = [ { 'name' => 'John Doe', 'address' => '123 Any Street', 'city' => 'Anytown', 'state' => 'TX', }, { 'name' => 'Mary Smith', 'address' => '100 Other Avenue', 'city' => 'Whateverville', 'state' => 'PA', }, ]; ``` this already confused me. is the $ vigil for scalars? Why is address using it? Isn't address an array here? Don't get it.
- 2OEH8eoCRo0 5y agoaddresses is an array reference with two anonymous hash reference elements.
- sloucher 5y agoSo if it's an array, why isn't it @addresses?
- eythian 5y agoIt's an array reference. If you replaced the [ ... ] with ( ... ) you'd have an array and use @. This is something I see people new to Perl struggle with, and I remember it taking me some time to grasp back in the day. It's pretty natural to me now, but I do feel it's something of a wart in the language.
- cutler 5y agoReferences are scalars in Perl. @$ dereferences an array ref and %$ derefs a hash ref. You can also reference a scalar in Perl and deref it with $$ but I never understood why you would want to.
- turnsout 5y agoI created some big apps in mod_perl back in the day, and although I don't use it at all anymore, looking back I do appreciate the sigils. Especially in the modern era of type safety and type inference, it can be hard to tell what variable "is" just by looking at its name or assignment. Whereas `%names` gives you a clue. On reflection, my biggest critique of Perl is also its biggest strength: it's just so easy to use regular expressions. It's such an important language primitive, people use regex everywhere. Unfortunately, even experts miss regex edge cases, and when regex fails, it can fail spectacularly. Then future-you (or worse, someone else) has to parse and fix that massive regex you wrote after drinking two espressos. In general, clear beats clever. Even if it means your clear, lengthier solution is actually slower.
- AnimalMuppet 5y ago> Then future-you (or worse, someone else) has to parse and fix that massive regex you wrote after drinking two espressos. There's things you can drink that are worse for clarity than espressos...