Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: The REAL reason for why they choose PHP over Perl.

by Anonymous Monk
on Jun 23, 2006 at 17:19 UTC ( [id://557263]=note: print w/replies, xml ) Need Help??


in reply to Re: The REAL reason for why they choose PHP over Perl.
in thread The REAL reason for why they choose PHP over Perl.

I blame the Python people for that one. I think Python people spend more time denigrating Perl than actually coding. Quite venimous stuff. According to them, Perl is impossible to read, it's not object oriented, it has too many operators, it's confusing, etc.

I don't. Much of their arguments are legitimate, if you care about the things they complain about.

Perl *is* a large, complex language; that's a statement of fact, not opinion. I once counted over 200 function call formats in perlfunc; that's a lot for the base language. What's more, each function call can be called in one of three contexts: and lots of people don't understand context right away. You have to memorize each function twice; what it does in scalar context, and what it does in list context, and if they are different or not.

Perl does a lot automatically, in a lot of different situations, and until you memorize what shortcuts perl is taking, you won't know what it's really doing. Even experts here on perlmonks run code through B:Deparse to try to make sense of what's really happening with strange code.

Seems like I committed the mortal sin of indenting the code with a tab instead of eight spaces. You see, Python uses indents to tell it which lines belong to which blocks of code instead of using curly brackets. A "feature" according to Python people. I haven't touched it since.

Every language has it's "rookie mistakes". A long time ago, when I was first trying to learn perl, I wasted several hours trying to figure out why a simple pattern match wouldn't work. Turned out I was using ~= where I should have been using =~ : I'd never used composite operators before, and kept reading over the typo. I nearly gave up on Perl then, too.

Python's forced indentation has a purpose; it eliminates indentation errors (which can be annoying to track down on your own), and it ensures that your code is indented in a readable format.

I've wasted a lot of time over the years, in C and in Perl, running a search for a {, % match it, try to figure out if that's what it should match, decide it is, go on to the next match, iterate. I've actually started commenting end braces whenever I have to maintain code; not only does it give a bit more explanation as to what an ugly off-screen construct seems to do, it helps me resolve the painful "does this brace match what it should match?" question. Looking back on those wasted hours over the years, a little "use tabs for indentation" rule just doesn't bother me that much.

It also neatly solves another problem; pretty printing. If some wingnut formatted Perl inconsistantly (2 column indent half the time, 4 the next, 8 the next), you've got to parse the entire language just to indent the code. Perltidy does a good job with a horribly complicated language ("only perl can Parse perl"), but it didn't exist for years, and took a long time to write.

With tab indents, you just change the size of a tabstop. A ten year old can write a "tab to space" converter.

Perl's philsophy is just different than Python's. Perl people tend to focus on initial code development: the perl motto is "there's More than One Way to Do it". Python people tend to focus on maintainance -- something more like "There's One Right Way to Do It: strive to find it".

Depending on whether your do more coding or more maintenance, you may prefer one over the other...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://557263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found