Slashdot Mirror


Perl Medic

Craig Maloney writes "Anyone who codes in Perl can relate to working on other people's code. Sometimes the code will thankfully include "use warnings" and be a joy to maintain. More likely, though, the code will have so many warnings that the useful output is long gone in the stratosphere of your scroll buffer. Even good code written for earlier versions of Perl can become aged and decrepit, requiring elderly modules that may or may not work with newer versions of Perl. Maintaining this code can be a hassle, but fortunately Perl Medic: Transforming Legacy Code (referred to for the duration of the review as Perl Medic) provides some very useful tips for getting through these migrations, and will help the next person maintaining your code." Read on for the rest of Maloney's review. Perl Medic author Peter J. Scott pages 312 publisher Addison Wesley rating 8 reviewer Craig Maloney ISBN 0201795264 summary A great collection of Perl wisdom and tips for experts and other patient Perl acolytes.

One of the goals of Perl Medic is to transform code from stylistically poor and unmaintainable into stylistically sound, maintainable and testable code. The format of Perl Medic is very similar to books like The Pragmatic Programmer or The Practice of Programming. Perl Medic shows the reader best practices by example. Some of the chapters are checklists of practices that will help improve your ability to manage and wrangle the code, while others are lists of patterns and practices you should avoid, and should replace with the examples provided. This format very readable, and provides an excellent forum for gleaning what ways to improve the code.

Perl Medic is designed with experienced coders in mind. Topics are presented as if the reader may be using these ideas already in their code, whether good or not. While the advice is good, the presentation may be confusing for beginner and intermediate programmers who aren't intimately familiar with the concepts. I found myself re-reading several topics to try and grasp what the author was trying to convey. After several readings of the section on test harnesses, I still needed help, and ran to the Perl documentation to better understand what the author was saying. Certain advice is also presented, only to have it countered in the next section. Most Perl programmers are familiar with the '-w' switch, which turns on warnings in a Perl program. The pragma 'use warnings' is introduced as a way to turn on warnings for just the code being worked on without displaying the warnings of the modules included in the program. In the next section, the author points out that it might be a good idea to put '-w' in there to see if there are any issues in the modules you may be including. While this advice may be intuitive for experienced Perl coders, the beginner may be confused. "Should I use '-w', or should I use 'use warnings'" she may ask herself.

The book also suffers from a case of being too brief in some sections. In section 2.3.1 (Gobbledygook) the reader is directed for help on how to turn a partially obfuscated program into more intelligible code; a very useful skill indeed. The author redirects the reader to section 4.5 where the utility perltidy is discussed with further detail, but before ending the section, the author also introduces the module 'B::Deobfuscate' along with a URL. No mention of how to use it is provided. In section 6.4 (Debugging Strategies) the author gives advice on how to debug a program. His advice: "Divide and Conquer". While there is debugging advice throughout the book, it's a little frustrating to see a section specifically designated "Debugging", with only one subheading under it. The organization of some of the topics feels artificial, and perhaps should be reorganized in future editions.

Underneath these faults, though, Perl Medic is a great book. Chapter 11 (A Case Study) should be required reading for coders inheriting Perl projects. This chapter is a blow-by-blow account of the author's work in transforming a simple LDAP application from Perl 4 into a robust Perl 5.8 application. The author is very candid about what decisions were made in the code transformation, and why certain elements were addressed in the way they were addressed. One particular element is an elderly module used for the LDAP lookups themselves. The author details the process used to determine a better module to replace this module, and guides the reader through each of the steps required to change the code to use this new module. The decisions the author uses to make this code work under the new environment are enlightening for anyone planning a migration of Perl code into a newer environment. Chapter 7 contains the versions of Perl from Perl 4 up until 5.8.3, and elaborates on what changed between the versions (very helpful for those who are planning an upgrade from 5.003 to a more recent version of Perl). Chapter 9 (Analysis) has very useful tips for not only debugging you program, but for using the Perl Debugger and getting the most out of your debugging session.

Perl Medic is recommended for anyone who is tasked with maintaining or writing Perl Code. While the examples are written with experienced coders in mind, beginners will do well to use this book for areas to focus on while they learn the language. Inheriting code can be a daunting task, but with a book like Perl Medic, you'll have the tools at hand to help ease the work ahead into a more manageable task. And you'll make it easier for "the next guy".

You can purchase Perl Medic: Transforming Legacy Code from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

194 comments

  1. Re:Dupe? by databyss · · Score: 1

    and people say that /. has no standards...

    --
    Hmmm witty sig or funny sig? Maybe elitest techy sig!
  2. Re:Dupe? by Willis+Wasabi · · Score: 1

    or not, musta been somewhere else. I could swear it was /.

    Search first next time...

    --
    All true wisdom can be found in sigs.
  3. The thing about Perl... by Sheetrock · · Score: 3, Insightful
    While its ubiquitiousness and relative ease of use as far as banging together a CGI script in an hour goes, it does not seem designed for maintainability.

    Preventative and maintainance coding is difficult enough when a language has a particular idiom you can follow. Perl gives you an unparallelled freedom of expression and with it several confusingly different ways to achieve the same task.

    I used to be a believer, but now it seems Python is ready to take the yoke, at least with those of us who wonder how can you build a complex yet maintainable script without static typing.

    --

    Try not. Do or do not, there is no try.
    -- Dr. Spock, stardate 2822-3.




    1. Re:The thing about Perl... by smittyoneeach · · Score: 1
      I used to be a believer, but now it seems Python is ready to take the yoke, at least with those of us who wonder how can you build a complex yet maintainable script without static typing.
      Some kind of optional static typing is a recent Python design teapot-tempest, but Python is most definitely not statically checked as of this writing.
      Of course, how you edit really matters most...
      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    2. Re:The thing about Perl... by John+Bokma · · Score: 1

      maintainability is up to the programmer, not the language. If "Preventative" coding means defensive coding, it's wrong to begin with. Moreover, freedom doesn't mean you have to use every possible way. Skilled Perl programmers often know how to limit the number of ways. The major problem is that most people learned programming Perl by downloading a CGI script and added new functionality by trial and error. Most CGI scripts on the net are extremely badly written in the first place, so imagine the results of this "programming" (which often is installed on a server of a customer, or worse, is put on a webpage as open source). I doubt that many people learn Python that way. PHP on the other hand is often learned the same way. Comparing the quality of many PHP scripts out in the wild with many Perl CGI scripts in the wild give you a clear picture.

  4. Re:Nay by jargoone · · Score: 3, Informative

    Yeah. Because PHP is great at non-web applications.

  5. Comments to come: blah, Perl hard to read/maintain by Neil+Blender · · Score: 4, Funny

    s/shitty perl code/shitty code in any language/;

    You can inherit shit in any language.

  6. not just for legacy code by consumer · · Score: 5, Informative

    This is the best book I've ever read about how to write clear and maintainable Perl code. The advice is solid and up-to-date with discussions of perltidy, modern web techniques, etc. I would recommend this book to anyone who writes Perl, just as a style guide.

    1. Re:not just for legacy code by Anonymous Coward · · Score: 0

      write clear and maintainable Perl code

      Wha?

    2. Re:not just for legacy code by Hercynium · · Score: 3, Informative

      Hear, hear! I have had this book in my desktop library since i bought it eight months ago. While it's certainly too short to truly cover the topic completely, this book has remarkable depth, and is still quite easy to grok. You can read it cover-to-cover or flip around and always find some useful advice. Don't make the mistake of thinking this book is too short to be useful... It's filled with hints and links to more information. Heck, nowadays, all books should be filled with links and references; printed materials too often become obsolete too quickly!

      (Normally I'm a grammar/spelling nazi for myself... but I've been coding in PHP all day and I've lost the will to fight for correctness.)

      --
      I'm done with sigs. Sigs are lame.
  7. Using a new language is usually not an option by winkydink · · Score: 5, Insightful

    In most cases, refreshing an existing program will take less time than rewriting it in a diffferent language, as in both cases you need to have a firm understanding of what the program does before proceeding.

    In many corporate cases, you don't have the luxury of writing in any language you please and, even if you do, in most cases you'll have an uphill challenge convincing a PHB that rewriting from scratch in a new language is the better proposition.

    --

    "I'd rather be a lightning rod than a seismometer." -Ken Kesey

    1. Re:Using a new language is usually not an option by Anonymous Coward · · Score: 0

      Posted anonymously for a few reasons.

      I have just inherited a large and very well written Perl code base that does some serious cleaning up of highly crappy data (from hotel chains no less).

      Problem: it's slow. Mind-bogglingly slow. It's "compare this record with a million others and construct rules about what it could be before inserting into the database" kind of slow. It's so slow that the company can't in fact grow and get more hotels on board. It's so slow that rewriting the thing in C wouldn't help more than about 10% I guess.

      Now I have this stupid idea in my head that the algorithms could be done a lot better and that the program itself would be better in Common Lisp (if you need to argue about the choice of language, then Tango Sierra - it _is_ the right choice of language for this kind of project).

      Here's what I'd like to do: maintain the Perl (and optimise at least some of it to keep them happy) and secretly write a parallel system in CL and present them with it as a fait accompli after three months or so.

      Do y'all think I'm crazy? One word answers accepted.

    2. Re:Using a new language is usually not an option by Anonymous Coward · · Score: 0

      Go for it! If you fail - don't tell anyone. If you succeed - then you'll (hopefully) get a lot of respect.

    3. Re:Using a new language is usually not an option by dynamo · · Score: 1

      If it were well written, it wouldn't be so slow. It's not perl's fault.

    4. Re:Using a new language is usually not an option by synx · · Score: 1

      no.

      You can become the saviour. Just for gods sake don't tell anyone you're using lisp, or else you'll never get it done.

    5. Re:Using a new language is usually not an option by Anonymous Coward · · Score: 0

      I know it's not perl's fault - perl regexes are very fast, and naturally it does brilliantly as a CGI handler and text processor. And even I can read this guy's perl - use strict, -w, nice clean subset of features, no reliance on default variables, and so on.

      I just think that I'm missing something about the overall implementation - some kind of algorithmic "aha!" that often happens when you write bottom-up Lisp to sketch a large system.

      But your point is well taken, thanks. More investigation needed...

    6. Re:Using a new language is usually not an option by Anonymous Coward · · Score: 0

      Hmmm - good point. I'll use Steel Bank's compilation feature and deliver magic exes or something.

      In fact I won't even mention Lisp...

    7. Re:Using a new language is usually not an option by jallen02 · · Score: 1

      Honestly... there are so few problems that absolutely have to be solved in Lisp that I think you are just trying to let your inner geek come out. You don't need a particular software language to ferret out an "algorithmic aha!". You just need to anaylze the problem.

      You talk about some sort of linear searching and really slow performance. It could even be O(n^2) performance. I am willing to guess a little algorithm analysis and a little bit of creativity will yield data structures that can make the software run orders of a magnitude or two quicker.

      I love Lisp as much as the next geek, but really.. what you are talking about is just good ole algorithm and data structure design. First get a clear mental picture of the data and the data structures you will represent the data with to accomplish whatever data processing you need. Sounds like you could trade off some memory for processing speed and not be to bad off. Chances are good you don't need to compare each record to the million others ;)

      I say your not nuts. You just need to do sound analysis of the program. Just top down designing it in Lisp won't solve the problem any quicker than sitting there with a pencil and paper and puzzling it out. And its highly possible you could end up coding just 30-60 lines of code to take out the nastiest of the linear searching inside of a loop and completely solve the problem if. (Versus rewriting it from scratch at hundreds and hundreds of line of cost). I am making a lot of assumptions about your problem, but it doesn't sound like any sort of really difficult problem so I am asking about the more basic ideas here versus ask for more information.

      But hey.. who am I to stop someone from coding in Lisp?

      Jeremy

    8. Re:Using a new language is usually not an option by Anonymous Coward · · Score: 0

      Thanks for the feeback - much appreciated. The reason I'm looking at Lisp is because I'm in this for the long term: the current functionality is but a very small part of what will eventually be required.

  8. Use a real language. by Anonymous Coward · · Score: 0

    Perl, does in fact, run 4x slower than C. If your program requires speed and maintainability, then stick with a real compiled language. Anything else is a scripting language and should be used appropriately.

    1. Re:Use a real language. by Anonymous Coward · · Score: 0

      4x? Try multiplying that by 10 a few times, you stupid fucking retard.

    2. Re:Use a real language. by Camel+Pilot · · Score: 4, Insightful

      on what test? Take a fairly common task - word counting

      Perl 1.0 cpu time 11 lines of code.
      gcc 0.3 cpu time 182 lines of code.

      So i can distort reality also and say while C can sometimes be as fast as 3 times faster it will take 1700% more lines of code.

    3. Re:Use a real language. by Anonymous Coward · · Score: 0

      Clarification: That's java that runs 40x slower.

    4. Re:Use a real language. by Anonymous Coward · · Score: 0

      So i can distort reality also and say while C can sometimes be as fast as 3 times faster it will take 1700% more lines of code.

      I can distort things too by using a big number like 1700%. So what, you can do it in 1 or 2 lines in perl or 30 lines in C. Wow, that's huge.

      Try serious pattern matching. C can have 10000-100000 times the speed advantage of Perl. Sure it takes a hell of a lot more code, but if C takes 5 minutes to complete your search, Perl could take a year.

    5. Re:Use a real language. by Camel+Pilot · · Score: 1

      Give me an example where Perl 10000 or 100000 slower than perl. It doesn't exist.

      Since Rex-Exp is pattern matching from the benchmark link provided for test called Reg-Exp

      Perl 2.56 Cpu Lines of Code 24
      C Gcc 2.98 Cpu Lince of code 98

      gasp Perl is faster.

    6. Re:Use a real language. by mvdde_xh · · Score: 2, Insightful
      It may run slower than C in some cases. But you can crank out working perl script *much* faster than in C.

      Sometimes the developer's time is more important that the computer's time.

    7. Re:Use a real language. by qw(name) · · Score: 1

      We have a perl regex that is 80 lines line (one item per line). I get the willies just thinking about utilizing that kind of power in a C program.

      Also, for true speed increases in Perl, don't use the RegEx engine. Use hashes. That alone will speed you Perl program exponentially.

    8. Re:Use a real language. by Anonymous Coward · · Score: 1, Interesting
      Use hashes. That alone will speed you Perl program exponentially.

      On behalf of those of us who understand what this word means, I ask you to stop using it until you join us. (Hint: it doesn't mean "a lot".)

      Study some Big-Oh notation, or more generally asymptotic notation. You should at least know that:

      O(1) is constant time
      O(lg n) is logarithmic time
      O(n) is linear time
      O(n lg n) is...I don't think there's a name for it, but it goes here in the sequence
      O(n^2) is quadratic time
      O(n^c) is polynomial time (for any constant c, including the "1" or "2" that'd make it linear or quadratic time, above)
      O(2^n) is exponential time

      and be able to find an upper bound on your algorithm. It might not be the best upper bound (I could say an O(1) algorithm is O(n^2) and be right but not terribly informative) but you should at least be able to find one.

      You should also know that these same concepts can apply to the space your algorithm requires (in memory, on disk, whatever).

      If you don't have something in your program that takes O(2^n) time (and you probably don't), your program can't get exponentially faster. It doesn't make sense.

    9. Re:Use a real language. by Anonymous Coward · · Score: 0
      Eleven lines of code?

      <?php
      print substr_count("string"," ");
      ?>


      I count three. Remove the white space and you have one. I'm not "fluent" in Perl, but surely it has something similar (maybe not?).
    10. Re:Use a real language. by jcuervo · · Score: 1
      11 lines?!
      $w = 0;
      $w += split /\s+/, $_ while (<>);
      print $w, "\n";
      What were you doing in the other 8 lines?
      --
      Assume I was drunk when I posted this.
    11. Re:Use a real language. by Neil+Blender · · Score: 1

      3 lines?!

      print scalar split /\s+/, ;

    12. Re:Use a real language. by qw(name) · · Score: 1
      On behalf of those of us who understand what this word means, I ask you to stop using it until you join us.
      How about O(boy^whatever). When you learn how to recognize hyperbole you can join us (whoever we are).
    13. Re:Use a real language. by Anonymous Coward · · Score: 0

      Gah, forgot to preview

      print scalar split /\s+/, <>;

    14. Re:Use a real language. by Shin+Chan · · Score: 2, Interesting

      Let's see (just a real life thing I tested earlier today... so yes, before this article got published)

      Running a "BOT" on the MSN Messenger network. Sending a 300 meg ISO to it, memory only "shot up" by an "amazing" 100KB. Average speed on sending, 150KB/s (as good as it get's on my connection).

      Now we hook up another conversation. Response time is excellent, transfer is not suffering nor are other connections. Ping time is 0.0788 seconds (that is, me server perl app, so it has to pass 4 "pipes", 2 to my app, 2 back to me).

      CPU usage stayed below 5% all the time. . The script has been running for nearly 3 days now, too. I'm sure your C app can shave off an amazing 0.01 something seconds and minimize memory usage to maybe only half. Point remains, Perl isn't slow when well written :)

      --
      Proud owner of BOT2K3 [ bot2k3.net ]
    15. Re:Use a real language. by Anonymous Coward · · Score: 0

      Dude, precise technical terms are not a good place for hyperbole. "A bazillion times faster", sure. "Exponentially faster", no. Some things really are exponentially faster.

    16. Re:Use a real language. by jcuervo · · Score: 1
      That works for one line; mine does entire files. ;-)
      [520] cuervo@crossbone ~ $ head -n2 keysyms.h
      #define KS_nul 0x0000
      #define KS_Control_a 0x0001
      [521] cuervo@crossbone ~ $ perl -we 'print scalar(split /\s+/, <>), "\n"' keysyms.h
      Use of implicit split to @_ is deprecated at -e line 1.
      3
      I got bored, so I came up with a couple more ways to do it, but this was the only one-liner I came up with before I lost interest. Compressed, just to make it interesting.
      print"$x\r"while(defined($_=<>)&&($x+=split/\s+/,$ _));
      --
      Assume I was drunk when I posted this.
    17. Re:Use a real language. by Anonymous Coward · · Score: 0

      Quit being an asshole.

      And by asshole, I mean a contemptible, detestable person, not an actual anus. But you probably managed to figure that one out.

    18. Re:Use a real language. by Shin+Chan · · Score: 1

      print substr_count("string"," ") + 1;
      ?>

      e.g. "this is a test" --> 3 spaces, 4 words. :)

      --
      Proud owner of BOT2K3 [ bot2k3.net ]
    19. Re:Use a real language. by Anonymous Coward · · Score: 0

      "this is a\nbroken algorithm"

  9. No problem. by jspoon · · Score: 5, Funny
    More likely, though, the code will have so many warnings that the useful output is long gone in the stratosphere of your scroll buffer.

    When this happens, just write a Perl script to sort out the parts you need to know and print out a nice little summary.

  10. Re:Perl != maintainable by zardo · · Score: 1

    Ruby is replacing perl in my case, and I think that will develop into a trend. Ruby is a lot more like coding in perl.

  11. Re:Perl != maintainable by Shin+Chan · · Score: 1

    Maybe you should learn how to write maintainable Perl scripts/apps then. I too have used for nearly 2 years now and have never had a problem with maintainabillity of one of my scripts. Not even of those from the very beginning.

    --
    Proud owner of BOT2K3 [ bot2k3.net ]
  12. What dupe? by kclittle · · Score: 0, Offtopic

    What has /. come to? Preemtive "dupe flames"? :D

    --
    Generally, bash is superior to python in those environments where python is not installed.
    1. Re:What dupe? by kclittle · · Score: 1

      c/Preemtive/Preemptive/

      --
      Generally, bash is superior to python in those environments where python is not installed.
  13. Re:Nay by Shin+Chan · · Score: 2, Interesting

    PHP?! PHP?!?!

    Okay. Sure. PHP does give some advantages over Perl.. To lazy programmers that is. Really, PHP has over 3125 core functions, while Perl has "only" some 150. Include a module and whoop, some more functionallity, including only those things you need.

    Really, how often do you have to look up a PHP function's working (or even name, hence PHP isn't very consistant, something2something, something_to_something, somethingtosomething... the list goes on)? When I haven't worked with PHP for a while that starts to faint. Perl never does.

    Oh and, rewriting a map{} and grep{} is left as an exercise to the reader ;)

    --
    Proud owner of BOT2K3 [ bot2k3.net ]
  14. Maintainability of Perl code? by Sv-Manowar · · Score: 3, Insightful

    Cue the flood of 'Perl is hard to maintain/read' and counterflood of 'You can write hard to maintain/read code in any language' posts.

    I think it can be generally agreed that due to the TMTOWTDI philosophy behind Perl, there can be complications involved when inheriting code from others who use a different style and different approach. (Obviously due to the many ways any given task can be approached).

    One (common?) approach to dealing with this seems to be to use different languages such as Python or Ruby. Arguably, however, if more coders stuck to code style guidelines and used best practices instead of quick hacks, the problem would be minimal, or at least no worse than other scripting languages.

    1. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 0

      TMTOWTDI?

      PDYOA (Please Define Your Obscure Abbreviations)

    2. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 1, Insightful

      Perl is hard to maintain because:

      1) too much punctuation .. make things hard to read

      2) too much "magic" .. makes things hard to read

      3) too much scaffolding to do object-oriented programming .. makes things hard to read

      4) just a shitty data model .. why are there arrays AND arrayrefs? Why not just arrays? That means the programmer always has to make a decision between crisp readability (arrays) and performance/lack of aliasing issues (arrayrefs).

      5) shitty object model. Do you want to do some setup to your classes at load time? You have to do something like "__PACKAGE__->setup()".

      Really I have tried writing clear Perl code, but it's always "not quite there", there's always some little nit that has to be commented, explained, etc.

      Not until I did a big project in Ruby did I have any clue what I was missing. Just the sort_by method on arrays was a mind-blower.

      So if you want to keep believing that you can write maintainable code in Perl, go ahead. Just be aware there's an upper bound, that's baked directly into the language.

    3. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 0
    4. Re:Maintainability of Perl code? by kevin_conaway · · Score: 1

      Theres More Than One Way To Do It. Very common in the perl community. Its part of the perl ABCs

    5. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 0

      One (common?) approach to dealing with this seems to be to use different languages such as Python or Ruby

      You complain about one Slashdot cliché and then precede to commit the "you should use XXX language" cliché.

      Nice.

    6. Re:Maintainability of Perl code? by hondo77 · · Score: 1

      Really I have tried writing clear Perl code, but it's always "not quite there"...

      And you blame the language for that? How convenient.

      --
      I live ze unknown. I love ze unknown. I am ze unknown.
    7. Re:Maintainability of Perl code? by snorklewacker · · Score: 2, Interesting

      Not going to intersperse your points with mine, since I really hate that style, so I'll just go in order.

      1. No one will argue against perl having too much punctuation. It's a hell of a noisy language, and you can really play some perl golf with sigils if you try. Sometimes you even have to, but rarely.

      2. The "magic" also makes things easier to read. "open $file or die" anyone? Sure beats checking whether it returns nonzero, don't it?

      3. Then use one of the Class:: modules. Personally, I rather LIKE that I can have a subclass with a polymorphic constructor, which you can't really get with languages that hardwire the constructor. What the hell is a class factory? Don't need that idiom in perl.

      4. It only becomes insane when you start dealing with prototypes and @foo is suddenly an array and not a list. Otherwise this is idiom that anyone can get used to. Frankly, I find it a nitpick -- you want really shitty data models, pick on the insane "scalar" thing, where the string "0" is false in an if statement.

      5. This is actually just false. You use BEGIN for compile-time stuff and an import method for import-time semantics. Hard, eh?

      Perl 5 is over 10 years old, and showing its age in various ways, but it can still take criticism and even a lot of kicking gracefully. It's the language everyone loves to hate, but when rubber meets the road, it's what you find people using anyway. It's an inelegant crock, it's shell, sed, and awk duck-taped together, but it's exactly what people asked for.

      Spare me the bondage of enforced "elegance". If you want Java, you know where to find it.

      --
      I am no longer wasting my time with slashdot
    8. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 1, Funny

      Not going to intersperse your points with mine, since I really hate that style, so I'll just go in order.

      That's being a true Perl programmer. Never make it easy for someone to read your stuff.

    9. Re:Maintainability of Perl code? by Black+Perl · · Score: 2, Insightful

      I'd like to argue that Perl is very maintainable. Many studies show a correlation between LOC and number of defects. So the important thing is reducing the LOC written. The differences accountable to language syntax is negligable when you can reduce the amount of code you write by order(s) of magnitude. With Perl, you have CPAN (http://search.cpan.org/), a repository of pre-written, tested code, the vast majority of which are classes ready to use in object-oriented fashion. Now, I'm not going to say that Perl's OO syntax is anything but inelegant, but it works. What is elegant is the way CPAN works. I won't go into that here, but it does allow you to decrease by orders of magnitude the amount of code you have to write. There are great solutions for all kinds of things, such as object-relational mapping (point Class::DBI at your database, and you instantly have get/set methods to update your tables) and powerful templating (http://template-toolkit.org/), just to name a couple. There are 4000+ other examples there.

      As an example of reducing lines of code, here's an article on writing a database-driven web application in 18 lines of code, and a similar article here.

      But this doesn't apply to just database or web frameworks. Thanks to CPAN, this applies to anything you set out to do. CPAN modules (in general; there are exceptions) are encapsulated best practices, well tested, and a major productivity booster. And, they drastically reduce the amount of code you need to write, making your code more maintainable.

      --
      bp
    10. Re:Maintainability of Perl code? by myowntrueself · · Score: 1

      TMTOWTDI?

      That doesn't spell "Don't do what I say, do what Larry thinks I mean"

      --
      In the free world the media isn't government run; the government is media run.
    11. Re:Maintainability of Perl code? by synx · · Score: 1

      re #2:

      IF the only magic I had do deal with was 'open or die' I would be jumping with joy. There is plenty of other magic, for example the whole context changes meaning of operators significantly.

      I value consistency in a language... Larry's whole 'postmodern' thing aside.

    12. Re:Maintainability of Perl code? by Wdomburg · · Score: 0, Troll

      "MOD THIS UP INSIGHTFUL!!!! by Anonymous Coward Wednesday February 30, @09:34AM"

      That is so incredibly lame, I can't even find the words.

    13. Re:Maintainability of Perl code? by snorklewacker · · Score: 1

      The true spirit of #perl is also not to suffer idiots or bend over backwards for those who just won't use their brains.

      Sorry you had so much trouble with the comprehension.

      --
      I am no longer wasting my time with slashdot
    14. Re:Maintainability of Perl code? by jenesuispasgoth · · Score: 1

      ok.

      Tell me, between those two programs (that do exactly the same thing), which is easier to read ?
      (I had a mycat.c file to show too, but it didn't pass the filters ...)

      /**** MyCat.java ****/
      package net.beuarh.lasher;

      import java.io.BufferedReader;
      import java.io.File;
      import java.io.IOException;
      import java.io.FileNotFoundException;
      import java.io.FileReader;

      public class MyCat {
      public static void main(String[] args) {
      if (args.length != 1) {
      System.err.println("Usage : " + MyCat.class + " <file_to_cat>");
      System.exit(0);
      }

      try {
      FileReader fr = new FileReader(new File(args[0]));
      BufferedReader br = new BufferedReader(fr);
      for (String in = br.readLine(); in != null; in = br.readLine())
      System.out.println(in);
      } catch (FileNotFoundException fnfe) {
      System.err.println(fnfe) ; System.exit(0) ;
      } catch (IOException ioe) {
      System.err.println(ioe); System.exit(0);
      }
      }
      }
      /**** MyCat.java ****/

      #---- mycat.pl ----#
      #!/usr/bin/perl

      use strict;
      use warnings;

      print STDERR "usage : $0 <file_to_cat>\n" and exit unless($ARGV[0]);

      open(IN, "<$ARGV[0]") || die "$! $@";
      print while (<IN>);
      close(IN) || die "$! $@";
      #---- mycat.pl ----#

    15. Re:Maintainability of Perl code? by jafac · · Score: 1

      It's not only the TMTOWTDI that makes Perl inherently more "abuseable" than most other languages. It's the "default variable" ($_, etc) thing, where actually using the variable in syntax is optional.

      These features are really, really, nice to have, when you're hacking, or writing up quick little scripts to do some administrative task. It's nice to have the option of brevity when you have a high level of comfort with the language. But these options ARE a detriment to maintaining stylistic conformity.

      The point of a computer language is to provide a way to express a program's logic in a human-readable language, that can be unambiguously interpreted by both the human, and the machine - to be converted into instructions for the machine to follow. The TMTOWTDI principle of Perl, along with the inherent syntactic flexibility, means that ambiguity is more likely to happen on the human side of the equation. You're at the mercy of the habits of the coder, and the Perl expertise of whomever reviews or maintains that code. Stylistic Conformity pares down that likelihood.

      --

      These are my friends, See how they glisten. See this one shine, how he smiles in the light.
    16. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 0

      If you don't know Tim Toady, why the hell are you reading and commenting on a review of a Perl book?

    17. Re:Maintainability of Perl code? by Anonymous Coward · · Score: 0

      I'm curious to know what you expect $@ (aka $EVAL_ERROR) will hold after an open/close failure. You aren't helping the Perl argument by posting cargo cult code.

    18. Re:Maintainability of Perl code? by jenesuispasgoth · · Score: 1

      ok, my mistake... Then replace the first die with
      die "couldn't open the file $ARGV[0]" and the second with "couldn't close ..."
      what else ?
      My point was that readability is very subjective a topic. I know of people who read C and C++ idioms like I read Dilbert. But the big mistake people make is that they expect Perl to be a C-like language. This is not so. Perl is far richer : of course one can do C-like programming, but then this would really shorten one's possibilities with the language. This is really a languange that should be read aloud ! :-) (I hope I am clear enough now...)

    19. Re:Maintainability of Perl code? by Intron · · Score: 1

      "I know of people who read C and C++ idioms like I read Dilbert."

      I see a lot of C++ code that makes me laugh out loud, too.

      --
      Intron: the portion of DNA which expresses nothing useful.
  15. Re:Nay by RangerRick98 · · Score: 1

    Actually, there are some things that I have written commandline PHP scripts to do. It's not often, but sometimes PHP is just the best tool for the job. Other times it's Perl. Other times it's a shell script, or C, or Java, or whatever. It all depends on what you're used to, what you're skilled at, and what problem you're trying to solve.

    --
    "You're older than you've ever been, and now you're even older."
  16. nice perl is possible by hey · · Score: 4, Insightful
    For example:
    sub main()
    {
    init();
    work();
    cleanup();
    }
    1. Re:nice perl is possible by Anonymous Coward · · Score: 1, Funny

      I guess you can write COBOL in Perl too!

    2. Re:nice perl is possible by Not+The+Real+Me · · Score: 1

      Sorry dude, but that is the c style of writing code on unix/linux systems.

      Perl has always been a write only language that is only readable by the author. I've lost track of the number of modules on cpan.org that are stuck at version y.xx and have not been updated in a long time and only work with versions of Perl *OLDER* than 5.3 because no one is able to correct the module to work with perl v5.3+

    3. Re:nice perl is possible by abulafia · · Score: 5, Insightful
      Perl has always been a write only language that is only readable by the author.

      Funny. I'm supporting an app initially written about 8 years ago entirely in perl. It is about 80K lines. Outputs PDF by writing postscript directly (don't ask, but there are reasons for this). I came in about 3 years ago on it. None of the original developers (nor the original company) are around. Somehow, we still maintain an improve it. Maybe it isn't such a write-only language.

      I've lost track of the number of modules on cpan.org that are stuck at version y.xx and have not been updated in a long time and only work with versions of Perl *OLDER* than 5.3 because no one is able to correct the module to work with perl v5.3+

      I assume you've also lost count of all the C, Fortran, PHP, Pascal and Java projects that don't work in modern environments, too.

      Bottom line: If you can write good code in any language, you can write quality perl. Bad perl is easier to write than some languages, and I think that is a sign of utility. And don't get me started on some of the _bloody fucking awful_ Java I'm also supporting...

      --
      I forget what 8 was for.
    4. Re:nice perl is possible by Anonymous Coward · · Score: 1, Insightful

      You didn't just go there! You did!

      I have just inherited code that resembles just that: function calls with no arguments. They don't use strict, so all variables are global. The subroutines are little more than macros, and you have to refresh yourself on what variables are affected each time you see a function call.

      I think Perl's major flaws stem from not having "use strict" on by default. If it doesn't need strict, it can probably work just fine in shell script!

    5. Re:nice perl is possible by John+Bokma · · Score: 1
      Bottom line: If you can write good code in any language, you can write quality perl.
      Amen to that. People make shitty code, not programming languages. If you can't use a paint brush, don't blame your lack of skills on the hairs of the paint brush, or that there are so many to pick from, or that there is so much choice in paint. With painting there are often many ways to do a thing, to the beginner. An artist however, doesn't see those many ways ;-)
    6. Re:nice perl is possible by Intron · · Score: 1

      I see lots of modules on cpan that have been superceded by better-written modules, or are obsolete because they duplicate functionality that's now in the core. For example, Tk::fileselect is superceded by better modules getOpenFile and getSaveFile Can you name a useful module that is "stuck" and does not have a replacement?

      --
      Intron: the portion of DNA which expresses nothing useful.
  17. Maintainability by XanC · · Score: 4, Insightful
    A lot of posts are complaining about Perl being unmaintainable, and suited to banging out a quick script in a half hour but not for anything more complex than that.

    Baloney. The advantage of Perl is that you have the option to write maintainably if you want to!

    If I just need a quick solution to a problem, I can very quickly write gibberish that does the job and then forget about it.

    If I'm writing a big app which someone will inherit from me, I can avoid confusing constructs for something easier to follow. I can pass variables in Perl style, C-style, I can use objects if I want. Whatever I think will be most maintainable for somebody else.

    Just because you can write gibberish in Perl doesn't mean you can't write good stuff too.

    1. Re:Maintainability by Anonymous Coward · · Score: 1, Insightful

      Many big, inherited apps started life as quick n' dirty 'never gonna touch this again' hacks... I am tempted to say most of them do. Many large apps have sections written by less experienced programmers and/or someone who was under the gun.

  18. The solution is simple by Anonymous Coward · · Score: 0, Interesting

    if self.sanity_questionable?
    raise "I'm waiting for Perl 6 you insensitive clod!"
    end

    scripts.select { |s| s.written_in? :perl }.each do |script|
    rewriter = Rewriter.new(:perl, :ruby)
    rewriter.transform script
    end

    assert scripts.all? { |s| s.language.clean_object_model? }
    assert scripts.all? { |s| s.language.easy_on_the_eyes? }
    assert scripts.all? { |s| s.concise? && s.readable? }
    assert scripts.all? { |s| s.maintainable? }

    self.productivity *= 2

    fellow_programmers.each { |w| self.evangelize_language w => :ruby }

    1. Re:The solution is simple by Anonymous Coward · · Score: 0

      If you want to see any opposing opinions on something dear to /.r's hearts (esp a programming language) then you have to search the comments at the -1 "Troll" level.

    2. Re:The solution is simple by Anonymous Coward · · Score: 0

      If you want to read any opinions opposing something dear to slashdotter's hearts (esp programming languages) you have to read the comments at the -1 "Troll" level.

  19. Re:Nay by WWWWolf · · Score: 3, Funny

    Rrrrrrgh. People who suggest Python as Perl replacement are bonkers. People who suggest PHP instead of Perl or Python are clearly insane.

    My honest opinion is Ruby beats either as a Perl replacement - Ruby retains a lot of Perl ideas while succeeding in providing a very clean syntax.

    And people these days can't even do language trolls properly. Let me try. Ahem. hm. hm. hm. (climbs to mountaintop and shouts:) "We should rewrite the Perl programs in Common Lisp!" (dramatic echo) (gasping heard all over the world) (climbs down) There, much better. Now let's rewrite the apps in both common lisp and ruby! Before Perl 6 ships and we need to rewrite everything again, of course! Go on, hurry!

  20. Re:Chapter 1: Installing Python by Nohea · · Score: 1

    I have been a "Perl Medic", and re-wrote old perl with new perl - much better.

    Perl gives you enough rope to hang yourself. If you are disciplined, it is powerful enough to do anything cleanly, quickly, and efficiently.

  21. thanks for straightening me out. by Anonymous Coward · · Score: 0

    I think I'll just crank up my written in perl browser, and use my written in perl email client on my written in perl operating system and use my written in perl command line to run "wc" written in perl.

    Scripting languages are obviously the solution for all problems, including fast word counting !!!!

    1. Re:thanks for straightening me out. by Camel+Pilot · · Score: 2, Interesting

      You are the only one proposing the use of perl for everthing. Ever heard of a strawman, nice try but it is a weak attempt to prove whatever your point is.

      Are compiled languages faster than script style languges? Yes, typically. Are compiled languages always the best approach. No.

      Lets take a real world example. Recently I need to take a stream of data that was interleaved two byte time series. I had to demultiplex it and reverse the endian. I prototyped in perl and wrote the service version in C. Performance difference between C and Perl was 12%. Development time, even with the prototype was difference was more than double and with 4 times the code to maintain.

      I have similar stats with C versus Matlab for numerical processing.

    2. Re:thanks for straightening me out. by asavage · · Score: 1

      A while ago there was a story on slashdot about different algorithms for calulating pi. I wrote one of them in 10-12 lines of MATLAB that took him about 40-50 lines of c. My code was also 10x more readable. He gave run times that were within 20% of mine on similar architecture.

  22. Re:Nay by shobadobs · · Score: 4, Insightful

    PHP? Are you kidding me? There is nothing worse than PHP. PHP looks strewn together without thought. Just consider the system by which PHP's built-in functions are named. Except that there is no such system; the names follow all sorts of different casing rules.

    PHP was made by taking a cute language for embedding a broken imitation of Perl-esque syntax in-between HTML and extending it with bajillions of functions that badly needed to be namespaced. It never provided anything useful that Perl couldn't, except that it made newbies comfortable by making them feel like they're in "HTML land" instead of "Programming language land."

  23. Re:Comments to come: blah, Perl hard to read/maint by Uruk · · Score: 4, Insightful

    Yeah, but perl makes it easier to write shit. I happen to love perl and use it all the time, but I also have to be very disciplined about the aspects and particularly syntax conventions of the language that I use, in order to write readable perl. Just because you can write:

    do { thirty(); things(); in(); a(); list(); unformatted(); } if($foo);

    Doesn't mean that you should.

    One of the brilliant aspects of perl is that it allows you to write code like you think about code. Well doesn't that presuppose that other people are going to think about code the same way you do? Ooops.

    Books and books have been written on the need for code formatting, syntax, and variable naming conventions in languages that are twice as rigorous and disciplined as perl. In perl, the need is double.

    So I guess what I'm saying is that although shitty code is shitty code in any language, perl provides the possibility for a certain depth and richness of shit that just isn't accomodated in other languages. Kudos to the authors for addressing what is a real problem with a powerful and widely used programming language.

    --
    -- Truth goes out the door when rumor comes innuendo. -- Groucho Marx
  24. Re:Comments to come: blah, Perl hard to read/maint by Coryoth · · Score: 3, Insightful

    s/shitty perl code/shitty code in any language/;

    You can inherit shit in any language.


    That is true, but perl does provide easy ways to write sloppy or unmaintainable code. That's not necessarily a bad thing, because it is exactly that looseness that makes perl a very fast language to develop quick scripts in - there aren't anywhere near as many hoops to jump through and TIMTOWTDI makes it very easy to just write whatever you're thinking. For the niche of a language that lets you knock together something to do the job quickly perl is fine.

    If you want anything maintainable you need to forget all of that and make use strict and use warnings mandatory, and enforce some coding style standards. That can be done, and if you do that it is easy enough to write maintainable perl - it's just that you can't expect the language to help you with it much: you have to enforce and police the standards yourself.

    Jedidiah.

  25. no perl scripts should forget... by Sebastopol · · Score: 1


    #!perl -w
    use strict

    Those are the two guidelines required by our methodology.

    --
    https://www.accountkiller.com/removal-requested
    1. Re:no perl scripts should forget... by Anonymous Coward · · Score: 1, Insightful

      Where I work, use of $_ in any form is punishable by death. If you use it in the implied form, you get tortured first.

    2. Re:no perl scripts should forget... by Sebastopol · · Score: 1

      implied $_ has a five line limit. beyond that, out comes the wet-noodle whacker. ;-)

      --
      https://www.accountkiller.com/removal-requested
    3. Re:no perl scripts should forget... by Anonymous Coward · · Score: 0

      There used to exceptions, but they got stretched. So it was banned completely. I have learned that Perl coding standards need to be more rigorously enforced and more strict than coding standards in other languages.

    4. Re:no perl scripts should forget... by Anonymous Coward · · Score: 0

      did you actually try what you post? using #! without a path doesn't work. either specify the complete path like #!/usr/pkg/bin/perl or use #!/usr/bin/env perl to inherit $PATH.

    5. Re:no perl scripts should forget... by merlyn · · Score: 1
      So, you gave up grep and map? How sad.

      After all, you can't use them without $_.

      And defaulting regex to $_ is a very natural thing to do.

      I think a rule like this is like saying "Don't shift the car out of first gear! Higher gears kill!". That's not responsible. The responsible thing to do is to create guidelines for clarity. Banishing $_ is not one of them in any sane Perl shop.

    6. Re:no perl scripts should forget... by Neil+Blender · · Score: 1

      Ok, so we do use it with grep. We frown on map because it can lead to resource hogging if you

      my @results = map { }
      map { }
      map { } @a_very_big_array;

      (which can be hard to deciper as well as inefficient speed wise when compared to other loops)

      Also, if you have a series of regexes, it's nice to have some clue what you are searching through once the assignment to $_ is off the page.

      As I said here, I think for serious projects, you have to really strict with guidelines when using perl for large projects. If it's just some personal script, do what ever you want. But I am talking about two hundred thousand lines and developers of very different skill levels. Control and consistency is very important.

    7. Re:no perl scripts should forget... by Anonymous Coward · · Score: 0
      Where I work, use of $_ in any form is punishable by death. If you use it in the implied form, you get tortured first.


      $_ is built-in to make life easier, not harder.
      while (<>) {chomp; push @a, $_;}
      is easier than
      while (defined($_ = <>)) {chomp $_; push @a, $_;}
      and just as readable.

      It's a part of the language for a reason. Look at -p and -n.
    8. Re:no perl scripts should forget... by Anonymous Coward · · Score: 0
      Yes, but this is faster, easier, and more readable without once mentioning $_ :
      @a = <>;
      chomp @a;

      Look at perldoc -f chomp

      And while I wouldn't mind maintaining code that does things like chomp(@a = <>); I can understand why a programming house would want to ban such constructs more than I can understand why they would ban $_ or other "magic." There's no reason to use Perl if you're just going to tiptoe around all the Perl idioms.
    9. Re:no perl scripts should forget... by John+Bokma · · Score: 1

      -w should be replaced with: use warnings; Also, personally I prefer to use the full path to (a (symbolic) link to) Perl.

    10. Re:no perl scripts should forget... by John+Bokma · · Score: 1

      That's just plain stupid. Any style guide with limiting rules as given above is severly flawed.

    11. Re:no perl scripts should forget... by John+Bokma · · Score: 1
      A programmer who uses map {} map {} map {} has more problems than just understanding $_ If your regex stuff goes "off the page"... I really hope I don't have to maintain that code (e.g. I read it as 100+ regexps, not one big regexp). Moreover:
      for ( $string ) {

      s/.../.../...
      :
      :
      :
      s/.../.../...
      }
      makes code only more readable.
    12. Re:no perl scripts should forget... by Neil+Blender · · Score: 1

      If your regex stuff goes "off the page"... I really hope I don't have to maintain that code (e.g. I read it as 100+ regexps, not one big regexp).

      First off, 'off the page' can be 40-50 lines. At most, that's 5 nicely formatted regexes and resulting operations, not 100+. That is hardly an unreasonable number. If you can have one page open with 100 regexes visible, well, I don't want to maintain your code either.

      Second, I have to deal with public domain files that I have no control over the formatting. For example, NCBI Unigene files use '//' as a record delimiter. Each record can contain a dozen different types of information for a single gene and can go on for hundreds of lines. One record could be 3 lines and contain only 3 peices of information, the next record could contain twenty or a hundred times as much data. A single line of data (out of a record that could be hundreds of lines) might contain anywhere from 1 to 50 more pieces of information, some uniformly delimited, some not.

      As I said, I have no control of the format but I still need to parse it. This can easily require 10 or more regexes and what ever you need to do with the data per record. This is only one example. I have to deal with all kinds of wacky formats.

      As far as the map map map example, that's exactly why it's frowned on. It's not a good idea to do it and it's exactly what leads to unreadable code - trying to perform 50 operations on a set of data in 5 lines just because you can and it looks cool (to you, the only person who can understand it.) No one here is going to get chewed out for writing:

      my %hash = map { $_, 1 } @array;

      As I said earlier, I work on a very large number of lines of Perl. Any code that follows our guidelines is eminently readable. Most of the code that doesn't, isn't. And that's not just me talking, it's when new developers join the team. Large scale Perl apps probably require the most discipline when it comes to coding guidelines. Otherwise, what everyone here says about Perl not being maintainable is absolutely true.

  26. Perl is a write-only language by mi · · Score: 1
    Sorry, can't resist...

    For other languages there is -Wall -Werror. On a better OS use ${BDECFLAGS} instead of -Wall :-)

    --
    In Soviet Washington the swamp drains you.
    1. Re:Perl is a write-only language by David+Gould · · Score: 1


      For other languages there is -Wall -Werror.

      We're talking about Perl here -- what has Wall got to do with it?

      --
      David Gould
      main(i){putchar(340056100>>(i-1)*5&31|!!(i<6)<< 6)&&main(++i);}
    2. Re:Perl is a write-only language by Anonymous Coward · · Score: 0
      For other languages there is -Wall -Werror.

      I don't really get what your point is. If you are saying that there is not a way to enable all warnings in Perl, that's not true. You just do use warnings; at the top of your module (or other scope), and warnings are on. You can also make all warnings fatal if you'd like (just in your example) by doing use warnings FATAL => 'all'; instead of just use warnings;.

      A nice little feature of having this as a language construct (basically a pragma) instead of putting it as a compiler switch is that you can turn it on and off within the source file as necessary. For example, suppose you start maintaining some crappy code that was written without warnings. You'll eventually be cleaning it up, but for now you just need to add a few functions. With a lexically-scoped warning facility like Perl has, you can just turn warnings on within the new functions you write, allowing you to start off right with the new code and preventing you from having to choose to fix the old code or leave warnings off on the new.

      If you want to go a step further (than you can go in C, etc.), then you can add use strict;, which prevents you from accessing global variables without special extra syntax to make it clear you really intend to touch a global variable.

    3. Re:Perl is a write-only language by Zarf · · Score: 1

      We're talking about Perl here -- what has Wall got to do with it?

      Perl has a Wall.
      Larry Wall.


      or you can do "perl -cw" for compile and warn... because you can compile perl if you really want to.

      --
      [signature]
    4. Re:Perl is a write-only language by David+Gould · · Score: 1

      We're talking about Perl here -- what has Wall got to do with it?
      Perl has a Wall.
      Larry Wall.


      Ah, you've heard of him. Good. I'd assume this means you got my joke. I'm glad it wasn't too subtle.

      --
      David Gould
      main(i){putchar(340056100>>(i-1)*5&31|!!(i<6)<< 6)&&main(++i);}
  27. Dear Medic - Visit Perl6 project, CODE BLUE by Anonymous Coward · · Score: 0

    Longest pregnancy every, since 2001.

  28. He speaketh the truth by Anonymous Coward · · Score: 1, Interesting

    Actually I had a project that did exactly this at a major financial company. I had to convert their old Perl scripts into Unix scripts because the manager was sick of them breaking when new Perl versions came out.

    1. Re:He speaketh the truth by Anonymous Coward · · Score: 0

      "Unix scripts"? I hear those are more maintainable than those "non-Unix scripts".

  29. Re:Nay by Anonymous Coward · · Score: 0

    Typical thing for a PHP user to say. You show that PHP is the language for bashers and those who can't grok other languages.

    ANY language is only as maintainable as the author of the program/script makes it. You can either do things in an elegant way, or write complete crap.

    On the PHP front.. I have yet to find a project where it is a better choice than Perl. Then again, usually a Swiss Army Knife is more useful than an empty canteen.

  30. Re:I'll get marked as a Troll for saying this... by Anonymous Coward · · Score: 0

    "I'll get marked as a Troll for saying this..."

    Be careful what you wish for

  31. Re:Perl != maintainable by Anonymous Coward · · Score: 2, Funny

    Ruby is a lot more like coding in perl.

    Than coding in what? Perl?!?

  32. Not just the naming of functions by Anonymous Coward · · Score: 1

    but the fact that some alter their argument in-place, others return a value...and no rhyme or reason to this. php is the ultimate toy that survives only by virtue of the fact that it is easy to install

  33. Re:Pamela Jones EXPOSED by Anonymous Coward · · Score: 0

    What the hell are you talking about and why should we care?

  34. Re:Nay by Anonymous Coward · · Score: 0

    The lack of namespaces and the inconsistent naming conventions can certainly be a problem, albeit not insurmountable. The price is a slightly increased learning curve but the PHP manual at php.net is a very quick way to answer questions one may have while coding. For example, you can do php.net/explode or php.net/strings and it'll take you to the proper pages. It's an example of documentation done right and while it does not address the issues you brought up, it does make them more bearable. Towards more modularized code, PEAR aims to provide something like CPAN does for Perl. It's nowhere near as large and mature yet, but it's growing up.

    If you're going to attack PHP, I'd suggest its more unsavory aspects like register_globals (thankfully defaulting to off in official PHP but many hosting providers turn it back on for compatibility with scripts that assume it) or magic_quotes_gpc (protects newbies from themselves but means good PHP coders must do special checks with get_magic_quotes_gpc() and stripslashes() if they want to portably obtain the raw data the user entered).

    Though I don't know very much Perl at all, it looks like map{} can be done with array_map. For grep{} with regular expressions, there's preg_grep and for the general case, array_filter.

  35. Re:Nay by killjoe · · Score: 1

    The IT industry is stuck in a loop. Every few years it tries to re-invent lisp, smalltalk and unix each time coming up with something that ends up being a mutated ugly hack.

    The latest attempt at that is ruby. Ruby is great fun and a neat language but honestly it's just an attempt to rewrite smalltalk in a perl idiom.

    --
    evil is as evil does
  36. posting oddity by Anonymous Coward · · Score: 0

    Out of curiosity, how come this posting lists the body byte count on the /. home page and the other postings don't?

  37. If you liked Peter's book, attend Peter's workshop by TomDLux · · Score: 2, Informative

    I agree, perl medic is a great book, influential in encouraging and developing good habits.



    Peter will be speaking, though not on the same topic, at YAPC:2005, June 27, 28, 29 in Toronto. There's a whole day's worth of workshops on perl6, including PUGS, most of a day on testing, as well as threads on DBI, CGI, and lots of other workshops. Register now! At $85US for registration, it's the best bargain you'll find this year.


    If you are planning to attend, Book your hotel room soon. The host hotel is only guaranteeing room availability till next weekend. There's a huge conference coming to Toronto a few days after YAPC, so the hotel wants to start making rooms available for early arrivals. Not that all the rooms will disappear the first day, but you wouldn't want to be disappointed, would you?



  38. Re:Nay by Shin+Chan · · Score: 1

    Though I don't know very much Perl at all, it looks like map{} can be done with array_map. For grep{} with regular expressions, there's preg_grep and for the general case, array_filter.i

    array_map is great, but requires an extra function. map{} can handle pretty much any perl code instantly, without any extra subs or other weird constructs. While it's not a "real" problem, I am annoyed at PHP for the fact that I have to write a whole function for every simple map I want to perform, whereas perl can do them in a line. For larger projects, you might even want to create a whole file filled with just those functions.

    preg_grep is great, too.. But lacks code support. For example, one could use functions, or any other expression that returns something (or nothing, undef) in Perl, whereas preg_grep only does regular expressions. array_filter is great too, but again requires additional functions.

    This also immediatly shows the problem with PHP: Why does it require a gazillion functions for a couple of tasks that only one function could quite well accomodate? IMHO, this is mainly the reason for the "core bloatness" of PHP; the PHP developers have created a function for pretty much every simple task (and a whole lot of functions so obscure you will probably never will be able to use).

    For example, you can do php.net/explode or php.net/strings and it'll take you to the proper pages. It's an example of documentation done right and while it does not address the issues you brought up, it does make them more bearable

    As for the documentation, yes, I love the way PHP has set it up. Perl's manpages are nice, but still harder to read and slower to access. The php.net/function redirect is a very nice idea, indeed :)

    On a sidenote, I still use PHP frequently when creating simple websites that don't need the power of Perl or need to quickly done. PHP is great for starters, but eventually you will want to try something else.

    --
    Proud owner of BOT2K3 [ bot2k3.net ]
  39. Re:Nay by value_added · · Score: 2

    PHP was made by taking a cute language for embedding a broken imitation of Perl-esque syntax in-between HTML and extending it with bajillions of functions that badly needed to be namespaced. It never provided anything useful that Perl couldn't, except that it made newbies comfortable by making them feel like they're in "HTML land" instead of "Programming language land."

    I'll requote as I share the same opinion. In fact, I'd offer the argument that contrary to the "right tool for the job" advice that gets bandied about so frequently, if you write a lot of code in Perl, it's often more efficient to keep writing code in Perl, as there's very few areas where Perl doesn't shine.

    My personal opinions aside, I wonder how you would explain the widespread and seemingly increasing usage (and popularity) of PHP?

  40. I don't need a medic... by HomerJayS · · Score: 2, Funny

    Some of the code I've been forced to maintain needed Dr Kevorkian.

  41. Don't forget by Anonymous Coward · · Score: 0

    self.profit!

  42. Maintainability vs. Extensibility by emil · · Score: 0

    As explained above, many perl programs are no longer maintainable because of the extensibility of the language. As some perl modules rise in popularity, some fall - an example is the old LDAP library mentioned above that is no longer usable on new perl versions.

    For quick hacks, if it can be done with awk, I will do so. If it requires date processing, I will use gawk. I am not above shelling out to ldapsearch from awk because I will have to maintain fewer complex package installations.

    I will only fall back to perl when I need access to system calls or other facilities that the more primitive UNIX tools do not provide (and I am not willing to write the utility in C).

    I do this because I like easy portability. Perl's extensibility precludes this approach.

  43. So you wrote in "C" for speed afterall? by Anonymous Coward · · Score: 0

    no comment.

  44. Hi Sheetrock by Anonymous Coward · · Score: 0

    While Perl has gotten a bit of a bad rap because it's a disaster of a language, what kind of future do you envision for efforts to improve it, like Python?

  45. Re:Perl != maintainable by qw(name) · · Score: 1

    Oh crap! A recursive discussion!

  46. Re:Nay by Just+Some+Guy · · Score: 4, Insightful
    My favorite bit of PHP idiocy is mysql_query() versus pg_query(). Given that the functions are basically identical except for the databases they access:
    1. Why is the first's prototype:
      resource mysql_query ( string query [, resource link_identifier] )
      while the second has its arguments reversed:
      resource pg_query ( resource connection, string query )
      ?
    2. Why is "mysql" spelled out, but "postgresql" or even "pgsql" abbreviated to just "pg"?

    I hate the language for its utter lack of consistency. People talk about how great the php.net documentation is but I think they have the causality reversed: those docs have to be excellent or the language would be unnavigable. I have no desire to remember 3500 core language functions with similar (but inconsistent) naming systems and a randomized argument list. Seriously, what were they thinking?

    I don't think PHP is inherently bad, but the current implementation certainly is.

    --
    Dewey, what part of this looks like authorities should be involved?
  47. Re:Nay by fastduke · · Score: 1

    I've used both and love both. Perl was first then php. PHP is very well suited for what it is, and perl just speaks for itself. But I would have to say that newbs that use php don't really know what php is... They mix it up with Javascript all the time.

    --
    Fastduke :0)
  48. Re:Nay by qw(name) · · Score: 1
    As for the documentation, yes, I love the way PHP has set it up. Perl's manpages are nice, but still harder to read and slower to access. The php.net/function redirect is a very nice idea, indeed :)
    That's the one thing Perl needs to improve. Also, the php.net/function website allows for users to offer lessons learned while using a particular function. It would be sooooooooo nice to have a Perl equivalent. Sooooooooooooooo nice.
  49. Re:Nay by qw(name) · · Score: 1

    You do realize that PHP started out as a Perl module don't you? Ever hear of Personal Home Page?

  50. Re:Comments to come: blah, Perl hard to read/maint by Anonymous Coward · · Score: 0

    Solution to shitty Perl Code:

    Python.

    I've used both commercially - give me Python anyday.

  51. TCL by Anonymous Coward · · Score: 0

    You infidels.

  52. Re:Perl != maintainable by Anonymous Coward · · Score: 0

    I too have used for nearly 2 years now and have never had a problem with maintainabillity of one of my scripts.

    Yes yes, but how easy would it be for someone else to maintain/update your code?

  53. Yep. Strictly typed languages help by Billly+Gates · · Score: 0

    Ask any VB developer about the 'Option explicit declaration' (I think thats the name? Its been years since I touched it)?

    It forces the compiler to treat code without explicit declarations of types to be treated as errors. It also prevents undeclared variables from being used due to spelling errors.

    For example in C++ you have to do
    int test1 =0 or
    int test1

    before you can use it in code. Earlier versions of C did not do this and created alot of hassles.

    Also many gnu C++ programs were not that well written before the even of gcc 3.x which treated some warnings as errors. It was a pain but it improved alot of programs as a result.

    Many developers are jr level guys and sometimes system administrators writing scripts. Not everyone can write good code and no one can do it wihtout practice. Strictly typed languages help because it forces everyone to follow a standard.

    As you can tell I am not a big fan of perl and prefer python or tcsh for scripting. :-)

    1. Re:Yep. Strictly typed languages help by idontgno · · Score: 1
      Ask any VB developer about the 'Option explicit declaration' (I think thats the name? Its been years since I touched it)?

      It forces the compiler to treat code without explicit declarations of types to be treated as errors. It also prevents undeclared variables from being used due to spelling errors.

      use strict qw(vars);
      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    2. Re:Yep. Strictly typed languages help by Guido+von+Guido · · Score: 1
      Why stop with just the vars? I think it makes more sense just to "use strict" until those rare occasions when you need to turn something off.

      If I recall correctly (and as you would expect) the book discusses using strict.

    3. Re:Yep. Strictly typed languages help by idontgno · · Score: 1
      True. In practice, if I'm using strict, I use it without qualifiers. In this specific case, however, I was just pointing out the particular Perl answer to gp's "strong typing" issue.

      "strict refs" sometimes bites me in old code that I've inherited and don't have time or permission to rewrite, though.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
  54. Re:Perl != maintainable by Anonymous Coward · · Score: 0

    Oh crap! A recursive discussion!

  55. Re:Nay by Billly+Gates · · Score: 1

    Yahoo happens to disagree.

  56. Re:Perl != maintainable by snorklewacker · · Score: 2, Funny

    Oh crap! See parent!

    --
    I am no longer wasting my time with slashdot
  57. Re:Nay by snorklewacker · · Score: 1

    How about the fact that the PHP parser just exits if there's a syntax error in an eval. Yes, pass malformed code to eval and it will unconditionally abort the parent script. Nice parser.

    Perhaps PHP5 is more sane. PHP5 looks reasonable, though I suspect it still inherits all the silly 3000+ global functions of its parent, and still requires you to bracket even commandline scripts with <?php ?>

    --
    I am no longer wasting my time with slashdot
  58. Re:Nay by Billly+Gates · · Score: 1

    Actually it started out as an apache module.

    It stands for "Pre Hypertext Pages". It was supposed to be similiar to C/C++ .h header files in which the compiler loads the headers files known as step1 or prelinking and loading in a compiler. Then the rest of the code is loaded and linked to the precompilied files and executed.

    Basically the creater wanted to make specific tags and code in his homepage that apache would read first and run before teh html is processed and sent, in order to see how many employers accessed his resume.

  59. Re:Nay by Anonymous Coward · · Score: 0

    My personal opinions aside, I wonder how you would explain the widespread and seemingly increasing usage (and popularity) of PHP?

    It's supremely easy to install, and you can be up and running in a couple minutes from scratch. mod_perl requires a lot more work.

    Ironically, PHP1 (aka PHP/FI) was written in perl.

  60. Re:Nay by Anonymous Coward · · Score: 1, Informative

    "Actually it started out as an apache module."

    Actually, you're totally wrong.

    "It stands for 'Pre Hypertext Pages'."

    No, no, and no again. It never stood for that, not once, not ever. I'm not even going to dive into the rest of what you wrote, I'll just back myself up with real facts, unlike yours.

    I quote:

    "PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'."

    Thanks. Now please stop trying to prove people wrong unless you know your OWN facts first.

  61. Re:Comments to come: blah, Perl hard to read/maint by BerntB · · Score: 1
    Just because you can write:

    do { thirty(); things(); in(); a(); list(); unformatted(); } if($foo);

    Doesn't mean that you should.

    Totally right! No need for ():es when you have a suffix 'if'. You should end it .. if $foo;

    Only joking.

    Seriously, I second your position; Perl breaks all the rules but works anyway, given some discipline. It is both powerful and fun.

    If I get a choice, I use it for everything.

    --
    Karma: Excellent (My Karma? I wish...:-( )
  62. Re:Nay by petermgreen · · Score: 1

    isn't the whole idea of utf-8 that it can be used by code that wasn't explicitly designed for unicode?

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  63. dont go there. by Anonymous Coward · · Score: 0

    note that perl programs NEVER mention the memory footprint or startup overhead in perl programs.

  64. Re:Nay by JamesOfTheDesert · · Score: 1

    Ruby supports UTF-8.

    --

    Java is the blue pill
    Choose the red pill
  65. Perl is too clever by COBOL/MVS · · Score: 1, Insightful

    Having written code in Perl and other languages (COBOL, C++, Java, VB, TCL), I have come to the conclusion that Perl as a language is more concerned with being clever than getting the job done. The language has some of the most untechnical keywords (e.g. bless, chomp and others) and it makes it completely laughable (like a toy almost). Also, just look at any of the books and or documention written about perl. They all read like Tom Baker scripts from the 1970s Dr. Who episodes.

    While the TIMTOWTDI philosophy of perl is cute in theory, it seems to have backlashed and its now total anarchy. I look at some perl and it's total alphabet soup. And the lame excuse of "just because you can do it this way doesn't mean you should" is like putting warnings on cigarette boxes (just because you can smoke these doesn't mean you should).

    This book is not going to save perl. It's way too late for that. Perl will continue to be written poorly by people who think they're smarter than everyone else and will try to write their code to read like Tolstoy rather than for what it is.

    --
    GOBACK.
    1. Re:Perl is too clever by Anonymous Coward · · Score: 0

      The language has some of the most untechnical keywords (e.g. bless, chomp and others) and it makes it completely laughable (like a toy almost).

      Untechnical? Now there's a scathing indictment.

      So you're saying Perl would be improved by using nice arcane words like malloc or strstr?

  66. Re:Perl != maintainable by Shin+Chan · · Score: 1

    Fairly easy. I work on some with a friend (which, even though a bit unrelated, is at the other end of the planet). I work on it for a bit, then swap code and he works on it. We have always been able to read each others code perfectly fine even though we have different ways of writing Perl. We don't usually do weird stuff, either ("Keep it simple, Stupid!") so I think the code would be fairly simple for someone else to read. If it were open source, that is.

    --
    Proud owner of BOT2K3 [ bot2k3.net ]
  67. This gives me an idea by Anonymous Coward · · Score: 0

    The International Obfuscated Perl Code Competition

    Very similar to the IOCCC. You are given a selection of pieces of Perl code, some of which have been written normally, and some of which have been deliberately obfuscated. All you have to do is tell which is which :-)

  68. You're missing the point by metamatic · · Score: 1

    For many problems in the busines world, a 12% speed increase isn't worth having if it doubles development time.

    For example, I recently put together a reporting system. It's all scripting and Java. Could it run faster if it was all in C? Undoubtedly. However, it's only going to run once a month, so whether it takes 20 minutes or 22 minutes to crunch the data is utterly unimportant. Writing it in C would simply be premature optimization.

    --
    GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
  69. I've switched to Ruby by metamatic · · Score: 1

    Even though I'm still inexperienced at writing Ruby code, I already find it faster to write good code in than Perl.

    --
    GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
  70. MOD THIS UP INSIGHTFUL!!!! by Anonymous Coward · · Score: 0

    I agree!

  71. Re:Comments to come: blah, Perl hard to read/maint by Anonymous Coward · · Score: 0

    Perl is hard to read and is hard to maintain. When we write English papers there are expected standards concerning sentences, paragraphs, chapters etc. Perl is way too loose on what it allows.

  72. Re:Nay by qw(name) · · Score: 1

    I'm not an expert on it but it sounds like you're talking about mod_php.

  73. Doubles development time. by Anonymous Coward · · Score: 0

    The guy is demuxing some data and flipping bytes;
    so development time went from 5 minutes to 10 minutes. Imagine the poor clown that has to run
    10 of these jobs sequentially on Friday at 4PM. With the C implementation he can go home a half hour earlier.

    Uh. What's your point?

    1. Re:Doubles development time. by Camel+Pilot · · Score: 1

      I hate responding to a coward but 5 to 10 minutes try 5 to 10 man days. The perl program actually keeps up the process feeding it and I may actually deploy with the perl program and throw the c version away since the long term maintenance will be less. Try putting a name to your comments and you will be less off handed and will think a bit for responding.

  74. 11 lines? In Perl? Well... by Anonymous Coward · · Score: 0

    cat *.file | perl -ane "$c += scalar @F;END {print qq(Counted $c words.\n)}"

  75. Re:11 lines? In Perl? Well... by Anonymous Coward · · Score: 0

    1) I get a syntax error with this.
    2) So, you jammed two lines into one.
    3) "| wc" is a lot easier to type and remember.

  76. Perl isn't slow ... by Anonymous Coward · · Score: 0

    when it's calling libraries written in C. :)

  77. I guess the only use left for C... by Anonymous Coward · · Score: 0

    ...is to write compilers and interpreters for other languages.

  78. and providing fast libraries by Anonymous Coward · · Score: 0

    for toy languages like Perl. :)

  79. Re:Nay by Anonymous Coward · · Score: 0

    My personal opinions aside, I wonder how you would explain the widespread and seemingly increasing usage (and popularity) of PHP?

    Sturgeon's Law.

  80. Re:Nay by Billly+Gates · · Score: 1

    From link "..The whole new language was released under a new name, that removed the implication of limited personal use that the PHP/FI 2.0 name held. It was named plain 'PHP', with the meaning being a recursive acronym - PHP: Hypertext Preprocessor."

    Php/FI is not PHP in its current form. But I did assume it was. The scripts were read in on apache but I do nto know if it were originally a set of cgi scripts or were they actual apache mods like modern incarnations are.

  81. Re:Nay by Billly+Gates · · Score: 1

    I am not an expert either. But php by default is run as a mode but it also can be run as a cgi. Perl and python now run as mods as well but I believe php started putting everything the apache engine just like Microsoft did with ASP and IIS.

  82. Re:Comments to come: blah, Perl hard to read/maint by mce · · Score: 1
    One of the brilliant aspects of perl is that it allows you to write code like you think about code.

    While that point of view does have some merit, it also points out the worst failure of Perl. Far to many people do almost no thinking about their code and then get to live with just what they bargained for. Sadly, any later maintainers didn't bargain at all but still have to survive the mess created in the mean time. In se, this "why would I need to think" attitude is not a problem of Perl, but Perl does implicitly encourage it.

  83. 10 man days to write demux + byte swap ? by Anonymous Coward · · Score: 0

    yeah, you better stick to perl.

  84. Re:Nay by el-spectre · · Score: 1

    It gets worse... mSQL is "em-sequel" whereas mySQL is "my ess-cue-ell".

    Why? cuz the Gnu people can't have a monopoly on weird names, damnit.

    --
    "Faith: Belief without evidence in what is told by one who speaks without knowledge, of things without parallel." - A.B.
  85. Re:Nay by kabz · · Score: 1

    Do Not Resuscitate. Sorry, I'm not a great fan of Perl, useful though it is on occasion.

    --
    -- "It's not stalking if you're married!" My Wife.
  86. Re:Perl != maintainable by Cro+Magnon · · Score: 1

    How does Ruby compare to Python? And is it portable to the Mac or (ugh) Windows?

    --
    Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
  87. New language versions break code? Unforgivable! by DutchUncle · · Score: 1

    Why isn't everyone totally unforgiving of the idea that new version releases break existing products? If it's suppposed to be the same language, it's supposed to WORK. Yes, you can "deprecate" things, and suggest that they not be used any more, and even let them be less efficient, but legacy code is not supposed to be broken by the compiler, any more than running the same old code on a newer computer should break. I've been in programming since the IBM mainframe days, and this would have been considered a hanging offense - certainly lawsuit material. Imagine if the phone company decided to change its interfaces overnight and your phone stopped working - that's how ticked everyone should be.

    1. Re:New language versions break code? Unforgivable! by LizardKing · · Score: 1

      Back in the early to mid-1990s, Perl made programming accessible to people who would have struggled with systems programming languages like C or C++. The alternative, shell programming constructs, did not provide the rich set of features provided by Perl. Unfortunately, Perl's use by novices and the "101 ways to do the same thing" approach has left a legacy of spaghetti code written in dozens of weird idioms.

      Amongst the Slashdot readership, there are a lot of these novice programmers (although some of are now Ruby or Python proponents). To criticise Perl (or Python, Ruby, etc) on the grounds that they do not provide the backwards compatability that you would expect from standardised languages and libraries is considered sacrilege.

    2. Re:New language versions break code? Unforgivable! by DutchUncle · · Score: 1

      I have no problem with 101 ways do do the same thing, or even weird idioms; that's true in most computer languages, as it is in English and other natural languages. As John Dikstra said, you can program Fortran in any language. I *do* insist that when a new interpreter version is released, all 101 should still do the same thing(s) they used to do rather than doing anywhere from 1 to 101 different things.

  88. Re:Perl != maintainable by Anonymous Coward · · Score: 0

    Ruby is pretty comparable to Python in most ways. Pretty much, if you like Perl, and you like Python, you will like Ruby. It is portable to *nix (including Mac), and Windows, and downright neat.

  89. Re:Nay by Anonymous Coward · · Score: 0

    If you're going to attack PHP, I'd suggest its more unsavory aspects like register_globals [etc, etc]

    No, I think the haphazardly-named and insanely numerous core functions all stuffed into the primary namespace are far more damning because they are aspects of the language itself rather than of the interpreter. While I can easily control the interpreter's behavior regarding magic quotes and register_globals, I can't irradicate the language problems without recoding the interpreter itself.

  90. Re:Comments to come: blah, Perl hard to read/maint by John+Bokma · · Score: 1

    As you already explained: that one can write shitty code doesn't mean one has too. Moreover, I haven't seen any language yet that guides one to write any algorithm in such a way that comments are not needed. There is no programming language that thinks for you. Perl's major problem is the huge number of people who learned it by just peeking at a CGI script and tweaking it to their needs. Same holds for PHP, and hey, isn't the quality of code quite similar? I recently had a long winding discussion with someone who complained how bad Perl was designed (http://groups-beta.google.com/group/comp.lang.pyt hon/messages/7e74fc5dd24047a1,4434b5a10d0e32f8,142 2dd275c9c6e3a,3547b6a0a71c1dfd,dce98f843551d487,dc 30957084149f8e,0fc2b0d1cc84a2c2,4eb114d062008987,d 0257059b4c0f09b,de6a3819b19098d3?hl=en&thread_id=6 d65bbac956ebbb0&mode=thread&noheader=1&q=bokma+per l+skills+python&_done=%2Fgroup%2Fcomp.lang.python% 2Fbrowse_frm%2Fthread%2F6d65bbac956ebbb0%2F4ff432e af904ac53%3Fq%3Dbokma+perl+skills+python%26rnum%3D 2%26#doc_dc30957084149f8e but after some time I got the feeling that just his Perl skills were severly limited.

  91. Re:Perl != maintainable by Anonymous Coward · · Score: 0

    Yeah, ruby runs fine on any of the common platforms.

  92. Re:Nay by WWWWolf · · Score: 1
    Yahoo happens to disagree.

    Yahoo, yeah, now there's a really weird place, which only happens to come into existence when people really want to use what seemed like the right tools at the time... They have stuff in both Common Lisp and PHP. I can kind of understand CL but PHP is still kind of weird.

    (And they have quite a bit of stuff in other languages as well, to be fair - Java and Perl at least. I think I saw a .py or two in an Yahoo URL somewhere a few times. I always kind of liked the fact that they don't make their language choices very apparent unless you point them specifically out.)

  93. Re:Nay by 1110110001 · · Score: 1
    I don't think PHP is inherently bad, but the current implementation certainly is.

    You talk about a PHP3 lib and think this is current implementation? Of course an API does not change. But in PHP5 you've mysqli:
    mixed mysqli_query ( mysqli link, string query [, int resultmode] )
    As you see it's the way you want it. And every new lib since PHP4 follows the same guideliness.

    BTW no one should use the database libs directly anyway. Use an abstraction like adodb or PDO in PHP 5.1. If you'd have a well structured code you'd never see the mysql quirks.

    b4n
  94. one disagreement I had with the book's author by kwoff · · Score: 1

    In the book, he advocates reducing lines of code by getting rid of temporary variables where possible. I've never agreed with that philosophy, and I think it's a terrible way to make code maintainable.

    1. Re:one disagreement I had with the book's author by PeterScott · · Score: 1

      Which is why that recommendation was immediately followed by another one recommending adding temporary variables when necessary. Both sections explained that clarity is the ultimate goal.

  95. Re:Nay by larry+bagina · · Score: 1
    register globals, magic quotes, session url rewriting, etc. can be set via the .htaccess file.

    magic quotes ... I don't think there are appropriate words to describe how stupid that is. Everybody needs to suffer so newbies won't have to escape data before inserting it into a db?!?!?! Arrghgh!!!!

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  96. Re:Nay by larry+bagina · · Score: 1
    CCLAN is still bloody tiny.

    Not unlike Michael Jackson's dick the morning after a Macaulay Culkin sleep over.

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  97. Re:Nay by Anonymous Coward · · Score: 0
    Problem: too many functions. Functions have inconsistent/irrational arguments.

    Solution: Add more functions.

    I like the PHP language, but the functions are a mess. Functions that shouldn't even be included (ie converting jewish dates to non jewish dates). Naming schemes more erratic than Courtney Love. Functions which work differently depending on the version. It's a mess.

  98. Re:Nay by 1110110001 · · Score: 1

    There are not too many functions. --without-mysql and all mysql_* functions are gone. That's how modules work in PHP. It still has no namespace (maybe PHP6 via Parrot) and thus the prefix.

    They made a new module for different reasons. First everyone know the inconsistency sucks. But you can't just change alls mysql_* functions and break older code. Second mySQL matured. Mysqli is meant for mySQL 4 and adds some new functions like prepare or transactions.

    Again if you don't want them don't compile them.

    For the jewish stuff. I guess someone could need them. Like some people need to know when is Easter. But again if you don't need them don't enable the calendar module. It's not enabled by default anyway. Thus you're responsible for having them, or maybe you're using windows - I won't comment on that ;)

    b4n

    PS: Try to register. It's always nice to know to whom I'm speaking, AC