2 ms·
I've worked on large 20 year old Java and C applications (OLTP and batch processes) and I can assure you that they can be as ugly as any old Perl code you have
by skinniks 7y ago
I've worked on large 20 year old Java and C applications (OLTP and batch processes) and I can assure you that they can be as ugly as any old Perl code you have dealt with.
Saying that I see absolutely nothing wrong with that perl code you are highlighting as being obtuse or ugly. Anyone who understands Perl should not have an issue with that line. It is clear and concise.
- Grinnz 7y agoWell, the "foo && bar" is a bit of a bashism, idiomatic perl would do "bar if foo" or similar.
- nocman 7y agoAnd a C-ism, and a C++-ism, and a Java-ism, and probably at least one other I'm not thinking of at the moment. There are a variety of things that Perl programmers would consider idiomatic (depending, I would say, on the background of the Perl programmer). Using something like (foo && bar) in this manner is actually quite common in some Perl code bases (although, I suspect it is more commonly used where there are multiple conditions that are chained -- Damian Conway's "Perl Best Practices" book has some examples of those). In the example given, I suspect the author of that code did it that way to reduce the length and put it on one line. I understand the desire for concise code, but if it were me, I would spread it out more to make it easier to read (mostly, I just wouldn't put it all on one line). I like having concise code also, but there is a fairly definite line that I try not to cross. If I have to work hard at all to keep track of the pieces, it's time to either add some more whitespace (horizontally or vertically, or sometimes both), change some of the constructs, or add some temporary variables to make the intent clear. I am the person most likely to have to deal with the code a year later, so like many others, I try to not confuse my future self.