Live data from Hacker News

PHP is much better than what you think

fabien.potencier.org

241–250 of 346 posts

Re: PHP is much better than what you think

#241

PHP is big because 10 years ago, it was the best choice. Back then, the non-microsoft options were Perl, ColdFusion, Java, and PHP. PHP was the best for web development out of that. This isn't the case anymore. PHP has been far surpassed by Python and Ruby. PHP is a wonderful templating language. Where does my opinion come from? I switch us from PHP to Python after writing a large CMS in PHP.

I've written "large" systems in PHP and some things annoy me, but I imagine this is true with other languages too (I hear from Ruby and Python devs all the time, some things get annoying).

That said, I spend most of my time on the web writing templates, and PHP is amazing at making that easier. There's a good reason PHP is used in ~78% of all web sites -- most of them are basic blogs or content sites.

Most web development is just templating attached to a business model layer, so why not use a language ideal for templating?

Re: PHP is much better than what you think

#242

One major problem I see in this article is that the stats that are cited as "proof" that PHP is the most widespread language are skewed. * The sample is not representative. It's the top 1 million according to alexa. * The percentage cited is "x percent of all pages that we can determine are..." which skews heavily in favor of PHP since PHP exposes it's version by default at least in older versions while other languag…

> (heck, why do I need to call 'php composer.phar' instead of 'composer'?)

You can.

http://getcomposer.org/doc/00-intro.md#globally

    $ curl -s http://getcomposer.org/installer | php
    $ sudo mv composer.phar /usr/local/bin/composer
    $ composer --version
      Composer version 6573fd3

Re: PHP is much better than what you think

#243

Earlier quoted context omitted.

I'll be intellectually honest and admit that, no, I haven't really touched PHP for anything near a production app in the last 5 years. But to be absolutely clear: before PHP used to be the only language I wielded for money. I have enough lines of PHP on my back to claim the right to an opinion. That said, last time I looked into PHP, modus operandi seemed to being focusing on making things easy, not making it easy to…

The PHP interpreter is much like any other compiler or interpreter. It will halt on errors. It will, by default, output warnings/notices for things like accessing uninitialized variables. Like any other compiler or interpreter, you can tell it to hide warnings, or to halt on warnings, or to log them somewhere instead of outputting them. What makes this a fundamental weakness of the language, but not of, say, C, where…

C is intended to be low-level, like an extra fancy set of macros for writing assembly. It is intentionally not supposed to do that much for you because you need greater control to do things like writing UNIX. Nonetheless, if you use it seriously then you will find that gcc does outright refuse to compile a great many things that it recognizes as broken, rather than chugging along. There is no way to simply suppress all compiler errors because there should not be.

Nobody in this discussion has raised the possibility of writing web apps entirely in C and suppressing all compiler warnings as they did so. That is a scary idea. And it gets even scarier if we are advocating for newbies to start writing web apps that way.

Re: PHP is much better than what you think

#244
post #32

Earlier quoted context omitted.

"PHP is easy to deploy on. That's it. That's why it's popular. It's braindead easy to go from text editor to web URL, it's braindead easy to unzip someone else's project and run it. It requires virtually zero sysops experience to be able to use. You don't even have to worry about setting those +x bits like you used to in the good old cgi-bin days." And that's exactly why PHP is the better choice for those of us who d…

But it still doesn't make PHP a good programming language. I am doomed to fix legacy PHP projects for the rest of my life, because they are so badly written they simply cannot be upgraded to newer versions of PHP. Yes it's popular and I've even seen designer jobs asking for php knowledge (lol), but that just tells us why it's so hated! The new PHP might be great, but all those numbers the article has don't tell us ho…

> it simply lacks everything

Can you elaborate on that a little please? What does PHP not have that all the other choices offer that make such a big difference?

Re: PHP is much better than what you think

#245

One major problem I see in this article is that the stats that are cited as "proof" that PHP is the most widespread language are skewed. * The sample is not representative. It's the top 1 million according to alexa. * The percentage cited is "x percent of all pages that we can determine are..." which skews heavily in favor of PHP since PHP exposes it's version by default at least in older versions while other languag…

> (heck, why do I need to call 'php composer.phar' instead of 'composer'?) You can. http://getcomposer.org/doc/00-intro.md#globally $ curl -s http://getcomposer.org/installer | php $ sudo mv composer.phar /usr/local/bin/composer $ composer --version Composer version 6573fd3

right. I could write a short shell wrapper as well - but why do I have to? I don't have to with pip or bundler.

Re: PHP is much better than what you think

#246

What would happen if you could put a tag with python code right in a page just like you do with the tag? Is this even theoretically possible? I feel like the biggest advantage PHP and classic ASP have is that there is a low barrier to get the most basic dynamic content working. If you're not a programmer, you don't need to understand a framework or a design pattern to get things going.

There's no reason you couldn't. It wouldn't be Python, but you could do it by defining a new file format to be parsed by the server (mod_whatever).

The earliest Python web frameworks were obsessed with this kind of stunt and it gave rise to a profusion of templating engines, some of which look pretty much exactly like what you are discussing.

I think what happened is that people tried it and found that the advantage is not that great, but the disadvantages are substantial for things significantly beyond "hello world".

Re: PHP is much better than what you think

#247
post #201

Earlier quoted context omitted.

> I suspect that parent was referring to the python 2.x branch, which has been catching up with ruby 1.9, but on most benchmarks started at ~ 3x slower and are now ~ 2x slower. Citation needed again. Ruby 1.9 is slower than Python 3, and Python 3 is slower or as fast as Python 2 on Python official benchmarks. http://docs.python.org/release/3.0.1/whatsnew/3.0.html#perfo... > Since benchmarks are completely worthless,…

Fib(36) Python 2.7.2 def fib(n): if n == 0 or n == 1: return n else: return fib(n-1) + fib(n-2) for i in range(36): print "n=%d => %d" % (i, fib(i))' python -c 20.69s user 0.06s system 99% cpu 20.807 total Ruby 1.9.3 def fib(n) if n == 0 || n == 1 n else fib(n-1) + fib(n-2) end end 36.times do |i| puts "n=#{i} => #{fib(i)}" end ruby 11.44s user 0.03s system 99% cpu 11.507 total I guess since benchmarks are not comple…

> I guess since benchmarks are not completely worthless,

The original keeps getting re-iterated: http://programmingzen.com/2007/11/28/holy-shmoly-ruby-19-smo...

The original author, on a basis of a fib benchmark, concludes ruby 1.9 is faster - that is as flawed as it gets.

Did you try running with Python 3? You will get around the same time as you get with Python 2.7. Pick anything from here http://shootout.alioth.debian.org/u64q/benchmark.php?test=al... and run it with Python 2.7 and ruby 1.9. The programs which are faster with Python 3 will be mostly faster with Python 2.7. 2.7 isn't slower than ruby 1.9; it is faster in most of the cases.

Regarding the fib example, when the original was doing the rounds, I didn't find any explanations from python or ruby implementors. I can't say why, but most likely python has a higher overhead with growing call stacks, and ruby does some optimizations.

Re: PHP is much better than what you think

#248

Earlier quoted context omitted.

Have you written a production app for PHP in the last 5 years? It handles (out of the box) multibyte encodings, locale-aware number and date formatting, parameterized prepared statements for your SQL, etc as well as most any language.

I'll be intellectually honest and admit that, no, I haven't really touched PHP for anything near a production app in the last 5 years. But to be absolutely clear: before PHP used to be the only language I wielded for money. I have enough lines of PHP on my back to claim the right to an opinion. That said, last time I looked into PHP, modus operandi seemed to being focusing on making things easy, not making it easy to…

HTML also chugs along at all costs:

You don't have to close tags,.

You can add(misspell) unknown attributes to tags.

works the same as

You can have multiple tags with the same ID field.

You can do ALL that and your page will still render, and probably look just fine. That's a major reason why the web took off. Because it didn't take perfection to get something done. Anyone that wanted to make a webpage could fumble around and make something that looked like a webpage.

Perhaps the web would be in a better place if browsers gave an fatal error if it tried to load a page that doesn't validate ... or maybe there wouldn't be a World Wide Web, much like there aren't any CueCats lying around.

Re: PHP is much better than what you think

#249

I am so sick of this kind of talk. What language do you like to code in? Really? That's great. Now shut up and go code in it. What difference does it make to you that I use PHP, Ruby or original ASP? My website achieves the result I desire. I chose the programming language I use because of reasons that made sense to me and my project, not because I want the approval of a bunch of hipster start-up kids.

To be fair, this has been a while coming. There's so much PHP bashing that takes place now it's ridiculous. People take inefficiencies of the language from 5 years ago, tart them up as crimes against humanity, and then pretend that the only reason PHP is more popular than their language is because most people aren't smart enough to code in their language. Fabien, though I sometimes disagree with his technical choices…

A number of these critical articles point out problems from 5 years ago... which are also still problems today.

I would have more sympathy if it were clearly evident that serious bugs were taken seriously rather than being ignored for a decade

Re: PHP is much better than what you think

#250
post #229
post #131

Earlier quoted context omitted.

You are deliberately trying to miss the point. But in the off chance that you don't really get it, the point is quora, asana were started by early facebook programmers, and they didn't use PHP. If they liked PHP so much, they would have used it. I can't find a citation, but there was a thread where a fb engineer claimed fb's internal PHP wiki starts with "There are two kind of people. People who hate PHP, and people…

> If they liked PHP so much, they would have used it. Or they got tired of being bullied by people like you.

>> If they liked PHP so much, they would have used it.

> Or they got tired of being bullied by people like you.

Or they really aren't a fan of PHP?

http://www.quora.com/Quora-Infrastructure/Why-did-Quora-choo...

Post reply on HN