3 ms·
What would "all the badness of Perl" be?
by mfontani 6y ago
What would "all the badness of Perl" be?
- outside1234 6y agoSee the unreadable unmaintainable code above.
- nerdponx 6y agoFor what it's worth, there's nothing in the Perl manual that says you have to write unreadable, unmaintainable code. Although maybe it's hard to judge a programming language separately from the culture around that programming language.
- faizshah 6y agoHonestly, when you don’t know perl it looks really unreadable but if you spend some time learning it it’s not that hard it’s just many of the operators are not google-able. The harder part, from experience, is maintaining perl scripts. A lot of perl scripts from the early 2000s are written in extremely hacky ways without modern code style sensibilities. In 2021 I don’t see any reason to use perl over python3 anymore, python3 is fast, widely used, easy to write, and easy to learn. Even the bioinformatics folks, some of the last perl holdouts, have been switching to python. Since learning perl a couple years ago I personally only use it for one liners to replace sed/awk. If I do use perl in a script it’s usually in one liner form in a bash script to post process output from something like ripgrep.
- mfontani 6y ago> In 2021 I don’t see any reason to use perl over python3 anymore Is there, in 2021, a "use strict" equivalent for Python, or can one still misspell variable names and not be warned about it?
- nerdponx 6y agoYou would get a NameError (or maybe an UnboundLocalError in some cases) if you use a nonexistent variable name in Python. At least, this has been true since 2013 when I started learning Python.
- jjav 6y ago> In 2021 I don’t see any reason to use perl over python3 anymore Regex handling is still far nicer in perl than anywhere else, so for any script which is primarily about string parsing with regular expressions, perl is the right tool for the job.
- mhd 6y agoMy version? That's a one-liner, one shouldn't maintain those. It was mainly intended to show that a lot of the logic for simple cases is so common that perl (and some other languages) have those as command line switches. That also makes it hard to win for total outsiders, though. This touches on core functionality, which often has quite a legacy behind it and thus its own vernacular. I can write `while (my $line = <STDIN>)` instead of `while(<>)`, but I can't get as easily rid of "chomp" being confusing to most people. A bit like car/cdr in Lisp. But that happens even if you have plain english functions and no special cased syntax. Looking at the simple python version, it took some effort for me to remember what `Count.update(lst)` does, or that `most_common` without arguments returns all elements.
- nerdponx 6y agoChaotic standard library with cute-but-difficult-to-search-for names like "chomp", messy and complicated rules around sigils and scalar() for arrays and tables, lots of magic convenience like "$_" being optional in loops, s/// being "destructive" by default, and the need for some ugly hacks around handling subroutine arguments. Perl has plenty of "good parts", too. But it is not an easy language to learn and even good idiomatic Perl code can be difficult to read. I don't blame people for favoring Python and Ruby.
- mfontani 6y agoI often see examples comparing one-liner worthy code written in one language with beautiful, linted, critique-passing indented code written in other languages, and on and on goes the Perl bashing based on examples of the former.
- keanebean86 6y agoMy only complaint is the dollar sign. Same with PHP. It take time to build the muscle memory for that.
- cgh 6y agoI've always believed Perl has an alignment of chaotic good.