Ask HN: Why no love for PHP?
Is it because PHP isn't considered a "serious" language, and is mostly the realm of "designers" and "script kiddies"?
Do the developers who visit this site all code in Ruby, Erlang or Objective-C? Are PHP developers a minority in this community?
I play with Ruby & Objective-C on my own time, but at work it's an all PHP shop. We primarily use the Zend Framework, and honestly it's pretty good (good enough for IBM...). With the recently announced build tools, and some of the classes we've developed on top of ZF, I can develop just as quickly in PHP as I can with RoR.
PHP is also fairly popular with successful startups. Larger sites like Digg, Flickr and Facebook are using at least some PHP to scale to fairly massive traffic; even Wufoo (a site which I feel represents what so many of us here are trying to achieve in essence) is written in PHP.
I will agree that PHP is a bit of a mess (backslashes for namespaces?), and that the internet is full of the wrong way to use it; however, there certainly are talented developers writing quality software in PHP. Is there no interest in that here?
Apologies if this is a rehash of a tired topic; I poked around for a few minutes and didn't see anything relevant/recent.
[+] [-] unexpected|17 years ago|reply
PHP is like buying a chef's knife at Wal-Mart. You can create a 5 star dish with it, it cuts perfectly fine, but it doesn't inspire the same passion that a Shun knife does.
Most restaurants in fact, don't use fancy-knives, they use just regular knives and it works out just fine.
But, to draw the analogy back to programming, we're not regular restaurants. We're wannabe "rock-star" chefs- coding and "startup-ing" isn't just a job, it's part of our core ethos, so we obsess over all the tools we use, the text editor, the monitor, even the chair- because it makes the experience all that much better.
Most people do this about things they seriously care about. Runners debate intricacies of running shoes or the perfect in race meal. I've had debates with weight-lifters about weight-lifting gloves. Go over to a different forum, and you will hear arguments about the perfect size of a suit lapel.
The "Everyman" tools can always accomplish 100% of the job, but provide 90% of the experience. We spend an inordinate amount of time trying to get that last 10% out.
Is it probably unnecessary? Yeah. But people really bond over passions, and in arguing/debating that last 10%, you can really connect with people, which is why sites like Hacker News are fun and addictive.
[+] [-] edw519|17 years ago|reply
Your analogy reminds me of the greatest cook ever, my grandmother. She used no technology whatsoever. All of her tools had been her mother's which were probably manufactured in the 1800s. She chopped everything by hand in a wooden bowl. (If anyone else helped her with the chopping, everyone at dinner could tell.) She never used pencil or paper and measured nothing. She stood in line at the farmer's market, the butcher, or the grocery store and inspected every item. And absolutely nothing I have ever eaten since, in any restaurant or home, has been remotely close to hers. It was magnificent! And I miss it so much.
I'd like to think I have almost as much passion about my work. I use the most primitive tools, 24 x 80 green screen editor, no framework, no IDE, no debugger, and mostly pencil and paper. I savor every byte just as I imagine my grandmother savored every little detail of her cooking. I'm not trying to save time or be fast, I just aspire to creating Grandma-quality software. I only hope my software brings someone the same joy her food brought all of us.
I've used many different tools, including php. And I rarely care how fancy they are. Ironically, the simpler, the more joy I have found along the way.
[+] [-] agotterer|17 years ago|reply
PHP has an extremely low barrier to entry. Its a loose language (lets not argue about this right now) that someone can get their feet wet relatively quick. These developers never really learn the true power of PHP, they aren't passionate about their projects and they dont contribute back to the community. They dilute the pool of truly passionate PHP developers.
Owning a Shun knife just lets everyone around you know that you are "serious" cook. But hell, I like to cook too.
[+] [-] pbhj|17 years ago|reply
Actually a lot of top artists don't. Not only because paint isn't their medium but because they don't do the work themselves. They have the ideas and then they employ minions to do the actually work of making the piece. Personally I think that makes them less than an artist, but they're the ones selling work for 100s of thousands of £s
F'real.
[+] [-] xiaoma|17 years ago|reply
Most people do this about things they seriously care about. Runners debate intricacies of running shoes or the perfect in race meal."
And yet one of the most grueling races in the sport of running, the 100 mile, 10000ft altitude Leadville 100 has been won more than once by a man not wearing true shoes at all.
This isn't an isolated example, either. Many masters of many fields focus on their skills rather than their equipment. Often those with the most expensive golf clubs, are those trying to compensate for a lack of skill. The same is true of photographers an their cameras. Miyamoto Musashi even went so far as to regularly arrive at duels with a wooden sword.
Tools can give someone an edge, but IMHO they aren't the right place to focus one's obsession.
[+] [-] unknown|17 years ago|reply
[deleted]
[+] [-] dean|17 years ago|reply
[+] [-] weavejester|17 years ago|reply
[+] [-] badger7|17 years ago|reply
I'm a chef, and I don't want to talk about knives. I don't care that my knives are basic; taste my cooking. I don't care that your knives are wonderful; I want to taste your cooking.
There's a reason that taste tests are done blindfolded, you know - ugly but delicious trumps beautiful but foul, every day of the week and twice on Sunday.
[+] [-] mdasen|17 years ago|reply
* PHP attracts idiots. Partly that's because you don't need to know anything to make simple PHP. So, in the large pool of PHP programmers, there are a ton of idiots. And those idiots produce a lot of verbose code that gets used because it does something. Ruby, Python, Perl, etc. all put up a larger barrier because they don't just come with a session handler or whatnot built in. And that weeds out more of the idiots. Doesn't really have to do with PHP the language, but it is nonetheless significant.
* PHP has a bad type system that leads to errors. There, I said it. The fact that 0 == "string1" and 0 == "string2", but "string1" != "string2" is unacceptably bad.
* PHP has no namespaces. Yeah, they're planned for 5.3, but the implementation is just ugly. This makes it more likely to botch something in a larger project.
* Which leads me to my next point: include/require. In PHP, it's decently common to say require('some_file.php'); and just grab a huge hunk of code. Eww! That code could be doing anything - adding in variables, executing code, etc. While it's true that other languages can do that as well, that's generally not the case - other languages are more in favor of importing objects or functions. Partly it's a language thing, partly it's a culture thing.
* Magic! So, how does mysql_query() know which database to connect to when you don't pass in a database connection? I mean, I'm guessing they're either using a global or if it's in C a static external variable, but PHP is littered with this crap. It's not necessarily bad, but it's magical.
* Functions! So, PHP now has cool object oriented stuff. Still, it doesn't use it at all. I don't object to strlen($var) that much when compared to $var->len(), but there are other cases where it's just crappy. So, PHP has a function strpos() which will return the position of the first occurrence of a substring within a string. Quick! In what order do you put the variables? In this case, it's string to be searched, search string. What about preg_match()? Oh, there you put it in the reverse order! And really, when writing functions, there is no "proper" order, but if you're doing $string.preg_match('/^apple$/'), there's a clear order.
* Looking more at preg_match(). What does it return? It doesn't return a match, it returns a count of the matches it finds. If you want the matches, you need to pass in a variable that it will take a pointer to as an argument so that it can place the matches in there. Bleh! How would this be done in a nice OO-way? $var->preg_match('/^apple$/').count() would get you the count and otherwise you get the match returned. Easy in a way that requires less memorization of weirdness and doesn't feel so wrong. And crappy things like that are done throughout PHP where things are weird, but end up
* php.ini. Terrible idea. PHP allows you to change very important things install-wide, directory-wide, app-wide, ick-wide! It's not just magic quotes. It's more that you never quite know what you're deploying to in a bad way.
Finally, it's that PHP is an older-style language without the cool things that newer languages can do. PHP isn't bad per-se, but it isn't good either. The biggest thing it has going for it is that it's easy on shared hosting. With VPSs coming down in price to the point that they don't represent a huge premium over shared hosting, that's become less of an attraction. PHP is fine, but there's a decent amount to get annoyed with when creating a larger application.
[+] [-] dasil003|17 years ago|reply
I jumped headlong into Rails 4 years ago after having been enamored with Ruby over Perl for sysadmin type scripting and text-munging. Yeah Ruby has some bad warts too (the runtime!), but the quality of code in the community is an order of magnitude better.
[+] [-] Todd|17 years ago|reply
If you're new to programming, don't waste your precious memory to inventorying an ugly mass of built-in PHP functions. Just pick Python, Ruby, C# or something else--anything else. If you have to learn it for your job, well, learn one of the other languages anyway.
[+] [-] pbhj|17 years ago|reply
Bit harsh. People are not idiots because they haven't studied computer science and don't know their algos from their elbows.
PHP is easy for quick and dirty - primarily business doesn't care how dirty the code is provided it's done quickly and the crashes don't hurt the bottom line too much.
[+] [-] encoderer|17 years ago|reply
For example, about typing... your argument is that when you cast a string to an int, it returns 0. What would you have it return, null?
Typing is jank in a number of ways, but in most cases I See the logic in the original decision. To a noice, the idea that false == "false" (because "false" casts to 0) but true != "true" just seems broken. But what else would you have it do?
About namespaces, people are complaining that PHP should use the dot operator like every other language. PHP uses dot for concat, which eliminates the ambiguity of using + for both concat and addition that exists in other languages. Now, they're going to use a backslash for namespace resolution. And that does create operator ambiguity. So PHP trades one ambiguity (dot) for this other.
And what do you possibly mean by "older style language"? Do you mean functional features? As you probably know, lambad's and closures will be available in 5.3. I agree that Python (my language of choice) and even C# (my 2nd fave) seem cleaner. But of course they do. They're new. Java seemed clean in 1997, too.
And finally.. I do value consistency in userland code and in the runtime. And PHP is horribly inconsistent. A salvation army of a language. But that stopped actually affecting me about 8 years ago when I left behind VIM for a real IDE with intellisense.
[+] [-] zmimon|17 years ago|reply
PHP has terrible unicode support. Almost uniformly every app that starts out using the default PHP function set ends up failing horribly when data with non-european (or even just non-ascii) characters end up in it. There are a whole lot of kludge workarounds, but they're basically an admission of defeat rather than a real statement of support.
[+] [-] zackattack|17 years ago|reply
[+] [-] tannerburson|17 years ago|reply
Almost all of the cool concurrency, natural language, efficiency, functional programming, and what-have-you research and development, is going on outside of the PHP community. Those are topics that HN collectively finds interesting, so PHP gets left out.
That said, just because PHP itself isn't particularly interesting, doesn't mean people don't build interesting things using it, and doesn't mean you shouldn't use it.
[+] [-] indiejade|17 years ago|reply
There was an article on slashdot yesterday about PHP6. Here's one from IBM:
http://www.ibm.com/developerworks/opensource/library/os-php-...
Not a whole lot of new, but something. I think PHP gets ignored sometimes because it is an older language, not the new and trendy thing.
[+] [-] coglethorpe|17 years ago|reply
That said, I coded my first startup in PHP. It's dead simple to make a dynamic web page with PHP, but it's also dead simple to create a huge mess. In that sense, PHP reminds me of C. It's pretty simple to write an app in C, but there are 1,000 pitfalls.
Just like with C, there are definitely talented coders out there who can make PHP behave correctly. Sadly, they are a minority. Many of them move on to other languages and frameworks.
I've since moved on to Ruby (on Rails) as well as Python. Both languages offer simplicity and power. Rails, in spite of being the Dane Cook of frameworks, makes it extremely easy to create a web application.
[+] [-] JustAGeek|17 years ago|reply
Sure, there are plenty of apps containing holes but those are not caused by PHP but by not coding correctly, eg not checking input making SQL injections possible etc.
Which might confirm what you said, it's easy to create a huge mess with PHP.
But then, it's easy to create a huge mess in any other language, too. It's probably even easier with Ruby due to its highly dynamic nature.
Languages are like tools, you have to know how to use it but you can't blame the tool if somebody misuses it.
Edit: Fixed typo.
[+] [-] jlsonline|17 years ago|reply
I love Rails but the fanboy culture really sucks.
[+] [-] j2d2|17 years ago|reply
[+] [-] Brentley_11|17 years ago|reply
[+] [-] dbul|17 years ago|reply
What does that mean? I'll take the compliment, but I'm not sure what the difficulty is in making PHP 'behave correctly.'
[+] [-] ErrantX|17 years ago|reply
Mostly I'm a Python fan but for websites PHP is just 100% easier for me because I have a framework I know well (KohanaPHP) and years worth of snippets/experience to use in prototying sites. I bet I can code a simple site faster in PHP than Python.
As to why PHP isnt discussed much on here: well I will hazard a lot of people take the same approach. We love exciting stuff in Python, C and Ruby (well, not ao much ruby for me :P) but PHP is our grab-it-and-run language. If someone knocks on the door and says "make me XYZ website in 2 days" we will probably pull out the PHP.
Nothing exciting and new is really happening with PHP - it is doing what it is supposed to do: help us produce dynamic websites fairly quickly with little fuss. So we can get on with the real job of hacking in Python (or Ruby or C or..... etc.) :D
I could be wrong :)
[+] [-] RossM|17 years ago|reply
I don't agree that there's nothing interesting going on though. I'd like to see some more innovative extensions (which might be because they are coded in C) but PHP Classes (http://phpclasses.org) is constantly producing PHP libraries and snippets for common tasks
[+] [-] KrisJordan|17 years ago|reply
The results of my last push evolved into a PHP framework: Recess. (http://www.recessframework.org) It's got annotations for a declarative, meta-programming style. It's inherently RESTful (and more fine-grained content negotiation is coming soon). The Models/ORM are lazy so that you can chain together queries that evaluate at the last minute. Recess deploys just fine to commodity $5/mo servers and was designed to be lightweight and fast without giving up object-oriented design (a la Code Igniter).
What I feel gets lost in the "PHP is terrible" literature is a distinction between PHP as a programming language and PHP as a technology / platform. As a programming language, from an academic perspective, PHP is embarrassing. As a technology/platform it's incredibly well suited for web applications because that's exactly its intention. PHP's shared-nothing execution model, simple deployment, efficiency & performance make it a great technology for authoring web applications. Tooling has gotten much better too with Eclipse's PDT & XDebug.
If you're growing tired of PHP and looking for a platform/framework to develop on that is more productive and enjoyable try taking Recess for a spin. For me, at least, it's made PHP fun again: http://www.recessframework.org/
[+] [-] cardmagic|17 years ago|reply
As I already mentioned, PHP is not an OO language. It is a language that has OO as a feature, but the core API is not OO. This creates a very awkward mix of OO and procedural code.
One of the most embarrassing things about PHP comes from its complete lack of naming and ordering conventions. Look at the array functions. http://us.php.net/manual/en/ref.array.php 47 of these functions start with array_, 25 of them are a mismatch of whole words and partial words that happen to do array functions. The reason PHP documentation is so good is out of necessity. Without fantastic documentation, PHP would be completely unusable due to this staggering oversight.
[+] [-] JeremyChase|17 years ago|reply
I think RoR is one large reason why PHP is looked down now. More specifically, there isn't a leading PHP framework that has a proven following or as well executed marketing plan. There are a lot of PHP frameworks, but none that capture the attention of the masses like RoR.
The other argument I hear is that the language is annoying to program in. This just doesn't not compute in my brain as PHP code looks perfectly normal to me. I think that some people just prefer certain syntax, and I have yet to come up with a reason that I understand.
As you have probably guessed I have been a PHP fan for years, but I recently started seriously using Ruby/Rails for some side projects. There are two reasons I am playing with this instead of cakePHP/KohanaPHP/Symfony/Zend
1. There is a lot of literature about Ruby/RoR
2. I found myself resisting Ruby/RoR, and I don't want to be the old guy that won't learn new technology
[+] [-] ErrantX|17 years ago|reply
I've never "got" RoR. Python makes sense to me as a killer all-purpose language just as PHP makes sense to me as a niche for-the-web language (I cant get these people that insist on running PHP standalone :o). But I never quite figured the rails niche.
[+] [-] breck|17 years ago|reply
With a simple ORM class and a class for handling forms and inputs, PHP gives you wings.
[+] [-] jlsonline|17 years ago|reply
Nobody gets excited about it anymore because it solved the problem it was aiming to solve a long, long time ago.
[+] [-] unfug|17 years ago|reply
At work we are still mostly a PHP shop, but anything I write on my own now gets done in Python. PHP's complete lack of a coherent function naming scheme is enough reason alone to get away from it.
[+] [-] Jem|17 years ago|reply
[+] [-] jcapote|17 years ago|reply
[+] [-] garethr|17 years ago|reply
[+] [-] Zak|17 years ago|reply
I'm inclined to agree. If you know how to advertise within a language community then using a lesser-known language will make it easier to find good programmers. This is probably even true for the short-term contract gigs often posted to freelance sites since there won't be hundreds of low-quality responses to sort through.
[+] [-] ionfish|17 years ago|reply
http://news.ycombinator.com/item?id=468493
[+] [-] breck|17 years ago|reply
We use PHP because at the end of the day startups are a job, and you've got to be creating value. I find that PHP gets the (web development) job done better than anything else.
Is programming in Ruby or Python more fun? Way more fun! But in the end, all that really matters is what happens when someone points their web browser to a URL. PHP was built for this use case and the whole LAMP stack solves this problem extremely well without needing any additional frameworks on top.
Also, as ugly and awkward as the C {}; syntax is, and as much as I hate not having certain features in PHP (i.e. chaining), I think there could be something special about that syntax that has understated benefits as evidenced by the sheer fact that the most widely used languages (C++,C,Java,PHP) all use it. Maybe it's just because that's what everybody knows and not because it's better. I'm not sure.
[+] [-] begemot|17 years ago|reply
[+] [-] JoelPM|17 years ago|reply
1) PHP isn't long-lived. Every time a request comes in Apache launches the PHP processor/interpreter and runs through the entire script. This means you don't get a heap that you can use to cache things[0], you don't get the benefit of JIT compilation, and you don't get the benefit of pre-compilation[1].
2) PHP development always seems to be tied tightly to a database. At some point an extremely high-traffic app will need to scale beyond what a DB (even a sharded DB) can support. To do this you have to think in terms of asynchronous processing, out-of-process updates, aggressive caching, and more.
The second point isn't really an issue of PHP, but more an issue of the PHP ecosystem - however, it affects the way I perceive the language itself.
Places that use PHP for high traffic sites seem to use it to build the presentation layer, which seems to work for them, but the majority of the work is being done by back-ends written in some other language.
[0] Yes, you can use memcache, but it still means, at the very least, a cross-process hop and most likely a cross-network hop.
[1] Compiling to bytecode (for Java) is still better than no compilation. Also, you only take the hit of starting the JVM once, not on every request.
[+] [-] dugmartin|17 years ago|reply
http://en.wikipedia.org/wiki/PHP_accelerator
[+] [-] e4m|17 years ago|reply
[+] [-] lleger|17 years ago|reply
I think the thing to remember is that as programmers we should be language agnostic. This is because we need to chose the right tool to get the job done. Granted, most times we can just choose our favorite language; however, there are times when, say, PHP would do better than Rails, or vice-versa.
[+] [-] flooha|17 years ago|reply
The great thing about PHP is that the difficult problems have mostly been worked out. Getting a PHP site up and running and scalable is standard stuff.
[+] [-] ironkeith|17 years ago|reply
Edit: fixed a typo.
[+] [-] Jem|17 years ago|reply
[+] [-] dbul|17 years ago|reply
[+] [-] mixmax|17 years ago|reply
I use PHP as well.
[+] [-] swolchok|17 years ago|reply