Posted by
CmdrTaco
on from the get-your-develop-on dept.
An anonymous reader writes "PHP just released the first release candidate of PHP 5 after 4 beta releases. It is considered stable and feature-complete -- so get testing!"
Power Power Power
by
ObviousGuy
·
· Score: 2, Interesting
It's funny, I remember when it was a main tenet of programming that data should be separate from presentation. However, PHP has shown just how powerful integrating data and presentation can be through inlining code directly into a webpage layout.
As Perl seems to fade more into irrelevence, languages that hold onto a strong central theme like PHP, Python, Ruby, and Dylan are coming to the fore to take its place. Whenever I see a story about PHP, I think more about the death throes of Perl than about PHP itself.
-- I have been pwned because my/. password was too easy to guess.
Re:Power Power Power
by
Charles+Dart
·
· Score: 3, Interesting
Separating code and content (and style) is what I use php for. If you are putting php in your html you are doing it backwards. Marked up content goes in one database table CSS goes in the other and php puts them together.
Re:Power Power Power
by
loginx
·
· Score: 4, Interesting
I personally use a proprietary templating engine, but if I was to use any of the open-sourced ones, I would first look at what my requirements are.
If you are looking for a full-fledged templating that has all the bells and whissles, I would recommend Smarty because it has a massive amount of feature and seems to be quite endorsed by official PHP developers.
If you are looking for something a little simpler to bring more speed and less overhead to your presentation layer, I do like the approach of the Sigma templating engine (in the links posted above) as it brings only what you really need and does it very quickly.
Re:Power Power Power
by
sporty
·
· Score: 2, Interesting
Yet it does such a bad job of enforcing it. You'd think for a language who's job that acts as a conduit between your view layer and your model would at least do a good job at it.
Or are we going to add another few thousand functions into the core language. Again.
Hmm... why do we always get new expressivity features and library extensions, instead of new safety features and ways for statically checking our code (such as type checking, a novel but, admittedly, completely impractical and academic invention that only freak languages use)?
I guess because people like me prefer to complain and use other languages instead of fixing unsafe ones...
Re:Safety?
by
Anonymous Coward
·
· Score: 1, Interesting
It minimizes a large class of SQL Injection errors in web applications.
It minimizes a large class of SQL Injection errors in web applications
...which is handled smoothly with a decent abstraction layer...
Anything else?
-- I have no problem with your religion until you decide it's reason to deprive others of the truth.
Much improved.
by
Sheetrock
·
· Score: 3, Interesting
A test run of our PHP setup on PHP5 RC1 seems to be more responsive and crisp than it was on PHP4. I've also heard the syntax is being improved in some areas, which would be quite the boon (our site looking somewhat spaghettish as it is.)
Didn't have to jump through any hoops that weren't explicitly mentioned to get it installed, and haven't noticed any problems so far. Hopefully this is a sign that the official PHP5 is soon to arrive.
--
Try not. Do or do not, there is no try. -- Dr. Spock, stardate 2822-3.
How does PHP comapre in terms of speed and ease of Use to other scripting languages like ASP, perl, JSP, or serverside Javascript.
I guess a lot of PHP user base was once doing mod_perl and CGI. I personally use JSP, but often find it too cumbursome for quick hacks.
-- for the last time people, I am "frodo from middle eaRTH", not "middle eaST".
Re:PHP in comparision to others
by
protohiro1
·
· Score: 2, Interesting
PHP is insanely easy to use. I think that is one of its biggest draws. I tried using JSP back in the day but it was really over the head of this artist. In terms of speed...well you're asking the wrong guy but I can't detect any difference between static pages and php pages (but my scripts are very simple). Products like vBulletin and Moveable type are very popular and seem to run at a decent speed and scale, so I think php is battle tested. Although the two web developers I know use ASP and JSP respectivly and don't seem to take PHP to seriously.
-- Sig removed because it was obnoxious
Re:Time for /. to
by
Sheetrock
·
· Score: 5, Interesting
Although you might be kidding (since/. has an established base of well-tweaked high quality/high performance Perl code), not only is PHP and in particular PHP5 is an excellent choice for prototyping because of the integration between display and function, but it's probably the right choice most of the time for people who are seeking to integrate databases with web functionality without delving into high-priced solutions.
/. is in a special situation due to the amount of traffic it receives, and the amount of effort that has gone into making Slash the powerhouse that it is has no doubt driven projects like perl_mod to increase the efficiency on the webserver side. While PHP would only improve on the appearance and capability to add user functionality, there would be issues with stability.
--
Try not. Do or do not, there is no try. -- Dr. Spock, stardate 2822-3.
Damn, you're clueless
by
jbellis
·
· Score: 5, Interesting
- for all but the most trivial sites, separating code & presentation is a Good Thing - PHP supports this kind of separation. google for template libraries.
Re:It is NOT stable
by
panic911
·
· Score: 2, Interesting
lol, good point.
I've been playing with PHP5 since Beta1 and honestly, I've never noticed any stability issues with it. Of course, that's not to say that it was stable (could have been bugs or security issues).
PHP5 has really great Object Oriented functionality. I'm glad to see that it isn't far from being released.
Apache 2.x safe to use yet?
by
Anonymous Coward
·
· Score: 5, Interesting
I remember reading within the PHP docs about how unsafe it was to use the 2.x release branch of Apache with PHP...something to do with thread safety if I recall.
Anybody know if PHP 5.x has overcome this limitation?
Re:Apache 2.x safe to use yet?
by
Wonko42
·
· Score: 2, Interesting
I've been using PHP 4.x with Apache 2.x (as a module) for over a year now, on both FreeBSD and Windows, with no problems. I haven't tried PHP 5 yet, but I imaginine it works fine too.
Re:Apache 2.x safe to use yet?
by
QuasiEvil
·
· Score: 2, Interesting
The only thing I remember was a problem relating to multiple includes of PHP scripts. The PHP people pointed at Apache, Apache people pointed at PHP. Something about apache filter vs. something-or-other, blah blah blah. Suffice to say they finally got things together a while back, and I run PHP 4.3.x on a handful of production servers (some with quite high load and mostly PHP pages) without issue.
I don't remember the exact details of the whole fiasco, but both sides racked up a black eye in my book. It was a very basic piece of functionality that they didn't seem to be moving too quickly to fix. It delayed my upgrade to A2 for about eight months and annoyed me every time I thought about it.
That said, PHP absolutely rocks. Fast, efficient, and concise. I just view it as improved C, which in my world (a world sans objects), is a very good thing.
Re:Apache 2.x safe to use yet?
by
gabe
·
· Score: 2, Interesting
Re:Apache 2.x safe to use yet?
by
Electrum
·
· Score: 2, Interesting
I remember reading within the PHP docs about how unsafe it was to use the 2.x release branch of Apache with PHP...something to do with thread safety if I recall.
PHP is not thread safe and likely never will be. The core is thread safe, but not all the extensions are guaranteed to be thread safe due to the external libraries they use. Thread safe issues likely won't show up during testing, but will show up in production under heavy load. This is the reason Zeus recommends using FastCGI instead of ISAPI for PHP, and the reason the recently released Zend WinEnabler uses FastCGI.
I strongly recommend using the FastCGI interface to PHP, even under Apache. The FastCGI interface is much faster than mod_php4 under Zeus and will likely faster under Apache too. It has the advantages that you can control resource usage better (no bloated PHP environment in every Apache process), run PHP as a different user than the web server and even run PHP on a different machine than the web server.
FastCGI rocks. It is a shame that many things are written as Apache modules and not FastCGI. The trend of "compiling everything into the web server" is bad engineering.
Re:That IS kind of funny
by
smack_attack
·
· Score: 2, Interesting
I think you are referring to sites that get killed from too many connections to MySQL (due to the poor defaults in MySQL). As someone who programs for high traffic adult sites, I can attest that PHP can handle loads of traffic with ease, it's the databases that usually fuck up first. And even then that's usually just due to retarded coding practices.
Funny enough though,/. uses MySQL without apparent problems, but then again there's a lot of page caching.
The "good design" police... have fun with it!
by
turnstyle
·
· Score: 3, Interesting
For starters, I'd say that PHP is more a challenge to ASP than Perl.
(I see plenty of Windows users adding PHP to systems that already support ASP)
In any case, all the talk of "good" design ignores all the new and not hardcore coders who can play with something like PHP (as well as ASP) but not so much Perl.
(note aslo that Apple includes PHP on their OSX boxes)
My point is that, in my opinion, one of the things so nice with PHP is that it's just fun to play with. If some coders want to "inline" their code, let them, and let them have some fun, eh.
It's like the pre-Web days when "designers" got into scripting with HyperCard and Lingo.
Control vs. Abstraction
by
Eberlin
·
· Score: 4, Interesting
Having browsed only a few ASP.NET howtos but not having had the opportunity (or misery -- since this IS slashdot) to code in it, I'm not too familiar with ASP.NET
OTOH, I am a bit more involved in programming in PHP. I think it's fairly nice and simple enough. Haven't gotten into a lot of the OO stuff but it's still fairly powerful with the simple things I do.
From what I've read, ASP.NET abstracts a LOT of the stuff from the programmer. Forms pretty much take care of themselves, validate on their own, and repopulate themselves for the user to correct. Among other things, this helps isolate code from content.
From experience (which may be very limited), PHP doesn't have this feature. This allows for so much more control over what happens to your forms, but also introduces more code into the mix which could get ugly after a while.
Thus we have control vs. abstraction -- a classic debate. Convenience and rapid development would lean towards abstraction (as anyone who coded VB may argue). Would be nice if PHP had that n00b convenience somewhere while still being great for more advanced coders.
Ultimately, control is probably the choice for anyone who wants to get past the abstraction. Besides, in the long run, you'd probably want to write your own data validation code (or at least implement an open-source version) instead of relying on a (closed-source) language to check for you. That's simply a matter of trust.
For people who think there must be something better to write web-based applications than PHP, I invite you all to take a look at Seaside by Avi Bryant, a web framework available for Squeak and, I think, VisualWorks Smalltalk. It uses continuations to make programming a web application basically the same as coding a desktop application. It features many, many things that PHP cannot do.
I hear this alot and I don't get it. I find PHP code very legible. In fact, I find every language that I have a good knowledge of to be quite legible.
Now if I have a lower level of knowledge of a language I often have trouble reading it, but that's usually because I didn't know that syntax X could be used to accomplish the task, I always used syntax Y. This happens to me alot in Perl, I can make it do alot, but since I'm not as familar with it, there are always ways I don't know to accomplish the tasks.
Of course this assumes the author is a somewhat reasonable individual, knows to use the proper control structures and the like.
So I genuinely ask, what is it about the syntax of this language that gets people? Is it too many curly braces or what?
Re:Time for /. to
by
Micah
·
· Score: 2, Interesting
For a site like Slashdot, PHP would kill performance. mod_perl caches psuedo-compiled code in the webserver. PHP has to be re-interpreted for every page hit. You can install the Zend Optimizer, but from my limited trials with Xaraya running under it I wasn't all that impressed.
Personally, I think Slashdot needs to be re-written in C. See my journal for the complete idea.
PHP vs. Perl
by
transient
·
· Score: 4, Interesting
I swear I'm not trying to start a flamewar with this, so please respond appropriately.
What advantage does PHP have over Perl?
At first, I rejected PHP because of its (apparent) preference for intermingling presentation and logic. As has been thoroughly discussed in another thread, separating the two is not only possible but recommended. That doesn't give PHP any points though -- it just removes a penalty.
Both languages have a wide range of libraries/modules to choose from (although I think the score here goes to Perl). Their syntax is nearly identical. They both run on lots of different platforms. PHP is pegged as a tool for making web sites, while Perl is a general-purpose scripting language that happens to be useful for web sites too.
So, make a business case for me. I manage a development team (I rose from the ranks so save your MBA jokes for another day) and I want to know why I should consider PHP over Perl.
--
irb(main):001:0>
Perl's grammar is too big
by
SnatMandu
·
· Score: 4, Interesting
PHP has a smaller syntactical (is that a word?) footprint. As you said that you manage a development team, this is important. The Perl motto of "There's more than one way to do it" becomes an issue when you've got multiple developers working on the same codebase. You can write and (attempt to) enforce code style rules in your organization, which mitigates this a little bit, but it takes time to write those guidelines, get buy-in, and enforce.
I use perl often, but I consider it a "fire and forget" language. I use it for sysAdmin type work often, when I'm doing something once, and want to write a quick script that nobody (including me) will ever lay eyes on again. For real development, where I'm trying to create a maintainable piece of software, with input from other developers, I stick to PHP.
Re:Perl's grammar is too big
by
SnatMandu
·
· Score: 4, Interesting
Most of your criticisms of PHP are totally on the money.
But come on. Once a programmer really gets into perl, only another hard-core perl person can read their scrawl. Don't get me wrong, I love perl. But it's a horrible choice for a large project with many developers.
I've not dug into perl documentation for a while (has it been years?), but last time I checked, it was about 100 man pages. With php, if I think there's a function called split, I type http://www.php.net/split and there's the docs.
Re: perldoc, c'mon! I get the impression you've never had to maintain code written by a hard-core perl programmer (or maybe you are one). For hobby stuff, use any language you want, but for business purposes, I don't want to have to search for developers who are so fucking specialized in perl. With PHP, I can make anybody who learned the basics fo C and make them productive in about 48 hours, working on someone else's code. With a big perl codebase, that same person is going to have to be twice as expensive if they're going to jump in head-first.
Re: too many overlapping core functions - I don't know what you're talking about. There are a few aliases in there (ie: chop or rtrim (which actually is annoying, since chop() should work like it does in perl, IMO)), but I don't see a lot of overlap.
I think perl is really neat, but it's overkill. I know that's the tried and true criticism, but I really think it's true. I don't want to give a group of 4-12 developers of varying cluefulness that sort of capacity to create havoc for each other.
Re:Perl's grammar is too big
by
Anonymous Coward
·
· Score: 2, Interesting
Here's an example of what the parent poster was talking about:
ereg()/ereg_replace()
eregi()/eregi_replace()
split()/spliti()
C'mon! Just make the "i" part another argument! Sheesh!
Some functions are split with underscores (mysql_connect, ereg_replace, file_exists()) others are just mashed together words (fgetcsv(), all standard POSIX calls, etc.). It's polluted with dozens, if not hundreds, of in-core functions!
Perl, on the other hand, derives its real strength from libraries (CPAN!). Like Java, C++, Python or any other language.
Which is harder? Learning hundreds of built in functions or figuring out a library? Dunno, hard to say, but libraries seem a lot more popular than throwing hundreds of core functions into a language.
Documentation? Sure, you have www.php.net/[function], I've got "perldoc -f [function]". I don't need net access to do a quick lookup. Not to mention all module documentation is available through perldoc on the commandline as well.
And if you have a problem with unreadable, unmaintable code, fire the programmer and get someone who can stick to coding standards, comment their code, and keep the cutesy one-liner hacks out of their code.
Give any group of 4-12 developers a big project, and they'll create chaos if you don't have them stick to coding standards. Especially if they don't know the language inside and out - Perl OR PHP!
Finally clause
by
BlueLabel
·
· Score: 4, Interesting
I used to be a PHP developer, but switched to python-based content management systems due to the elegance and ease of programming in python. However, I was interested to see how PHP had progressed since the last version, and read the article linked by Slashdot.
The main reason I initially dumped PHP was its atrocious error handling. Python and other more elegant languages use exception handling, which is much more elegant than checking return codes and setting error handlers.
I had read earlier than PHP 5 would include exception handling, but wouldn't include the "finally" clause. For programmers that understand and use exceptions, the finally clause is _very_ useful. I try to avoid using C++ simply because it doesn't have a finally clause (and no, the object destruction mechanism is not a good substitute).
So, I became very excited when I read the following:
Note that there is support for "catch all" and for the "finally" clause.
(http://www.php.net/zend-engine-2.php)
However, I couldn't find any examples showing the "finally" clause or the "catch all" clause in use.
So, I went grepping through CVS.
In the changelog for PHP, it is suggested that all exceptions _must_ inherit from a base 'Exception' class, which means that catching and exception of type 'Exception' is a basic "catch all". However, I couldn't find _any_ evidence in CVS that a "finally" clause has been introduced in PHP 5.
Has anyone here found evidence that the "finally" clause exists in PHP 5?
-- Devin
Re:Keep the presentation and code SEPARATE, please
by
Safety+Cap
·
· Score: 1, Interesting
If you've been involved in any kind of app deployment followed by its maintenance (especially web apps), you'll know that keeping presentation and code separate is extremely desirable. Integration of these two is a weakness, if anything.
Script kiddie programmers fail to understand this lesson, which is why PHP/MySQL shitsites are a bear to maintain (that, and tryting to normalize these databases is a laughable exercise, at best).
Hell, just try porting a P/M site to a nice DB so you can push more of the data manipulation functionality to the DB layer where it belongs and you're in for a real tear-jerker. My main frustrations with OSS is that most of the work is done 1) where the work is easier, 2) where most people (unwashed masses) congregate, and 3) with little regard to lessons learned and best practices.
-- Yeah, right.
Re:Apache 2.x MPM is safe with PHP 4.3.x
by
ergonal
·
· Score: 2, Interesting
Here's what Rasmus said 6 days ago in a bug report:
We are not talking about just Apache2 here. We are talking about Apache2+an MPM+PHP+3rd Party Libs. The folks at apache.org are only concerned with Apache2 itself, and for serving up static files it is better than Apache1 in many respects. However we have to worry about a lot more stuff here. In fact, we couldn't care less about serving up static files. The main issues as I see them are: <p> 1. Thread safety issues. - It is very difficult to track down threading problems and we don't have decent tools to help us.</blockquote> - The thread safety of many 3rd party libraries are unknown quantities and can depend on the OS, libc and even compile flags. - Many distributions seem to ship with the Worker MPM as the default and that is the MPM that gets the most attention. This is a hybrid multi-process, multi-threaded MPM.
2. You can eliminate the threading problem by running the prefork MPM which effectively makes Apache2 behave just like Apache1 in the way it forks processes and serves one request at a time per process. Issues here: - Apache2 itself is rather fringe still. It has approximately a 5% marketshare vs. 65% for Apache1 at the time of this and out of that I would guess the majority are running the Worker MPM. So we are talking about a fringe MPM in a fringe server. This means it has not had anywhere near the attention from people running large production web server farms that it needs for me to comfortably say that this is a solid piece of code with all the kinks worked out. - The benefits of moving to Apache2+prefork are questionable. The new filter API would be one of the benefits, but it still has some issues and by default we run PHP as a handler, not a filter currently. You can optionally run it as a filter but people have had problems with that.
Until such a time when enough clueful PHP people think there are enough realworld useful features in Apache2-prefork or even Apache2-threaded to actually sit down and bang away at PHP and the majority of the PHP extensions under Apache2. Or if enough regular users report back that they tried it and had absolutely no problems then we will change our reccomendation, but for the time being I don't think that we in good faith can tell users that Apache2+PHP is something they should be putting into production.
PHP's libraries and OOP
by
Anonymous Coward
·
· Score: 1, Interesting
I'll look at PHP again when its massive function library is refactored into functions.
There should be no need to write:
$arr = array(); array_push($arr, 42);
When it could be:
$arr = new Array; $arr->push(42);
Re:Sys Admin stuff with PHP? Really?
by
solidox
·
· Score: 2, Interesting
i got a few php scripts on a cronjob to do database backups and such things. i also use it for quick admin type hackie scripts. personally i recon it's far superior to bash/perl/etc for shell scripting
--
Re:Here you go
by
Anonymous Coward
·
· Score: 1, Interesting
Java is a statically typed language which makes using it for web apps _extremely_ verbose in comparison to the other languages here.
I'm really getting tired of seeing that particular bit of nonsense trotted out in every discussion here.
To set the record straight: STATIC TYPING HAS NOTHING TO DO WITH VERBOSITY.
Java is verbose, and Java is statically typed, but that does not mean that all statically typed languages are verbose, any more than it means that all statically typed languages are Java.
Consider Haskell, where the quicksort algorithm can, famously, be written in two lines of code:
qsort [] = [] qsort (x:xs) = qsort [e | e <- xs, e < x] ++ [x] ++ [e | e <- xs, e >= x]
Note the total absence of type declarations. In fact, this function will work on values of any type that can be sorted. And it's also completely statically typed.
Welcome to the world of modern programming, where convenience doesn't have to mean flinging safety to the winds.
It's funny, I remember when it was a main tenet of programming that data should be separate from presentation. However, PHP has shown just how powerful integrating data and presentation can be through inlining code directly into a webpage layout.
As Perl seems to fade more into irrelevence, languages that hold onto a strong central theme like PHP, Python, Ruby, and Dylan are coming to the fore to take its place. Whenever I see a story about PHP, I think more about the death throes of Perl than about PHP itself.
I have been pwned because my
Hmm... why do we always get new expressivity features and library extensions, instead of new safety features and ways for statically checking our code (such as type checking, a novel but, admittedly, completely impractical and academic invention that only freak languages use)?
I guess because people like me prefer to complain and use other languages instead of fixing unsafe ones...
Didn't have to jump through any hoops that weren't explicitly mentioned to get it installed, and haven't noticed any problems so far. Hopefully this is a sign that the official PHP5 is soon to arrive.
Try not. Do or do not, there is no try.
-- Dr. Spock, stardate 2822-3.
I guess a lot of PHP user base was once doing mod_perl and CGI. I personally use JSP, but often find it too cumbursome for quick hacks.
for the last time people, I am "frodo from middle eaRTH", not "middle eaST".
Try not. Do or do not, there is no try.
-- Dr. Spock, stardate 2822-3.
- for all but the most trivial sites, separating code & presentation is a Good Thing
- PHP supports this kind of separation. google for template libraries.
lol, good point.
I've been playing with PHP5 since Beta1 and honestly, I've never noticed any stability issues with it. Of course, that's not to say that it was stable (could have been bugs or security issues).
PHP5 has really great Object Oriented functionality. I'm glad to see that it isn't far from being released.
I remember reading within the PHP docs about how unsafe it was to use the 2.x release branch of Apache with PHP...something to do with thread safety if I recall.
Anybody know if PHP 5.x has overcome this limitation?
I think you are referring to sites that get killed from too many connections to MySQL (due to the poor defaults in MySQL). As someone who programs for high traffic adult sites, I can attest that PHP can handle loads of traffic with ease, it's the databases that usually fuck up first. And even then that's usually just due to retarded coding practices.
/. uses MySQL without apparent problems, but then again there's a lot of page caching.
Funny enough though,
Hammer of Truth
I wonder if I can install both so I can play with php5.
http://saveie6.com/
(I see plenty of Windows users adding PHP to systems that already support ASP)
In any case, all the talk of "good" design ignores all the new and not hardcore coders who can play with something like PHP (as well as ASP) but not so much Perl.
(note aslo that Apple includes PHP on their OSX boxes)
My point is that, in my opinion, one of the things so nice with PHP is that it's just fun to play with. If some coders want to "inline" their code, let them, and let them have some fun, eh.
It's like the pre-Web days when "designers" got into scripting with HyperCard and Lingo.
Everybody's welcome.
Here's what I do: Bitty Browser & Andromeda
Having browsed only a few ASP.NET howtos but not having had the opportunity (or misery -- since this IS slashdot) to code in it, I'm not too familiar with ASP.NET
OTOH, I am a bit more involved in programming in PHP. I think it's fairly nice and simple enough. Haven't gotten into a lot of the OO stuff but it's still fairly powerful with the simple things I do.
From what I've read, ASP.NET abstracts a LOT of the stuff from the programmer. Forms pretty much take care of themselves, validate on their own, and repopulate themselves for the user to correct. Among other things, this helps isolate code from content.
From experience (which may be very limited), PHP doesn't have this feature. This allows for so much more control over what happens to your forms, but also introduces more code into the mix which could get ugly after a while.
Thus we have control vs. abstraction -- a classic debate. Convenience and rapid development would lean towards abstraction (as anyone who coded VB may argue). Would be nice if PHP had that n00b convenience somewhere while still being great for more advanced coders.
Ultimately, control is probably the choice for anyone who wants to get past the abstraction. Besides, in the long run, you'd probably want to write your own data validation code (or at least implement an open-source version) instead of relying on a (closed-source) language to check for you. That's simply a matter of trust.
For people who think there must be something better to write web-based applications than PHP, I invite you all to take a look at Seaside by Avi Bryant, a web framework available for Squeak and, I think, VisualWorks Smalltalk. It uses continuations to make programming a web application basically the same as coding a desktop application. It features many, many things that PHP cannot do.
For a site like Slashdot, PHP would kill performance. mod_perl caches psuedo-compiled code in the webserver. PHP has to be re-interpreted for every page hit. You can install the Zend Optimizer, but from my limited trials with Xaraya running under it I wasn't all that impressed.
Personally, I think Slashdot needs to be re-written in C. See my journal for the complete idea.
What advantage does PHP have over Perl?
At first, I rejected PHP because of its (apparent) preference for intermingling presentation and logic. As has been thoroughly discussed in another thread, separating the two is not only possible but recommended. That doesn't give PHP any points though -- it just removes a penalty.
Both languages have a wide range of libraries/modules to choose from (although I think the score here goes to Perl). Their syntax is nearly identical. They both run on lots of different platforms. PHP is pegged as a tool for making web sites, while Perl is a general-purpose scripting language that happens to be useful for web sites too.
So, make a business case for me. I manage a development team (I rose from the ranks so save your MBA jokes for another day) and I want to know why I should consider PHP over Perl.
irb(main):001:0>
PHP has a smaller syntactical (is that a word?) footprint. As you said that you manage a development team, this is important. The Perl motto of "There's more than one way to do it" becomes an issue when you've got multiple developers working on the same codebase. You can write and (attempt to) enforce code style rules in your organization, which mitigates this a little bit, but it takes time to write those guidelines, get buy-in, and enforce.
I use perl often, but I consider it a "fire and forget" language. I use it for sysAdmin type work often, when I'm doing something once, and want to write a quick script that nobody (including me) will ever lay eyes on again. For real development, where I'm trying to create a maintainable piece of software, with input from other developers, I stick to PHP.
I used to be a PHP developer, but switched to python-based content management systems due to the elegance and ease of programming in python. However, I was interested to see how PHP had progressed since the last version, and read the article linked by Slashdot.
The main reason I initially dumped PHP was its atrocious error handling. Python and other more elegant languages use exception handling, which is much more elegant than checking return codes and setting error handlers.
I had read earlier than PHP 5 would include exception handling, but wouldn't include the "finally" clause. For programmers that understand and use exceptions, the finally clause is _very_ useful. I try to avoid using C++ simply because it doesn't have a finally clause (and no, the object destruction mechanism is not a good substitute).
So, I became very excited when I read the following:
Note that there is support for "catch all" and for the "finally" clause.
(http://www.php.net/zend-engine-2.php)
However, I couldn't find any examples showing the "finally" clause or the "catch all" clause in use.
So, I went grepping through CVS.
In the changelog for PHP, it is suggested that all exceptions _must_ inherit from a base 'Exception' class, which means that catching and exception of type 'Exception' is a basic "catch all". However, I couldn't find _any_ evidence in CVS that a "finally" clause has been introduced in PHP 5.
Has anyone here found evidence that the "finally" clause exists in PHP 5?
Devin
Hell, just try porting a P/M site to a nice DB so you can push more of the data manipulation functionality to the DB layer where it belongs and you're in for a real tear-jerker. My main frustrations with OSS is that most of the work is done 1) where the work is easier, 2) where most people (unwashed masses) congregate, and 3) with little regard to lessons learned and best practices.
Yeah, right.
I'll look at PHP again when its massive function library is refactored into functions.
There should be no need to write:
$arr = array();
array_push($arr, 42);
When it could be:
$arr = new Array;
$arr->push(42);
i got a few php scripts on a cronjob to do database backups and such things.
i also use it for quick admin type hackie scripts.
personally i recon it's far superior to bash/perl/etc for shell scripting
I'm really getting tired of seeing that particular bit of nonsense trotted out in every discussion here.
To set the record straight: STATIC TYPING HAS NOTHING TO DO WITH VERBOSITY.
Java is verbose, and Java is statically typed, but that does not mean that all statically typed languages are verbose, any more than it means that all statically typed languages are Java.
Consider Haskell, where the quicksort algorithm can, famously, be written in two lines of code:Note the total absence of type declarations. In fact, this function will work on values of any type that can be sorted. And it's also completely statically typed.
Welcome to the world of modern programming, where convenience doesn't have to mean flinging safety to the winds.