Live data from Hacker News

Perl secret operators and constants

search.cpan.org

41–46 of 46 posts

Re: Perl secret operators and constants

#41

Obviously you should never use any of these in a production code base. Perl lets you write very bad, anti-team unreadable code in countless ways. You have to actively avoid these traps designed as neat toys.

The second worst code I have had to fix was in Python (sadly the worst was in Perl). Both bioinformaticians.

Re: Perl secret operators and constants

#42
post #18

I have been using Perl since 1996, but I only use a handful of the secret operators. For me, the power with Perl is CPAN and the stability of Perl 5.

If you are working on a code base with others, it would be cruel to use some of these. However there are operators that could be beneficial to the advanced Perl users.

When I use unusual or difficult language features, or basically anything I expect someone else reading the code won't understand, I leave a comment.

Re: Perl secret operators and constants

#43

Earlier quoted context omitted.

I think there's a difference between "baby talk" and using Perl as Perl. You can write Perl that looks like Python, or C, or whatever, but you're missing out on what makes Perl, Perl. "baby talk" Perl is another name for being able to much with Perl, knowing very little of it. Also known as, "Getting your job done". It's up to the individual to learn more about the language, which can be done gradually, much like a n…

you're wrong though: it's not just up to the individual to learn more about the language, it's also up to to every single person who maintains that code afterward! If you learn something, you force your maintainer to learn it. This is particularly true because many syntax elements are literally impossible to Google. If you didn't happen to learn some idiom (syntax), you just can't deduce or discover what it does, unl…

> This is just the nature of Perl.

I would encourage you to check out some of the more recent tools and books on Perl that help greatly in making code readable and maintainable, like the Modern Perl book, the Perl Best Practices book or things like Moose - or even if I dare say, Perl 6.

The Perl Community has come a long way since when I started in 1999, that's for sure. So has the entire Industry, to be quite honest.

Re: Perl secret operators and constants

#44
post #34

Earlier quoted context omitted.

When I first learnt perl, twenty years ago, I loved it because it was full of clever devices and syntactic virtuosism. Now, I don't like it anymore exactly for the same reason. It's cool, but the wrong kind of cool.

That's exactly the problem with Perl: cleverness -- especially other people's "cleverness" -- gets to be tedious, if not an outright pain to put up with and maintain, after a while.

It's my own "cleverness" that winds me up the most. I've written a few bits of 5am code that amazingly and finally work though I no longer have any clue how or why o_0

Re: Perl secret operators and constants

#45
post #25

Earlier quoted context omitted.

Mostly it was all the terrible code that got written in Perl by the first wave of non-programmers to start building web apps.

So, same fate as PHP?

Well, that's half PHP's problem. The other half is that it had very little coherent design in the beginning, which resulted in idiosyncratic an confusing syntax. It focused on a few things Perl did, while ignoring the important context they were housed within (for one, the whole idea of context as Perl implements it, for another being consistent within your own rules).

Perl, as confusing as it can seem, has fairly consistent rules that it follows. Learning those and keeping them in mind will generally let you intuit how something is expected to work.

Re: Perl secret operators and constants

#46

Earlier quoted context omitted.

I think there's a difference between "baby talk" and using Perl as Perl. You can write Perl that looks like Python, or C, or whatever, but you're missing out on what makes Perl, Perl. "baby talk" Perl is another name for being able to much with Perl, knowing very little of it. Also known as, "Getting your job done". It's up to the individual to learn more about the language, which can be done gradually, much like a n…

you're wrong though: it's not just up to the individual to learn more about the language, it's also up to to every single person who maintains that code afterward! If you learn something, you force your maintainer to learn it. This is particularly true because many syntax elements are literally impossible to Google. If you didn't happen to learn some idiom (syntax), you just can't deduce or discover what it does, unl…

Just because you seem to have a C-centric view of the world doesn't mean restricting yourself to C-like syntax and code structure is the "correct" way to do it. At that point, there's no reason to be using Perl over Python. You wouldn't complain that people using Haskell were writing unmaintainable code just because it didn't follow the idioms from C-like procedural languages, would you? Why would you lay the same claims at a Perl? Just because it superficially has some similar syntax and you can restrict yourself to that subset?

Learn the language you are writing code in, and use idiomatic code for that language.

Post reply on HN