Live data from Hacker News

I Like PHP

beust.com

181–190 of 269 posts

Re: I Like PHP

#181
post #151
post #122

Earlier quoted context omitted.

This is still the main reason why I use PHP: the development cycle is just so fast, and if you are experienced enough to write good code without anyone holding your hand, you can do great work in PHP in a much shorter period of time when compared to most other platforms (at least the ones I've tried). When people criticise the PHP language I think they really miss the point: it is the PHP platform that is really powe…

Yep. And compared to Rails, something like mod_php is just so much faster and less resource hungry, it hurts. I use both regularly in production, and scaling the PHP side is almost trivial compared to the rails side.

Sorry to nitpick but that isn't scaling. Unless I can add double the number of machines and double or almost double the capability, and keep doing so to thousands of machine your application doesn't scale.

In the case of web applications all tend to scale equally well as you can just add another web server. Its the database that causes the scale issues.

Re: I Like PHP

#182

The core of C is small enough that you can fit it in your head. PHP has so many functions that it's almost impossible to write it without googling php.net, etc. Not that this matters so much, Google is fast and omnipresent, but in that sense they are definitively not alike.

Almost impossible? Pop quiz: The case-insensitive version of "strpos" is "stripos", what is the case-insensitive version of "strcmp"?

Re: I Like PHP

#183
post #98

Earlier quoted context omitted.

The problem is that people go too far with the bashing- People tend to just sneer at anything PHP-related, and don't acknowledge that great work is being done every day in PHP. An app written in PHP by a 8/10 programmer is going to be better than an app written in (sexy other language) by a 7/10 programmer.

> An app written in PHP by a 8/10 programmer is going to be better than an app written in (sexy other language) by a 7/10 programmer. Depends entirely on your metric. It's far too easy to introduce subtle bugs, especially security oriented ones, in PHP. If I had a dollar for every XSS, remote file inclusion, CSRF, arbitrary file read, etc vulnerability I found in a "good" PHP app, I'd be a very wealthy man. Some thin…

None of the things you listed have anything to do with PHP, they can happen in any language.

Re: I Like PHP

#184

From the comments: "PHP is great for its purpose. Quick scripts that generate web content. It’s even OK for small applications. But just like C, PHP is lousy for the medium to large. Any software project with a duration in months or greater that is entirely in PHP is going to be painful." Like Facebook? Or Wordpress? Or Digg? PHP aint perfect, but it's demonstrably suitable for medium to large projects.

That's like saying because the Pyramids were built in stone, we should build all our skyscrapers in stone. I bet that if Facebook, Wordpress or Digg were built in Ruby on Rails or some other modern language, they would be exponentially faster and easier to develop and maintain.

Most of the time, performance is more a factor of system architecture and choice of algorithms/data structures - and less about the language you're using.

Unless you're doing very CPU intensive computations where every millisecond counts, the difference between most languages won't be that great in the big picture.

Re: I Like PHP

#185
post #78

Earlier quoted context omitted.

> Did you ever read Python's documentation? Yes. it's rather fucking good. > Show me one popular web programming language which has a full page, up to date, with examples and user comments and version incompatibility info, per function. Have you ever read Python's documentation? In the last ten years? Python's docs have a complete and readable description of the language[0] including its data model and the various co…

Don't forget being able to do this from within the interpreter: >>> print abs.__doc__ abs(number) -> number Return the absolute value of the argument. >>> print xrange.__doc__ xrange([start,] stop[, step]) -> xrange object Like range(), but instead of returning a list, returns an object that generates the numbers in the range on demand. For looping, this is slightly faster than range() and more memory efficient.

I usually use the help function, instead of reading __docs__ directly.

Re: I Like PHP

#186
post #179

Earlier quoted context omitted.

That's like saying because the Pyramids were built in stone, we should build all our skyscrapers in stone. I bet that if Facebook, Wordpress or Digg were built in Ruby on Rails or some other modern language, they would be exponentially faster and easier to develop and maintain.

> I bet that if Facebook, Wordpress or Digg were built in Ruby on Rails or some other modern language, they would be exponentially faster I'll take that bet.

They'd probably be linearly faster.

Re: I Like PHP

#187
post #23

"I don’t even bother writing tests for most of the PHP I write (obviously, I would be a bit more thorough if this code were destined to be used in a more mission critical web site). Not writing tests is not the only software taboo that I break when I write PHP: I happily mix up presentation and logic all the time. That’s just how PHP is supposed to work" And this is why everybody else hates PHP. It tempts you to writ…

Can you please provide me a resource to learn how to fully separate the code from the markup? I learned web development on ColdFusion then switched to PHP. I certainly understand separation of content from design (HTML to CSS) but I honestly have no idea how to do web development without mixing markup (HTML) with the actual programming. I've done a little C and Java web stuff where my code printed HTML output - ugly.…

On why you might not want to mix your markup with the templating logic (copied from a blog post I wrote a while back [1]):

- Designers and developers will have a hard time working on the same file, especially the designers who don’t necessarily understand the templating rules language, and can easily break the whole thing when trying to modify the file.

- Also, when provided with a new version of the template text (say, a new version of the HTML from the designers), it’ll be hard to incorporate the modifications into the original template with all the template rules scattered inside it.

Regarding how to generate dynamic markup and not mixing the markup with templating logic, I'll cite approaches like Apache Wicket [2] (although you still need to add a couple of attributes to the markup) and server-side jQuery like select and transform templating, such as what is done in Enlive [3] and Moulder [4] (a pet project of mine)

[1] http://jawher.net/2011/01/06/on-templating-and-a-shameless-p...

[2] http://wicket.apache.org/learn/examples/helloworld.html

[3] https://github.com/cgrand/enlive/wiki

[4] http://jawher.net/2011/03/03/moulder-in-action/

Re: I Like PHP

#188

Earlier quoted context omitted.

That's like saying because the Pyramids were built in stone, we should build all our skyscrapers in stone. I bet that if Facebook, Wordpress or Digg were built in Ruby on Rails or some other modern language, they would be exponentially faster and easier to develop and maintain.

Most of the time, performance is more a factor of system architecture and choice of algorithms/data structures - and less about the language you're using. Unless you're doing very CPU intensive computations where every millisecond counts, the difference between most languages won't be that great in the big picture.

The quote was "they would be exponentially faster and easier to develop and maintain".

Re: I Like PHP

#189
post #89
post #23

"I don’t even bother writing tests for most of the PHP I write (obviously, I would be a bit more thorough if this code were destined to be used in a more mission critical web site). Not writing tests is not the only software taboo that I break when I write PHP: I happily mix up presentation and logic all the time. That’s just how PHP is supposed to work" And this is why everybody else hates PHP. It tempts you to writ…

This is unfortunately true. I'm a PHP programmer (currently writing a book, A Highly Negative Book About PHP , that I've been billing as "like Essential Java but tells you what not to do") and, I like to think, a fairly good one; reading this article made me cringe because this guy is emblematic of most of the problems in the PHP community. He: -accepts uncritically gobs of code dredged up via Google -considers somet…

"-considers something "robust" if it doesn't break old code, when the rest of us hate it because we have to live with register_globals and other horrors"

Agreed - as a PHP programmer (mainly in Zend Framework), who is now learning Python... I hate register_globals. With a fiery passion.

More importantly, as someone who hosts several photographer websites, I have a bone to pick with http://bludomain.com/ - congrats on your eighth birthday. Have you updated your code since you were born? It's a travesty that involves turning on almost every deprecated option in a php.ini. :\

Re: I Like PHP

#190
post #174

Keep in mind that perhaps a majority of wordpress.org sites that have been around for a year or more have been hacked in some fashion at some point, and that the reason is because PHP encourages the kind of terrible code and unsafe-by-default environments that make this possible. Edit For example, I am thinking of how various templating languages, including Jinja2 (for Python) default to auto-escaping strings you're…

WordPress sites get hacked because the owner fails to update the platform or install 3rd party scripts/plugins without any sort of logical research.

This can be said about any platform, regardless of the language.

Post reply on HN