Which will be negated by how hard real-world perl code is to read and maintain.
Which will be negated by how hard real-world perl code is to read and maintain.
package Point;
use Moose; # automatically turns on strict and warnings
has 'x' => (is => 'rw', isa => 'Int');
has 'y' => (is => 'rw', isa => 'Int');
sub clear { my $self = shift; $self->$_(0) for qw/x y/}
1; class Point {
has Int $.x is rw;
has Int $.y is rw;
method clear() { $.x = 0; $.y = 0; }
}
:) use mop;
class Point {
has $x = 0;
has $y = 0;
method clear { ($x, $y) = (0, 0) }
}
ref: https://github.com/stevan/p5-mop/blob/master/t/000-examples/...Moo/Moose (and Mo and Mouse if you must) are on the other hand game changers.
I definitely recommend reading "Modern Perl". It is a game changer.
You don't even need to know how to write code to understand the code written at Crowdtilt or any other company that really uses Modern Perl and have good practices.
Comparing the readability of python vs perl/c-like languages show it clearly. In python the readability come as a natural idiom, it is part of their zen!.
I found that when I develop in python/delphi/pascal the code is readable by default, but in ANY c-derived language could become messy fast. Something as simply as how align a IF clause. In C-like language I could go wild (and I see a LOT of code that look different, from person to person) and in contrast I read almost any python code as if I was write by myself.
Superficial readability, perhaps.
Neither PEP 8 nor PEP 20 get into interesting questions about maintainability like:
* How long should individual compilation units be?
* How do I factor my code?
* What metaphors do I use to name components?
* How do I know when to break apart components?
* How do I know when to merge components?
* How do I write effective documentation?
* Is this API easy to use?
* Have I sufficiently encapsulated this component?
* How easy is this code to test?
* Does this code match local style?
* Does this code follow the idioms and express the necessary elements of the problem domain effectively?
* Is it easy to misuse this API?
* Have I made too much information public?
* Have I made too little information public?
* Does this code make potential bugs screechingly obvious?
* Do I handle potential error conditions sensibly and completely?
* How much work do I face enhancing this code in the future?
PEP 8 concerns itself with far less interesting things, like why vertical alignment is annoying. In my experience, that's one of the least substantial elements contributing to maintainability.As for readability, it doesn't really matter if someone who doesn't know the language can't read it.
PEP 8, on the other hand, is to get these good developers to agree on the less interesting things, such that they can use it as a stepping stone to the more interesting ones. PEP 8 requires strict compliance, because if different developer ignore different portion of PEP 8, you end up with nothing.
In short, if you have long lines of code crammed together with no spacing, get them to look pretty based on PEP 8 first before we talk about how easy is this code to test.
It's just easier to write bad Perl, and most Perl is set it and forget it in scope.