6 ms·
Maintenance. I say this as somebody who loves Perl, quirks and all (actually because of the quirks). It's actually a beautiful language to work in in the same w
by bane 12y ago
Maintenance. I say this as somebody who loves Perl, quirks and all (actually because of the quirks). It's actually a beautiful language to work in in the same way English is a beautiful language -- it's a beauty because it's a goddamn mess. But it's a rotten language to maintain.
Sure, it's perfectly possible to write highly maintainable code (I have a few 30-40k line Perl projects that I can open up and get right to work on without too much fuss) and you can create some coding standards and stick to them, and write perfectly maintainable code. But Perl is a bit like C++ in the sense that everybody has different standards and those standards change and "non-standard" bits of the language start leaking into your code and you spend as much time unmessing things as you do writing code.
I don't think Perl will ever really die, it's too convenient, but it's definitely never going to enjoy the dominance it once had. It'll fall back to a very good one-off system admin and log processing language with some extra bits, but it's simply a language that the rest of the world has surpassed and Perl 6 just isn't a realistic offering, after a very loooong wait (nor does it fix the issues non-Perlers have with the language -- it's basically fan service).
- amenbrother 12y agoI was recently asked to add some trivial code to the end of an existing unmaintained Perl script written long ago. Something along the lines of $x = `cat FOO 2>/dev/null`; if ($x == "foo") { system("BAR"); } When I tested it I found BAR was executed no matter what FOO contained without any errors or warnings. WTF? After a little more searching I found the problem was that I should have written $x = `cat FOO 2>/dev/null`; if ($x eq "foo") { system("BAR"); } I have absolutely no patience for this kind of crap, but I don't have time to replace the whole thing right now so I just suck it up and move on. I can understand how Perl may never die completely but I'm never going to use it for anything new.
- shadowfox 12y agoThis sort of distinction exists in other languages though: Java has == and equals. OCaml has = and == etc. (Not that Perl doesn't have its issues; but this is very low in that list imho)
- TheMiller 12y agoAhd in Common Lisp, EQ, EQL, EQUAL, and EQUALP. See http://www.nhplace.com/kent/PS/EQUAL.html http://www.nhplace.com/kent/PS/EQUAL.html for an explanation of why.
- sillysaurus3 12y agoMistakes from other languages are still mistakes. One could try to call them tradeoffs rather than mistakes, but then you'd have to explain why the programmer benefits from such circuitous thinking.
- pcwalton 12y agoI don't think that one is a mistake. At least, if it's a mistake, it's not a mistake in the equals operator. PHP attempted to use one set of comparison operators and the fallout has been far worse: there have been security problems due to the semantics of PHP's == operator attempting to guess whether to perform string or numeric comparison when doing password comparisons. The mistake, if any, is that numbers and strings are unified into one scalar type in Perl. This allows some tricks, such as being able to use sprintf to perform rounding, but it has fallout in other places in the language, such as here. Given that numbers and strings are unified, having two operators for comparison is the correct decision: it makes the semantics much simpler by having the language not guess which kind of comparison to perform.
- TheMiller 12y agoThey're not mistakes; read the article. "Equality" is not the singular, unambiguous concept that many programmers think it is.
- tobinfricke 12y agoBut in those languages, the equivalent to ($x == "foo") will return false (almost) all of the time. The poster here says that this expression is true (almost) all of the time in Perl. Why?
- mst 12y agoI guess you've never written any bash either, wherein the exact same problem exists except that == and eq are the other way around, for reasons I can't quite remember. Plus, of course, if you'd enabled perl's warnings system, via 'use warnings;', it would have complained at the use of == on a non-numeric value. If you don't enable the compiler features that catch problems, then, yes, you can run into problems. Welcome to programming. Edited to add: I got downvoted within five minutes. If you disagree that my bash analogy is inaccurate, I'd love to hear why.
- scrollaway 12y agoI did not downvote you, but comparing a language to Bash is certainly in no way flattering, and I would definitely not put it in the "good defense analogy" category.
- mst 12y agoComparing a final conditional in a systems-style script that is then calling another program, shell-style, to bash, which is the most common language where you'd execute a conditional then call another program, seems reasonable. Maybe not flattering, maybe not a good defense, but I think under the circumstances an acceptable comparison.
- amenbrother 12y agoThanks for the 'use warnings;' suggestion. Keep in mind the subject here is maintainence - where small changes with minimal impact to production is the rule and the work is often done by programmers with incomplete knowledge and no patience for explanations. For maintenance you want KISS, not TMTOWTDI. I'm no big fan of bash but at least bash gets the common case right here without any special settings. For example, if I use -eq instead of == and write #!/bin/bash x=`cat FOO 2>/dev/null` if [ $x -eq 'bar' ]; then echo baz fi as you imply, bash won't be silent. It will say bash-3.2$ ./example.sh ./example.sh: line 3: [: bar: integer expression expected
- 12y ago
- crahrah 12y ago""non-standard" bits of the language start leaking into your code" I work on a small team (C++), so this has never been an issue. If you break coding guidelines someone will notice and let you know. But this really should be integrated into work-flows. (ie/ into Gitlab, Jira, etc.) There should be some kind of step - before you are allowed to merge code - that checks that you are withing coding guidelines.
- EdwardDiego 12y ago> But it's a rotten language to maintain. I've been diving into some of our legacy Perl and man, the learning curve of the various sigils and implicit variables. Even working with collections was challenging. I'm working to make it better Perl (I have a copy of Modern Perl on my desk), but that's solely to make it understandable so that we can rewrite it / replace it with something like Salt.
- mst 12y agoIf it's seriously legacy code ... then I'd completely support you rewriting it, and I'd rather see it rewritten as not-perl than left as bad perl, no matter how much I personally do like perl. This is why I'm glad we're not the 'most popular thing' anymore, these days the same quality of people are producing similarly awful code in node.js and go, and I feel sorry for those languages' communities because of it.
- EdwardDiego 12y ago> If it's seriously legacy code ... Well, I'm removing globally scoped maps shared across several modules and about 6000 lines of code. To be fair to the original author though, he was learning Perl as he went along, and when he learned about references he started using them in new code.
- yellowapple 12y agoIf you don't enjoy Perl code that looks like a cartoonish string of censored profanities, you could always try including 'use English' in your program, which aliases more descriptive names to all those punctuation-mark special variables. See here: http://perldoc.perl.org/English.html http://perldoc.perl.org/English.html
- mst 12y agoI don't want the popularity we once had. The same people who wrote unreadable, unmaintainable perl went on to do the same sort of damage in PHP, then python, then ruby/rails, and now node.js/go. They were never a net positive to the community, and I'm not sorry to see them causing problems for somebody else. (and before somebody says "but that doesn't happen in X" ... yes, it does, even python lets you write code that looks superficially comprehensible but turns out to be so horribly illogical structurally that it's impossible to maintain - I quite like python but I've been there and I was kinda scared because at least wrong perl looks wrong to start with, whereas wrong python looks fine until you realise just how much of a crawling horror it is)
- chaostheory 12y ago> before somebody says "but that doesn't happen in X" ... yes, it does, even python lets you write code that looks superficially comprehensible but turns out to be so horribly illogical structurally that it's impossible to maintain It does happen, but due to the design of Python / Ruby / Javascript, it's a lot harder to make happen especially when you use a framework. As a former Perl dev, unless someone maintains god-like discipline over a Perl code-base; it's a lot easier to come up with unmaintainable spaghetti, that no one save for the original developer fully understands how it works, than it is in other competing languages.
- esaym 12y agoI was thinking the same thing. Didn't say anything because I didn't want to be rude to the "lets cut and paste code from google searches" coders... If someone really wants to use a language, there is no excuse for not reading a book for that language first.
- yellowapple 12y agoAnd when it comes to a "book for that language", Programming Perl really does take the cake.
- mamcx 12y agoWith python is not the same. Even if the developers is truly bad and do a mess, is a decipherable mess. Requiere truly talent to do a hard-to-understand mess in python, and in that case, is very likely the code was made by a good developer ;)