Penguin

Differences between version 16 and predecessor to the previous major change of WhyIHatePerl.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 16 Last edited on Saturday, September 11, 2004 4:14:30 pm by CraigBox Revert
Older page: version 13 Last edited on Thursday, May 1, 2003 8:18:53 pm by GlynWebster Revert
@@ -7,15 +7,17 @@
 In perl you're never sure the operator this person is using is. Perl has operators and variables names after almost every punctuation key on the keyboard. (Pop quiz: Which punctuation keys on a standard qwerty keyboard, *aren't* valid perl variable names?) 
  
 ''True, but you don't need to know or use these variables. Just because you *can*, doesn't mean you *should* :) $! is the string message for the last error, $@/$$/$% do things with references to those data types, $# is the length of a list, $^ is magic for which OS you're on, etc etc. But not knowing this doesn't make perl any harder to use. Most punctuation also does something in C -- you're just more used to them.'' 
  
-''Isn't this based on the assumption that "use" is only writing code? I would argue that since you (and others) will end up having to read, and interpret the code at some point, complex and obtuse constructs like this do make the language harder to use. Since they are there, they will be used, so you have to know them to be able to understand the code.'' -- StephenLewis  
+''Isn't this based on the assumption that "use" is only writing code? I would argue that since you (and others) will end up having to read, and interpret the code at some point, complex and obtuse constructs like this do make the language harder to use. Since they are there, they will be used, so you have to know them to be able to understand the code.'' -- Stephen Lewis  
  
-''Also, just to be pedantic, the node is WhyIHatePerl, not WhyCIsBetterThanPerl ;)'' --StephenLewis  
+''Also, just to be pedantic, the node is WhyIHatePerl, not WhyCIsBetterThanPerl ;)'' --Stephen Lewis  
  
 This was ment as a random rant, as someone asked me what I disliked about perl, so I thought I'd jot a few of them down. It's not ment to be a complete critism, most of it is mostly due to my not knowing the language properly. 
  
 The thing is in perl you *can* write nice and easy to read and maintain programs, however people don't. Sure ''I'' can avoid these things, but it doesn't help me when I'm trying to debug some body ''elses'' script. C uses a lot less punctuation than perl, this is easily proven by the fact that perl uses mostly the same punctuation as C, and then adds it's own ones :) I don't think C and Perl really should be compared. They are completely different problem domains. I've got a rant growing somewhere about C too :) Compared to python, perl looks like executable line noise. 
+  
+''And [Python] looks like executable whitespace. These variables are actually hardly a design decision on [Perl]'s side - 99% of them existed in [AWK]. Much of the linenoise comes from the [AWK] and [SED] heritage actually. The majority of it is loathed by many [Perl] hackers as well. Too much of I/O is controlled by global special variables; Larry himself has said this situation needs fixing. Of course not much can be done for [Perl]5. Unlike the [Python] and [PHP] folks, we don't go breaking people's old scripts willy nilly :)'' --AristotlePagaltzis  
  
 !!Simple things are hard 
 Someone once said that the definition of a low level language is one that requires you to spend your time worrying about the irrelevant. Perl must indeed be a low level language. Trying to figure out how to pass a list to a function, create a local variable in a function, nest types are all things that are difficult to get "right". You have to know a magical encantation to do them. Why don't they do the right thing? 
  
@@ -23,26 +25,33 @@
  
 Lists get flattened, variables by default are global, nested types aren't really nested (they're just references). The point of a scripting language is to get on and do what you want, not spend time thinking about how you are going to achieve it. I'm sure there are other examples of perl doing counter intuitive things by default and requiring you to work around them. These are mostly historic since perl grew out of a smaller language into a bigger one. But I think these are good examples of why you shouldn't use perl for a large project. Perl is good at parsing text files and outputting a nice summary, or munging it into a different format. Perl is not something that you should be writing large projects in. Yet people still do. (People still write large user space projects in C too for some unknown reason). 
  
 To effectively work on a large project you've got to manage complexity, with perl unless you are very strict, the complexity gets away from you. The thing is most programs start 'small' (I'll just write something that parses subscribe/unsubscribe requests and updates a sendmail alias) but ends up growing over time into a monster (majordomo...) Compared to almost any other language, Perl makes you spend a lot of time working with the irrelevant. 
+  
+''Perl let's you know about the reference as well as the reference. Other languages hide the reference from you without working fundamentally differently. How is that better?'' --AristotlePagaltzis  
  
 !!There's More Than One Way To Do It 
 Perl people say this is a good thing, but the problem with theres more than one way to do it, is that noone ever does it the same way twice. To properly read a program you have to understand the 'idioms' that that program is written around. In Perl it's difficult to realise that "ah, thats a switch statement, I can see what that's going to do" because in perl there is no switch statement, you can roll your own (a nice idea), but, you can get half way through and discover someone's modified their idea of a switch statement slightly and now it has a side effect you didn't realise until you read the code very very carefully. In most languages you can learn a couple of constructs (for, while, do..until, if...then...else, functions) and you've learnt a good chunk of the language and can read most of it. (Even C++ which has a huge number of things (virtual private classes? who on earth would use such a thing?) you learn about the various flow control structures, and how to define/call functions/methods, and you can follow a good chunk of C++), however in perl, since theres so many ways of doing anything you have to learn all the idioms before you can read a sizable chunk of perl code since they are all used, randomly. 
+  
+''You're hanging your entire argument on switch statements here. [Perl] does not have one because all switch statements found in other languages suck to varying degrees and Larry decided we don't want one we'll have to work around rather than with. I haven't been particularly irked by that decision in practice.'' --AristotlePagaltzis  
  
 !!There's More Than One Way To Do It, part 2 
 (GlynWebster's two cents.) 
  
 When Larry Wall and Perlers say "there's more than one way to do it" they seem to be talking about syntax rather than the semantics. They really mean "there's more than one way to say it". I'm not sure that Perl gives anyone more ways to actually do things than any other well-stuffed scripting language. It gives people lots of ways to write down individual statements, which gives them a sensation of freedom while coding[2], but only seems to lead to confusion and trouble later on. The languages that really give you a lot of ways to do things, like CommonLisp, are far less popular. 
  
 I think this emphasis comes from Larry Wall's background in linguistics. With a natural language having lots of ways to say things is a good thing, but semantics are something that linguists try not to think too deeply about. The semantics of natural languages are so poorly understood that it's a bottomless pit best to stay out of. But computer languages are not like languages. They are "notations" more akin to the various notations used in mathematics. Larry Wall don't believe this. Larry Wall seems to be be paying more careful attention to semantics in his "Apocalypse" series of design documents, but he doesn't seem to learnt his lesson about syntax -- Perl 6 looks like it will be even hairier than Perl 5. He's more than smart enough to design a computer language, I know I couldn't do what he's done. I just don't feel like following him because I don't think he has taken the right approach, and has the wrong temperament for his task -- a belief that elegance is possible and a mathematician's urge to reduce things to their essentials seem to be called for. 
  
+''LarryWall believes that humans are linguistic animals, not that computer languages are like natural languages. Mathematical language is precise, but not the way we think. Larry believes usable languages must follow the way we think, not make us think the way the language works, and I absolutely agree. Reducing is not the answer. If animals, which is a category, were all called similary, say "ani"+syllable, and a cow as anico and a cock was anica you might send someone to milk the cock by accident. Things have to be sufficiently different, even if they're similar. You'll also notice that [Perl]6 is all about reducing similar mechanisms to identical foundations.'' --AristotlePagaltzis  
  
 !!Cause doesn't always preceed effect. 
 Perls operators like "unless" mean you can spend a long time reading a block of code before realising that the entire block doesn't get called because there is an "unless" at the end of it. Cause should preceed effect, not come half a program later. 
  
  <Matthias> hmmm... and unless is nice in some cases... it can really help 
  making code readable... unless you abuse it 
  <Isomer> I think that sentance just proved my point 
+  
+;: ''(Later addition) If you are using a complex condition which is composed of many smaller parts that may themselves be broken down into subconditions, making the condition part take a long time to read, memorize (of which different people are differently capable) and parse while you are trying to reach the conclusion of what it is all really trying to achieve at the essence of the matter - you might even start to get confused because the whole thing is getting too long to memorize for ''anyone'' -, then it makes sense. Now wouldn't that have been much easier to read if I'd put the "it makes sense" up front and left the longwinded condition trailing behind?'' --AristotlePagaltzis  
  
 ''Again, just because you can code something in one way, doesn't mean you should. I personally don't use the 'unless' keyword because it doesn't flow the same way a C program would. But then again, it is not uncommon in C to see do { block } while (0); This isn't exactly crystal clear either unless you are a seasoned C programmer.'' 
  
 The problem is that most of the code at least I interact with is written by other people, or at least is modified by other people. If a program is small, then it's irrelevant, people will just tend to rewrite it instead of modifying it. I find very few perl programs that I honestly thing are 'readable' and 'clearly throught out', this is perhaps because I'm not very experienced in the language, but when compared to when I was teaching myself C, I find perl to be much worse. 
@@ -51,8 +60,9 @@
  
 !!Perl implicitly does things behind your back. 
 Perl's $_ operator saves a lot of typing, but makes your program have a large hidden dependancy. Like the "more magic" switch of lore, changing something unrelated that does absolutely nothing obvious can cause your program to crash. Is it safe to insert some code in the middle of this block? Who knows! It could disrupt the fabric of space time that this perl program exists in. 
  
+''Um, that's what __local__ is for.'' --AristotlePagaltzis  
  
 ---- 
  
 !!Some additional discussion from the page of JaredWigmore: 
@@ -70,8 +80,44 @@
  
 The thing with Pascal is that it was impossible to do most things. Standard Pascal didn't treat files like most newer OS's did (a stream of bytes? wazzat?), but it's big failing was that the size of the array is part of the type, and there was no way to write a generic function to handle arrays of varying sizes. Since strings were a kind of array, you couldn't write a function to take a generic string. Sure, langauges like TurboPascal resolved most of these issues in incompatible ways. Delphi shows that Pascal can be a nice language when "touched up". 
  
 Perl may be expressive, but the problem is that you have to maintain other peoples perl programs, and since other peoples Perl programs are difficult at best to modify, you have a problem. while this may not be the language's fault, it __is__ a problem with the language IMHO. --PerryLorier 
+  
+----  
+  
+!!! AristotlePagaltzis and his soapbox  
+  
+[Perl] has weaknesses, but it follows the principle of [Mutt]: all [ProgrammingLanguage]s suck, this one just sucks less.  
+  
+If you read this page from a [Perl] hacker's view, you will continuously stumble over three things:  
+  
+# The original author is unwilling to learn references, which are the sole key and foundation to complexity and power in [Perl]. You may argue that you don't want to do so; fine, then [Perl] is not for you. But that the language separates the reference from the referent can in no way be construed as a weakness. Au contraire, it gives you control.  
+# Most of the people say "well I couldn't be bothered to learn [Perl] thoroughly" often followed by something along the lines "things didn't seem how I expected them". Well, [Perl] is [Perl]. If you wanted to learn a variation of some language you know, then why did you try [Perl] in the first place? If you're approaching something new with preconceived notions, you're going to return to your old ways pretty soon.  
+# The argument that "you ''can'' write clean [Perl] -- but people don't!!" comes up often. To that I say "real programmers can write [Fortran] in any language."  
+  
+!! Keys to [Perl]  
+  
+The first I have to say is that [Perl] is ''hard'' to learn. It is optimized for ease of ''use'' rather than ease of learning - a concept that seems to be foreign to modern computing (cf [GUI]s). It is not a language I would give a programming beginner to learn with, either, for exactly that reason. You don't put a greenhorn who just got his driver's license in a 200 HP sports car either, nor on the wheel of a 50 ton Mack truck. In that sense, [Python] fills an important gap - many people only write a few lines of code occasionally, and they're better off with a tool that guides them. If you only want to write a few lines of code occasionally, don't learn [Perl]. You'll only end up hurting yourself. A lot of people have, and the result is literally hundreds of thousands of awful scripts floating around on the web.  
+  
+Secondly, although its [C]-like syntax and [C] heritage may have you thinking otherwise, [Perl] is a list oriented language. It understands arrays as a type natively - in contrast, arrays in [C] are syntactically glorified pointers that, as far as the language is concerned, point to a single value. All variables in [C] represent only a single value; it has no notion of a list. [Perl] is much closer in spirit to [LISP] than [C], and indeed there's a lot of crossbreeding between [LISP] and [Perl] hackers. (I love [LISP] as well, myself.)  
+  
+Lastly, there's the issue of references I mentioned before. Any high level language builds complex nested structures out of simpler ones. [Perl] is no exception, it just makes this process explicit and in that way also lets you distinguish between the referent and the reference, where other languages conceal the latter. That said, in simple cases, [Perl] lets you pretend the reference isn't there, and my experience is that with a certain fluence in data structure layout for [Perl] code, the simple cases account for 60-95% of all uses, depending on what you are doing. The derefencing syntax for more complex cases is rather ugly and not something even [Perl] hackers cherish, though. ([Perl]6 promises to relieve this.) All that said, it isn't very difficult. With a bit of thought you should achieve any kind of manipulation you wish, something lanugages which hide the reference from you can't always offer. If you want to learn [Perl], take your time to understand how (de)referencing, it is the sole key and mechanism to complexity management in [Perl] - it might be inconvenient to learn, but ''all'' advanced mechanisms in the language hinge on references. Once you master them, all of the language is at your command.  
+  
+!! Why shortcuts are good  
+  
+From command line switches to the infamous ''$_'' variable to file operations, you can let [Perl] do a lot of your work when you can't be bothered to spell it all out. This does not mean you always should, but makes development a lot easier. I rarely know beforehand exactly how I am going to implement a program; being able to take shortcuts while I work on it until the final form crystalizes is very convenient. These shortcuts also improve maintainability if used in appropriate places, as well - the reader of a piece of code does not have to parse a lot of explicit red tape to come to the conclusion that it's just red tape and can be ignored in the greater scheme of things. The actually meaningful bits make up more of the code and so get more attention. O.c., abusing abbrvs mks anything < rd'able; I often go back once I have settled on a certain structure and remove or add shortcuts in order to make the coder clearer.  
+  
+Writing good [Perl] means finding a proper balance. But you ''can''. Other languages keep you perpetually slanted.  
+  
+!! A bit of petrol on the fire  
+  
+There's no direction in [Python]. No really. Guido and his crew don't (didn't?) even have any idea how the new language features in the [Python] 2.2 to 2.3 transition should be addressed. And they're going to break old code by changing the way established data types work. (The [PHP] folks have been doing this forever of course and noone seems to care. Namespaces? Wazzat? (The core functions are still getting lumped into the main global namespace with name prefixes.))  
+  
+[Perl] has a long history of organic growth as well as any complex system must, but there's always a long phase of design and rethinking involved for major changes, and they lead to a new version of the entire language rather than just its implementation. Meanwhile the [Perl]5 compiler will swallow most [Perl]3 code unchanged without complaint (the first version that reached any significance). [Perl]6 is breaking this tradition on the grounds that the language needs an overhaul, and that there will be both a true [Perl]5 compiler that targets [Perl]6's VirtualMachine as well as a lesser P5 compatibility mode in [Perl]6 itself.  
+  
+!! I am not trying  
+  
+to get anyone to use [Perl]. But nearly all of the criticism on this page hinges on the fact that people don't know [Perl] well enough (and I'll be so indignant to assume that the rest is only accidentally directed at real weak points because they're unavoidable). I don't see why a [Python] or [Java] or whatever advocate would write about why he hates [Perl] when they haven't bothered to learn it, where it would be much more logical to write about what they love about their favourite language.  
  
 ---- 
  
 [2] I think a similar, pleasant feeling of busyness while coding explains some of the popularity of [C]. "I'm doing lots of work, I must be getting a lot done. Right?"