Readable Perl (compared to lang*) (greenokapi.net)
NO FLAMES PLEASE.
Another i++ of perl's <blah> is not required.
What have been the successful trade-offs interms of readability in <language>?
CPAN Power http://search.cpan.org/~fxn/Acme-Pythonic-0.46/lib/Acme/Pythonic.pm :P http://search.cpan.org/~shancock/Perl-Tidy-20090616/lib/Perl/Tidy.pm http://search.cpan.org/~elliotjs/Perl-Critic-1.105/lib/Perl/Critic.pm Lots of modules((like Class::*) to simplify boilerplate code which inturn enhance readability.
Flowcharts[not exactly related to readibility] http://search.cpan.org/~jnagra/Perl-Visualize-1.02/Visualize.pm http://search.cpan.org/search?query=GraphViz&mode=all http://search.cpan.org/~tels/Devel-Graph-0.12/lib/Devel/Graph.pm
25 comments
[ 6.0 ms ] story [ 58.9 ms ] threadOne thing that struck me is just the shear amount of features and ways to do things that are built in -- whether it's good or not. For example, the "unless" operator strikes me as very useless. It certainly doesn't save any typing and it seems that the existence of many ways of doing the same thing makes it more confusing, not less.
That said, I'm definitely in the "Perl has serious readability and maintenance problems and Python makes me weak in the knees" camp.
Like C++, perl greatly rewards expertise and experience. If you want to be able to read everything inside two months, well, go elsewhere. But I'd say you're missing out.
So Perl is readable if you are a Perl expert - for everyone else it's pretty unreadable.
There are idioms in every language, especially in syntax. Python's inheritance declaration looks like a function call or an argument specification. Ruby's uses < to indicate inheritance. PHP and Perl are more self-documenting in this regard, using "class _subclass_ extends _baseclass_" and by assigning to a variable named ISA within a package respectively. Python's decorator syntax is non-obvious, and uses a perl-ish sigil to boot. Ruby using sigils to indicate scope (vs type, which is how it is done in both perl and older BASICs) is non-obvious. Python syntax for single element tuple creation. PHP's arrays allowing both integer and string indexing in the same array, and its "hashes" or "dicts" keeping order, leads to idiomatic code. Perl assignment list expanstion when using arrays and hashes as subelements on the LHS eating up the rest of the input is idiomatic. unless is idiomatic in perl, but only because few other languages have that kind of construct, and instead force you to use an if-not, which isn't always as readable. Perl's map and sort look like they can take closures, but they're really BLOCKs which is slightly different. The difference between Proc objects, blocks and lambdas and how they can be converted between each other and called in ruby is idiomatic.
Latin is readable if you speak Latin -- for everyone else it's pretty unreadable.
While other languages of course have their special syntax, Perl is very extreme in this regard. This is best illustrated by the following diagram of special Perl operators (where most of them are only found and used in Perl):
http://www.ozonehouse.com/mark/blog/code/PeriodicTable.pdf
I'd like to see a citation for that. My understanding was to allow for simpler nested data structures.
I can't imagine how that could be, unless somehow you mean that "first-class functions require references in Perl 5", which is true only insofar as first-class functions rely on the design concept of references.
If Larry had invented the idea of a reference context (not the most precise term, but I think it's understandable), references would have been unnecessary in Perl 5.
i think perl6 is using a different appoach based on laziness for nested data structures. there are always strings and do blocks which assign and return globs with randomised but unique name(gensym but perls gensym is returns a GLOB reference so you have to write ur own).
reference context == continuation right ?? in sub bar { ... $foo = sub { .... } ... return \$foo}, i think \$foo also captures the lexpad of bar using a single reference to $foos internals. thats all.
otherwise i think one would need continuations like in ruby or scheme or perl6.
Can you trolls at least get something about Perl5 to post about?! (Answer to a possible answer in advance: "What, you post about another language in the same family -- and claim not to be a troll!?")
I'll reference this, regarding language trolling on HN: http://news.ycombinator.com/item?id=963706
Because I'm just not going to be trolled discussing this on HN, again.
Wow, can you go through the synopses etc and prove that? :-) [Edit: Please put especial emphasis in showing why Moose is bad.]
That was sad. Why don't you run along and try to "argue" with someone about Emacs/Vi, instead?
Just try to not again start with flaming a language/editor based on a reference to a very different language/editor with a similar name.
Also, try to find something better than outdated ranting based on a claim that a humorous speech shows someone is insane... :-)
I do see that PHP is underrepresented in my list, and I just ran across one of PHP's most confusing idioms the other day. The LHS of list expansion assignment requiring the keyword list(), which looks like a function call. I can't count how many experienced programmers have asked me how this assignment to a function call works, which proves this is an idiom. And the opposite is a perl idiom: some functions in perl can operate as lvalues, like substr.
"The very fact that it's possible to write messy programs in Perl is also what makes it possible to write programs that are cleaner in Perl than they could ever be in a language that attempts to enforce cleanliness."
A claim that higher expressibility in a language (natural or not) doesn't imply better expressibility -- given that the user knows his tools.
(Well, your "argument" could also be taken as "anything that can't be written in standard Python isn't worth to write; that is all the expressiveness needed ever, Amen". Gödel might want to say something about that, but never mind.)
Dillinger(!) is claimed to have said "Bonnie and Clyde gave bank robbing a bad name". You give trolls a bad name.
Then look up the Ruby documentation for .. , which is also overloaded to have two different meanings, one that works inside conditionals and one that constructs Range objects when outside of Range objects, which is just as much syntactic sugar as anything perl provides. And the difference between .. and ... is visually subtle, I wonder how many off-by-one errors that operator idiom causes.
It all comes down to this: Perl doesn't have a "Right Way"(TM) of doing things. Many people (perhaps yourself) feel that this is a good thing. I simply believe the opposite.
I suspect in other languages lots of things compile to the same thing -
should produce the same thing. But if I was affecting a bit vector I'd use the former and if I was affecting a number I'd use the latter - because while the operation at the machine level might be the way, they are conceptually two different things and I want to express the concept to the next developer to look at this code.The fact that perl intentionally supplies lots of features to allow me to write my code to express my intent as clearly as possible is an advantage to me, just as I find the english language an advantage over, say, lojban.
Perl syntax also builds on a rich heritage. If you are familiar with that heritage, it's a lot more evident. Conversely, as you learn Perl, that heritage is elucidated. (For example, learning Perl in a Windows environment (I know...) and then moving to UNIX.)
Incidentally, on the subject of object orientation, I concur with Sriram Srinivasan's preference for Composition instead of Inheritance. He writes in "Advanced Perl Programming":
"Then when John Ousterhout's Tk came along, I marveled at the ease of creating widgets, even though it was in C and provided all the features that Motif provided (and much more). The Tk architecture used composition, not inheritance. I have been suitably chastened."
thats is why its "bare syntax" like sigils and all are wierd like the case endings in english. but they follow laws which when groked can be abused. like say "ness" can be added to adjectives to create nouns and so on.
eg) in ruby or in python varible names are like this, foos = ["foo","bar","foobar"] in perl you simply say @foo = ("foo","bar","foobar").
since perl treats $foo differently from @foo. (but most however do use @names due to their natural inclinations). see http://www.csse.monash.edu.au/~damian/papers/HTML/Perligata.... if you can grok gramatical cases.