Live data from Hacker News

PHP is much better than what you think

fabien.potencier.org

71–80 of 346 posts

Re: PHP is much better than what you think

#71
post #35

Namespaces, closures and traits are "all the bells and whistles you might dream of in a modern web language"? Really? Now I understand why Lisp users are smug. And that's ignoring the basic syntax touted as a feature . What I actually dream of in a web language (or any language, for that matter) is quite a bit more. I want to be able to get event-driven IO without writing event-driven code. I want to get parallelism…

Well, we can all dream, but what are you using now do get things done and make a living? I'm pretty sure Python and Ruby fail your criteria. Using the "perfect language" is a luxury that I for one can't afford. I need something that I can use reasonably easy and that is sought by employers. The fact that is has event-driven IO and parallelism (what kind of parallelism do you need for web sites?) is nearly irrelevant.

Yes, Python and Ruby do fail my criteria. Which is why I don't advocate them either.

I'm currently using OCaml, but I would probably prefer to use Haskell. They are both far ahead of PHP.

Assuming your website is doing anything non-trivial, parallelism would certainly be useful. Just because it's a web project does not mean you're not doing something computationally intensive, after all. But even if you don't need it, it certainly doesn't hurt to have the option!

Event-driven IO allows you to maintain more connections on the same resources than a thread-based model. There is just less overhead per connection. That's going to be relevant for most web projects. If you could get this for free (that is, without having to rewrite your code like in Node.js), why wouldn't you want it?

Just because employers seek PHP does not make it a good language, or even not a bad language. It just becomes a necessary evil.

Besides, that depends entirely on the job market in your area. Where I am (near SF), PHP is not in very high demand where Java, JavaScript, Python, Ruby and Objective-C are. I've also seen jobs using Haskell, Scala and (obviously) OCaml. This is obviously going to be different elsewhere, but my point is that it's all relative and not a function of any particular language's quality.

Re: PHP is much better than what you think

#72
I'll admit, the new-ish built-in web server in PHP is fantastic and it definitely makes me want to use PHP more often. Configuring Apache, setting up virtual hosts, fixing directory permissions, etc. was horrible.

Composer also looks cool, and I'm going to give it a try. I never understood PEAR/PECL/etc and was never quite able to get them to work properly.

Re: PHP is much better than what you think

#73

People who argue for PHP as a language always brings up this one argument: "PHP gets things done". Great. It get things done. Quick and dirty, but it gets things done. That is all fine and dandy, but what when you need things done proper ? How does it stack up then? Oh. You mean you have to consider input-data as actual text, not as some byte-streams which incidentally maps to the same character-set you used to write…

I'll play devil's advocate here.

Define "proper"? Does meeting a business need, bringing in money, putting food on the table, and paying the rent mean "proper"? If not, why not?

PHP has a plethora of flaws, but it's still a serious tool and used to build creations of significant value, that can't be ignored. As far as quality, what platform do you use to guarantee quality? I've heard many stories about terribly broken code bases in every language that's out there, from C to Ruby and Python to Java.

Re: PHP is much better than what you think

#74

People who argue for PHP as a language always brings up this one argument: "PHP gets things done". Great. It get things done. Quick and dirty, but it gets things done. That is all fine and dandy, but what when you need things done proper ? How does it stack up then? Oh. You mean you have to consider input-data as actual text, not as some byte-streams which incidentally maps to the same character-set you used to write…

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.

Re: PHP is much better than what you think

#75

People who argue for PHP as a language always brings up this one argument: "PHP gets things done". Great. It get things done. Quick and dirty, but it gets things done. That is all fine and dandy, but what when you need things done proper ? How does it stack up then? Oh. You mean you have to consider input-data as actual text, not as some byte-streams which incidentally maps to the same character-set you used to write…

I think with the proper tools (and I don't mean using the bare language, but enough libraries that give you nicer abstractions), it can be used for doing things properly just fine. Heck we do a living out of building custom apps for customers that range from financial world to data-oriented startups. You just have to know what you are doing, like with any language really.

- The mbstring ext gives you more or less decent transcoding support. I never had huge issues since it's generally ISO-8859-15 or UTF-8 I'm dealing with, but you may have a point. I can't answer conclusively.

- date handling overall is really great in PHP, I don't know about it in details in every language, but I know in some it's a massive pain. See http://php.net/DateTime and http://php.net/manual/en/intldateformatter.format.php for locale aware formatting.

- SQL injection is handled by the PDO db connectors just fine, and all libraries abstracting this basically take care of it. Unless you follow 10 years old tutorials it's pretty hard to have SQL injection leaks.

Etc etc.

The key is just this: know your tools.

Re: PHP is much better than what you think

#76

For reference's sake, this article is written by Fabien Potencier, the creator of the symfony framework. This guy's probably single-handedly responsible for lifting the PHP community to a higher level, by making great software (which, when he started, was pretty unique, with horrible hacks-upon-hacks like CakePHP being the norm), and by showing people how to do so.

The recent PHP releases are nice, but is there any plans about .. pardon me .. rewriting the core libs ? I guess they're close to zero. Even with a nice Object model, traits, closures and literals .. whenever I see old core functions poke it hurts. At the same time the world has moved: Scala, Go .. PHP still looks odd to me, even with his new found maturity.

Re: PHP is much better than what you think

#77

Hacker News really doesn't like PHP. There's a whole lot of blind prejudice in this thread Arguments against PHP are as futile as arguments in support of PHP. It's a programming language. The only thing that matters is the person using it. I'm sure Ruby, Node and Go are super duper awesome in a lot of academic ways, but unless we're talking about awesome things that have been made with them, it's just blah blah blah…

"The only thing that matters is the person using it."

Well, sure, I guess if you're really strange, you can be as efficient with Brainfuck as you can be with Python.

Re: PHP is much better than what you think

#79
post #12

I'd stay away from a language that has function names like array_keys or allows you to write array("a" => "green", "red", "blue");

I find PHP's arrays amusing. It's as if Rasmus couldn't decide whether they should be associative or indexed, so he made them both.

Although I suppose, strictly speaking, JavaScript has the same thing. (not intentionally, but you can make an array that is both if you really want to)

Re: PHP is much better than what you think

#80
post #62

Earlier quoted context omitted.

Saying PHP is good because Facebook use it is kind of like saying phone hacking is good because it was utilised but some of the UK's most popular newspapers... I'd be interested to know if there's any commentary from people high up in Facebook on whether they'd use PHP again if they were starting now?

What kind of an analogy is that? It is not only flawed but does not relate to your argument. I guess the point that illumen was trying to make is that PHP can be used in popular real world applications and is "proven" to scale. Just like Facebook, you can look at Wikipedia, Wordpress, Tumbler or earlier days of Youtube all of which was/is written in PHP! Be comfortable with the language you prefer and quit whining ab…

In no way whining about PHP, I still maintain various projects which use it and for which I think it's well suited.

The analogy was only meant to demonstrate an objection to arguments along the lines of "it's used by something popular therefore it's good" or "lots of people use it therefore it's good" which seem to be common points put forward in favour of PHP.

Popularity/ use by someone popular may be an indicator of quality but it very often isn't, the analogy isn't intended to go any further than that!

Post reply on HN