4 ms·
See the unreadable unmaintainable code above.
by outside1234 6y ago
See 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.