6 ms·
I think JWZ may be one of the few people that can criticize Perl and I'll be like "fair enough." Most people have never used Perl and just parrot the standard l
by deckard1 6y ago
I think JWZ may be one of the few people that can criticize Perl and I'll be like "fair enough." Most people have never used Perl and just parrot the standard line about it being write-only without actually having used it.
> It combines all the worst aspects of C and Lisp: a billion different
sublanguages in one monolithic executable.
Believe it or not, I used to be a Perl hater and a Lisp (or Scheme) weenie. But having worked with Perl, Common Lisp, Ruby, NodeJS, and Scheme, I really have to say that I'd take Perl over all of those. The worst aspect of C would be pointers and unsafe memory access, which Perl doesn't have. And the worst parts of Common Lisp would be the massive, inconsistent, designed-by-committee language, CLOS, and macros. Oh, and LOOP (I shouldn't need to dig out a reference book to remember how to do looping each time I need to. Seriously.) S-expressions have also worn their welcome on me. I'm just tired of brace matching (yes, even with your silly fancy IDE).
Perl is by no means perfect, but I've found it does more things right than wrong. Blaming Perl for regexes being useful is like blaming a hammer for nails being ubiquitous. What? You're going to hand code a lexer each time you need to parse a phone number or a zip code? If there was a better alternative we would be using it.
- samatman 6y agoThere is! I do! It's Parsing Expression Grammars! There's a reason Rakudo adopted them in its quest to out-Perl Perl (5). Regex is fine as an adequately-powerful shorthand for command-line munging and text editors, where the terseness is useful. It turns on you as soon as you want to use it in a programming language... which is where Perl comes in.
- drran 6y agoIMHO, grammars in Raku are much better than regexps in many situations, except oneliners. https://docs.raku.org/language/grammars https://docs.raku.org/language/grammars
- adrianmonk 6y ago> The worst aspect of C would be pointers and unsafe memory access, which Perl doesn't have. In a practical sense, it doesn't. But it's there if you specifically go digging for it: $ perl -le 'print unpack("p", pack("p", "Hello, world."));' Hello, world. $ perl -le 'print unpack("p", reverse(pack("p", "Hello, world.")));' Segmentation fault (core dumped) $
- bsder 6y ago> What? You're going to hand code a lexer each time you need to parse a phone number or a zip code? If there was a better alternative we would be using it. STOP PARSING WEB FORM INPUT. Please. For the love of God just stop. This is why emails of the form "foo+bar@fakeaddress.myemail" rarely work. Somebody's regex didn't allow "+" and everybody copied it. If you really need to check an email address, send a verification email to it. It's the only method that actually works. Why are you parsing a phone number. The user typed in a phone number, obey it. Are you sure that you know every combination of valid phone number? Zip code ... maybe ... if you are US only. Otherwise a postcode can't be parsed either. And this is before we talk about the Cardinal Sin of using regexes as parsers.
- Sohcahtoa82 6y ago> Zip code ... maybe ... if you are US only. Otherwise a postcode can't be parsed either. Also, don't store zip code as an integer. There are valid zip codes that start with zero that will likely get truncated if you store a zip code as an integer.
- lmm 6y ago> What? You're going to hand code a lexer each time you need to parse a phone number or a zip code? If there was a better alternative we would be using it. Use a parser combinator library. I've yet to find a case where they weren't a better replacement for regexes.
- flubert 6y ago> And the worst parts of Common Lisp would be the massive, inconsistent, designed-by-committee language, CLOS, and macros. I've always wondered what would happen if there was a CL standardization where everything was CLOS'ified in the :common-lisp package, so the #'+, #'map(can), etc. were generic functions along with a nice set of collections (dictionary, etc.). And the more specialized/efficient functions were squirreled away in a non-default package. Well that, and a bunch of other things like a different module system. SBCL seems like such a nice compiler that doesn't get the respect it deserves for being able to compile fast binaries for such a dynamic language.
- ScottBurson 6y agoThere are lots of good ideas floating around for a second CL standard. The problem is, either such a language has a CL compatibility environment, in which case it is probably implemented in CL using the features already in the language, meaning that it's really just another Quicklisp package; or it doesn't, in which case it has to fill some need that couldn't be filled the first way in order to attract a critical mass of interest. Julia is the closest thing I'm aware of to the latter. It's hard to get people to switch from something they find good enough for their needs, if the new thing is incompatible. See: Perl 6.
- lizmat 6y agoIn the case of Perl 6 this has resulted in a rename of the language to Raku (https://raku.org https://raku.org using the #rakulang tag on social media). An experience I would not recommend.
- m463 6y agoAt one point, I didn't know Perl and had to work on a project with it. For a while I was cursing the arcane syntax such as $_, $\ and even $ on a variable to the left of the equal sign... and then something weird happened. Those things became idioms in my mind and I started achieving a sort of fluency. And when I started to think in perl, I found it to be the highest-level language I had EVER worked in. I could express myself because there were multiple ways to do something and one always matched what I was thinking. For example, instead of having to think IF NOT SOMETHING I could UNLESS SOMETHING and then express it as unless(something) { do_something(); } or even: do_something() unless something; Now I like the idea of regular expressions, but I find the implementation leaves a lot to be desired. or should I say implementations plural. To me, the main usability problem with regular expressions boils down this: it is hard to distinguish between a literal and a regex control character. This is exacerbated because regex control characters are usually the same characters other languages treat specially as well. So you have regular expressions - which are somewhat straightforward, but you have to escape them for the place you are USING the regular expression - perl, shell script, sed, awk, grep or egrep, etc. So I've used regular expression for decades, and even now it's always subject to a little trial and error and requires testing.
- naikrovek 6y ago100% agree. Perl is highly underrated in today's software development climate.
- m463 6y agonote: I did switch to python. Even though it's less expressive I found the regularity works out better for me in the long run.
- naikrovek 6y agoI didn't. I don't write Perl anymore either, though. When Python started gaining traction, I was so incredibly turned off by the fans of the language that I swore I would never write code in it. That was 1998. If Python was 10% as good as those people were claiming, it would be humankind's greatest achievement for the next 1000 years, and it isn't. Please note that I'm not saying anything bad about Python here, only its advocates in the late 1990s. I still have a bad taste in my mouth because of those conversations, over 20 years later.
- ScottBurson 6y agoNever use LOOP. I don't! (Except in the trivial keywordless form in which it means "loop forever".)