Hacker News new | past | comments | ask | show | jobs | submit login
PHP Sucks But I Like It (ircmaxell.com)
326 points by ircmaxell on April 10, 2012 | hide | past | favorite | 232 comments



The secret to PHP's success is simple. I've never seen anyone point it out.

It just works.

If you have a web server configured to run PHP, then it's ridiculously simple to get a page to execute. Just put a .php file on the site and it runs. Done.

You don't have to jigger a bunch of components, dink around with a bunch of Tomcat or Ruby on Rails or proxy or other annoying settings. Most other web execution environments have a bunch of Rube Goldberg machine components you have to plug together to get them to work. It also performs very well and supports a lot of things.


True. A lot of webhosts are configured such that you can drop some PHP files into a directory via ftp, and it'll "just work". Which is nice. But...

...that's not really inherent in PHP. You can configure Python to be just as easy, and some webhosts do this. Node is pretty much always this easy. Django and Rails can also be this easy (if you've ever used Webfaction, you'll know what I'm talking about).

And, on the flip side, if you want to install configure PHP yourself, it's actually not that easy. It's trivial to get a PHP page to execute given a web server configured to make it trivial (but, again, that's true for almost any language), but configuring the web server isn't trivial.


PHP's hello world, for transmitting back to the user, is:

<?php Print "Hello, World"; ?>

I can wrap that in a little HTML, to get valid return to the user.

I don't know what Node.js's hello world looks like. From google it looks like the following. This is a heck of a lot more things to understand.

// Load the http module to create an http server. var http = require('http');

// Configure our HTTP server to respond with Hello World to all requests. var server = http.createServer(function (request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.end("Hello World\n"); });

// Listen on port 8000, IP defaults to 127.0.0.1 server.listen(8000);

// Put a friendly message on the terminal console.log("Server running at http://127.0.0.1:8000/);


Actually, you'd probably want Express.

  var app = express.createServer();
  app.get('/', function(req, res){
      res.send('Hello World');
  });
  app.listen(3000);
That is, admittedly, longer than PHP but it's arguably easier to understand what's going on, much easier to modify and extend, and just as easy to copy and paste off the web.

For Sinatra:

  require 'sinatra'
  get '/' do
    "Hello World!"
  end
Again, does PHP have any real advantage here? Python solutions will be similar. And in all those cases we can turn this into a full app with only a few more lines.

Consider this example of a completely function blog: https://github.com/mitsuhiko/flask/tree/master/examples/flas...

There's 76 sloc of code in the blog app, plus tests, templates, database access, and more. And it's clean, clear, and simple. What does the PHP equivalent look like?

Of course, PHP is still shorter for hello world...mostly because it's running as a CGI app. This is a terrible, archaic idea for all the reasons that get discussed when people talk about Why PHP Is Terrible, but nothing is stopping you from configuring other languages that way. So here's a real apples-to-apples comparison:

Python:

  print "Hello world!"
Too long? Try Ruby:

  puts "Hello world!"
19 characters including white space? Beat that! :)


No they aren't easier to understand, not by a long shot.

Imagine you're some mom who's made a static website for some group you're a member of. You made 20-30 static pages with Frontpage or something like it.

It's a much MUCH smaller step to rename a file .php and add

    <?date('Y-m-d')?>
Than it is to wrap your head around what that node JS or python is doing.

It's exactly that integration that makes PHP win. If someone would make a similar integration for a better language (and made it fit the other niches that PHP fits that nothing else does) they'd stand a great chance of changing the world.

The problem is, no one gets it. Just like you you're fundamentally missing what people like about PHP. It's not the language that they like. It's that it's HTML+server scripting. No setup needed, no external files needed, no libraries to learn, no security issues at least at the start. It just works, in small increments above the level of static HTML.


So you walk into a culinary studio and they're having this intense class on how to properly prepare escargot.

And you stare at them ... and tell them they should just make a peanut-butter sandwich. They stare at you blankly. Then they tell you to go #$%$#^ yourself.

Is the peanut-butter sandwich easier to make? Yes. Does it taste better? Yes. Can you use it to feed the masses? Yes.

But sir, you forget. It isn't gourmet!


Great analogy. I never got the arguments telling you it's so simple to change little things. When is this ever useful except for when you just get started? It only takes a couple of hours until you leave the zone where small modifications are handy and you need to structure your code, mostly using some MV*-approach.


Adding: <?date('Y-m-d')?>

Would whiff...

Either short tags would be disabled and cause an error. Or nothing would happen.

<?php echo date('Y-m-d')?> -- Would be most preferable.

<?=date('Y-m-d')?> -- Won't work on half of webservers.

PHP is simple but most PHP servers are terrible. Part of my job is to ensure the smooth installation of proprietary software on around 1000 servers a year. This is the painful part of PHP development. If the client is paying less than $5/mo for hosting then I often run into problems with misconfigured servers, common features being disabled.. hell.. shit not working! Why isn't it working? I don't know. There are no errors. There is nothing logged... yet for some reason the session only lasts 7 seconds before disappearing.. yay!

I love PHP because it is simple and just works... I really dislike 80% of shared hosting providers who cause all sorts of problems with what should be a simple cross platform application.


Yeah, OK, I'll bite...

"<?=date('Y-m-d')?> -- Won't work on half of webservers."

You're referring to shorttags, and how evil they are. Firstly, PHP 5.4 enshrines this echo shortcut usage, and they'll always be on from now on. <?=$something;?> will always work from 5.4 on.

Secondly, "half"? Where the hell are these mythical 50% of web servers that actively disable short tags? I've been working with PHP since 1996, have worked on hundreds of projects on dozens of hosts - shared and dedicated - over those years, and have come across this once, on a server managed by someone who compiled everything by hand (not just PHP, but everything) and felt turning short tags off was "optimal" because he'd read it somewhere. He wasn't a PHP dev, just had read 'short tags are bad'.

I don't doubt that some admins and hosts do turn off short tags. It is no where close to 50% of servers out in the wild though. 5% perhaps? Even that, in my view, would be a huge stretch.


Surely you realize that PHP is alone in having vast swaths of its common functionalitity disabled by hosts because of massive security problems arising in actual use?

This means PHP being crippled on many servers is PHP’s own fault.


Not necessarily. Popularity makes something more likely to be exploited. Compare PCs to Macs re: viruses. Also, many security issues were due to conventions in early versions of the language, e.g. register globals.


This is the main strength, and also one of the most obvious flaws, of PHP. What makes it incredibly easy to get started (if you start from static HTML) also makes it easy to trip yourself up later on.

Mixing logic and your text/data will work well for inserting a simple date, but when you start adding more complicated logic it is easy to create a mess which is difficult to read and modify even for you a few months later. That's the reason other frameworks/languages try to give you a more structured (and complex) starting point.


By "win", of course, you mean develop a giant ecosystem of abysmal code that decent developers flee from at any given opportunity, right?


Your examples are interesting, I may look at Sinatra and flask.

One other big advantage of PHP, which I find as time goes by, is (boringly) its broad stability. I first learnt PHP over 10 years ago, and what I learnt then still works now. Web apps are a very small part of what I do, I knock together the odd small one every couple of years or so.

I did do one app in Rails, but when I next came back to look at Rails about 18 months later, it seemed enough things had changed my app broke in various ways. I find I increasingly appreciate a large community, a book or two, and some stability.

Obviously if your day-to-day life is web design that doesn't apply. My day-to-day life in high performance algorithms, and I was using new C++11 features as they got implemented in compilers, and have played with many languages in that area.


I'd love an experts opinion on c++11 in the realm of high performance algorithms. Considering most of the updates were instruction additions and fixes, is it really increasing speed and even worth it to use the bleeding edge for maybe some small gain where a 10 year old language is simply much more reliable?

Also, I didn't mention the updates in parallelism that were added (because they should have come earlier)...but do you think c++ is comparable to a modern concurrent language atm? Worth it over erlang?


I wouldn't sat that C++11 is going to lead to faster code than C++03. However, if like many C++03 experts you were already writing a lot of template code, then 'decltype' and variadic templates in particular make a lot of templated code much easier and cleaner to write. lambda functions neaten up various things.

Other people may have different opinions, but I don't think C++11 will convert anyone, but people who already have a big time, or code, investment in C++ will find much of their lives much easier. Another indirect advantage is that by moving to C++11, it finally allows people to make a clean break from older, less standard C++ compilers. Wether will we end up with a new state, where people end up supporting partial C++11 compilers, we will have to wait and see.

The parallelism is really just standardising existing behaviour in many cases. People who want to write things like lock-free algorithms are very excited by the atomics stuff, but such stuff is beyond me.

I am disappointed that some more practically useful threading algorithms, like thread pools and such like did not end up in the standard. However they now seem to be arriving as 3rd party libraries.

I think what is going on is that before a threadpool library was '2 steps removed' from standard C++ (as first you had to write, or use someone else's, threading/atomics library). Now they are only '1 step removed', they are more useful.


If you want ultimate performance yes.

In modern architectures there are lots of places where you can get way faster, just by organizing your data in more cache friendly ways, or the way the data is layered across registers and memory regions.

You need a language like C++ for these type of optimizations.


The trivial example of PHP is equivalent to making a file with only the text:

  Hello World!
...and saving it as a .php file. I think you'll have a hard time finding something more concise. :)

In reality, one of the things that makes PHP an easy language to pick up is that you don't have to have all of the overhead of learning how it works. Novices sprinkle bits of PHP surrounded by HTML-looking tags and all of the sudden they're up and running.

I started with PHP myself, and found it to be an interesting and frustrating language (needle or haystack argument first?). It's often saved by an easily searchable manual and a huge user base.

PHP is a shoot-yourself-in-the-foot language. It'll happily let you do dangerous, awful, bad, bad things. This wouldn't be such an issue if there was a higher barrier to entry, the real problem is it's easy to pick up (is that really a "problem"?), but that's a feature not a bug.


This highlights PHP's core strength. The incremental effort to add dynamic content to an existing static website is very low. Even for an existing page. Right from the start, every existing page is already ready for PHP to be added.

At worst, all you may need is to ensure .html prefixed resources as processed as HTML files: http://docs.grabaperch.com/getting-started/file-extensions


Maybe a better comparison is from some of the microframeworks for PHP. As you can see, Sinatra influenced a lot of frameworks in many languages.

From Slim: (http://www.slimframework.com/)

require 'Slim/Slim.php';

$app = new Slim();

$app->get('/hello/:name', function ($name) { echo "Hello, $name!"; });

$app->run();

From Silex: (http://silex.sensiolabs.org/)

require_once __DIR__.'/silex.phar';

$app = new Silex\Application();

$app->get('/hello/{name}', function($name) use($app) { return 'Hello '.$app->escape($name); });

$app->run();


It would be interesting to create a javascript server-side environment where code is in blocks and is executed through server modules.

The benefit of being able to output HTML by default, drag+drop files over FTP or SCP to get it working, and a lanaguge that a lot of developers already know through client scripting.

I wonder if ASP still has support for Javascript as a server lanagage.

An example would be something like:

    <%
    	require('mysql');
    	require('session');
    	require('cookie');
    	require('datetime');

    	blog_data = mysql.fetch('select * from blog_meta');
    	posts = mysql.fetch('select title, content, author, pubdate, permalink from posts where published=1 order by pubdate desc');
    	user = session.get_current(cookie.sess_id);
    %>
    <!DOCTYPE html>
    <html>
    <head>
    	<meta charset="utf-8" />
    	<title><%= blog_data.title %></title>
    </head>
    <body id="home">
    <div class="container">
    	<% for post in posts: %>
    		<div id="post-<% post.id %>">
    			<a href="<% post.permalink %>">
    				<h1><%=post.title %></h1>
    			</a>
    			<div class="postmeta">
    				<%=post.author %> - <%= post.pubdate.format('%m %d %Y') %>
    			</div>
    			<div class="content">
    				<%=post.content %>
    			</div>
    		</div>
    	<% endfor %>
    </div>
    </body>
    </html>
as simple as PHP, but Javascript - and simple webapp modules like session, mysql, etc. etc.


Yes, PHP is awesome for building hello world applications. No one is disputing that.

However, for building applications that might get deployed somewhere, or talk to a database in a secure fashion, it's a nightmare.

For ruby, python and perl, it's just as easy to make a hello world like that, all you have to do is execute it as a CGI. Node.js is a FRAMEWORK, not a language, you can equally make it super simple to execute javascript the same way by again executing it at as CGI, it's actually even shorter because you don't need <? ?> tags.

The reason the Perl,Python and Ruby communities don't make apps like that is because it's a bad idea. In ruby,perl,python,javascript if you really want to you can. PHP makes it incredibly hard to not be stupid in the way your app is setup. PHP saves you a few minutes of following a rails cast in exchange for a lifetime of hell.

The crux of why most programmers disdain PHP is because of the poor choices for maintainability and ease of building larger applications, also because the PHP community has no idea what they're talking about for the most part.

Most PHP programmers couldn't even tell the difference between a language, a framework, a template system, probably because PHP doesn't have any separation of concerns. The language, framework, standard library, templating system are all mashed into one godawful mess.

But yes, it's really easy to build hello world applications. Alternatively, if you want to build a hello world application you could just write:

  Hello World
in a text file and be done with it instead of exposing yourself to all the security vulnerabilities inherent in PHP. (Yes, even hello world is insecure in PHP)


> However, for building applications that might get deployed somewhere, or talk to a database in a secure fashion, it's a nightmare.

In what decade? Ever heard of PDO? Prepared statements? PHP is actually more secure when it comes to database connections than all of the wonderful alternatives you mentioned.


"Prepared statements? PHP is actually more secure..."

The most commonly used module for mysql access, mysql (not mysqli for some reason), does not support bound parameter prepared statements instead opting for some very funky string escaping business.

Prepared statements are generally the only supported SQL mechanism in other languages/platforms I have used (C, Perl, Ruby, Java, COBOL...)


More secure? Then I suppose I'll get all of the insurance and banking portals to rewrite everything in PHP -- since is so secure and easy to use.


> Then I suppose I'll get all of the insurance and banking portals to rewrite everything in PHP

From COBOL? Probably a good idea.


>>However, for building applications that might get deployed somewhere, or talk to a database in a secure fashion, it's a nightmare.

Facebook, Wikipedia are begging to disagree.


No, they aren't.

Quote Adam D'Angelo, former CTO of Facebook: "PHP was out of the question [for building Quora]. Facebook is stuck on that for legacy reasons, not because it's the best choice right now". (source: http://www.quora.com/Quora-Infrastructure/Why-did-Quora-choo...)


[deleted]


Actually Facebook agrees with me so much that they rewrote PHP as a C++ macro called hiphop, and no longer use PHP.

A specious comment - hiphop transforms PHP to optimised C++ and then compiles it.

https://github.com/facebook/hiphop-php


Compilation = converting a language into another. Hiphop is a (two-stages) PHP compiler.


Please explain to me how "hello world" is insecure in PHP. I am genuinely interested in your reasoning.


PHP has had numerous security issues related to the parsing of things like HTTP headers, etc. This means that when you write your app in PHP, and do something simple you get security issues just for going along for the ride.

Things like this: https://bugzilla.redhat.com/show_bug.cgi?id=786686

Put an empty PHP file on your server and you've got a vulnerability. If they can't figure out how to parse a URL correctly what else is lurking? Ironically, the issue is a fix for a DOS attack, so they traded a DOS attack for remote code exec, and then backported it.

This is the equivalent of

  int main() { return 0; } 
having security issues.

By the way, this issue is from two months ago, we're not even talking about the really bad ancient bugs.


Since I cannot reply to your response, I would like to inquire as to some resources where I can read more about the specific security bugs in PHP you are mentioning.

I am well aware that PHP has had security issues in the past, but I am also aware of the fact that it gets a bad name because people read blog posts and then decide the sky is falling.


Let's look at something trivially more complex than a Hello World: a form handler. The form is just HTML, asking for a name:

    <html>
    <body>
    <form action="handlerhere" method="post">
    <label>Name: <input type="text" name="name" /></label>
    <input type="submit" name="submit" value="Submit" />
    <input type="hidden" name="submitted" value="TRUE" />
    </form>
    </body>
    </html>
The handler is a separate file. This whole example is from back around my first year of programming, when (among other silly things) I thought indentation was stupid. (Which was one reason I didn't like Python to begin with even though I love it now.) The PHP handler:

    <html>
    <body>
    <?php
    if (isset($_POST['submitted'])) {
    $name = htmlentities(stripslashes($_POST['name']));
    echo "<p>The submitted name was \"$name\"</p>";
    }
    ?>
    </body>
    </html>
And the Python version (notice the silly one space indent (I use two now!) and the silly semicolons):

    #!/usr/bin/python
    import cgi;
    def main():
     form = cgi.FieldStorage(); # instantiate only once!
     name = form.getfirst('name', 'empty');
     
     # Avoid script injection escaping the user input
     name = cgi.escape(name);
     
     print "Content-Type: text/html\n";
     print """\
     <html>
     <body>
     <p>The submitted name was "%s"</p>
     </body>
     </html>""" % name

    if __name__ == "__main__":
     main();
Oh, and with the Python version I had to add this file to the directory it was in which I didn't totally understand at the time:

    Options +ExecCGI
    AddHandler cgi-script .py
    Options +Indexes
Admittedly not that hard. I had an .htaccess file already for fun 404 handlers. I vaguely remember being confused for a while because the .py script didn't have the right permissions on it so the server's apache just refused to execute.

The complexity isn't that much different, it's just that Python provided no compelling reason for me to switch to it. (And, frankly, even with Flask still doesn't for simple single-file web-page scripts. Applications, on the other hand...)


What should I do with that PHP script alone? The same example in Node, with no web server, just like yours:

    console.log('Hello World')


> And, on the flip side, if you want to install configure PHP yourself, it's actually not that easy.

http://www.lifelinux.com/how-to-install-nginx-and-php-fpm-on...

Looks pretty easy to me.

Then again, I compile my own version of Apache with FastCGI and PHP-FPM all the time.


True, that's pretty easy. But it's also just as easy as getting most other language or frameworks up and running. And since the argument I was replying to was that PHP was good because those other languages are too hard to configure then, implicitly, PHP is too hard to configure - at least for the guy I was replying to.

And if you're relying on your webhost having your language-of-choice already configured for you, well, you can find webhosts with most of the obvious choices already configured. So what does that leave?

I would suggest that PHP does not, today, have any advantage over other competing languages and frameworks in the "it just works" sweepstakes.


Was going to say the same, yum makes it very easy.

What we need is a Douglas Crockford for PHP.

A “PHP: the good parts” and a good PHPlint would do wonders to the language and community.


As previously discussed on HN, Robert Eisele's fork of PHP (at v5.3.6) which attempts to fix many of the issues.

http://www.xarg.org/2011/06/php-hacking/


...that's not really inherent in PHP. You can configure Python to be just as easy, and some webhosts do this...

It's very rare to find webhosts that configure Python, Ruby, Node or the rest to be as easy as "upload a file, click reload."

One reason is the wonderful statelessness of mod_php's execution model: it forks a new process for every request, and destroys it at the end. It's inherently a much more stable environment than the competitors -- you can't save anything inside the interpreter for future requests. This makes server administration easy, and probably shared hosting easier to manage.


The original comment said "If you have a web server configured [for PHP] then it's ridiculously simple to get a page to execute."

My point was that this is true for any language.

You seem to be suggesting that the odds of picking a web server at random and having it be so configured for a given language is pretty low, which seems like quite a different issue, and (in my view) a pointless one. Nobody picks a webhost at random and just hopes that they have support, so the question is can you find support if you want it. :)

In any case, it's also incorrect in the case of Python and arguably Ruby. The first three mass-market shared webhosts I can think of are Dreamhost, Webfaction, and Hostgator. Without any configuration at all, Dreamhost supports both Python and Ruby scripts as CGI programs, Hostgator supports Python scripts as CGI programs, and I believe Webfaction does as well.

(Node is a lot newer and, admittedly, doesn't seem to have any support among mass-market shared webhosts.)


PHP is much better than CGI, because it doesn't have to load an interpreter and all libraries per request -- they were loaded at server startup time. This is why all serious web frameworks don't use CGI. But PHP avoids the administrative/stability problems of persistent servers -- Python, Java, Ruby -- by disallowing state across requests.

I think, because PHP servers are so stable, that's part of why they're so common on shared web hosts. For example, running a WSGI server is much more complicated. If a WSGI app goes bonkers you have to restart the relevant server. In mod_php, just kill the process.

What would be interesting is a forking-style server for Python or another reasonable language.


Um. We're getting a little bogged down here, but...

1) PHP is commonly implemented via CGI by many webhosts, even today. Not only is it generally considered more secure, but it lets you easily run multiple versions behind the same Apache instance. The performance hit isn't bad, either. So I'm not sure what "PHP is ... better than CGI" even means.

2) PHP is not particularly stable and it is not uncommon for a PHP process to hang until killed, often soaking up 100% CPU time. The stateless nature does make it easier to just kill it whenever it goes crazy, but it doesn't really have anything to do with how often it goes crazy.

3) You can configure servers in all sorts of ways, but there's nothing inherently harder about WSGI. You absolutely can just "kill the process".

4) I honestly have no idea what you mean by "a forking-style server for Python". Is there something you dislike about all the current ones? :)


People seem really hung up on the idea that Python and WSGI are not supported by cheap shared webhosts. If you ever think "gee, I wish I had some decent shared WSGI hosting for less than $10/month" the answer is Webfaction. :)

http://news.ycombinator.com/item?id=3826416

(@lmm: Sorry, I can't reply directly to your post.)


> 3) You can configure servers in all sorts of ways, but there's nothing inherently harder about WSGI.

I'm willing to believe this - but if it's true, where are the cheap shared webhosts with WSGI enabled? Or do you think there's some other reason PHP is so much more widely available?


It isn't true that "if a WSGI app goes bonkers you have to restart the relevant server." This is between you and your specific app server, it isn't a matter of WSGI.


PHP has no app servers to go bonkers.


Dreamhost supports ruby via phusion passenger now.

http://wiki.dreamhost.com/Passenger


Isn't not programming at all even easier? You don't have to get money, find a computer to buy, buy a computer, install an OS, buy an Internet connection, install a web browser, learn to browse the web, learn about how hosting works, find a host, get money to buy a hosting account, learn about apache, install apache, learn about php, install php, learn about text editors, install a text editor, learn php, write PHP, learn about scp, install scp, scp file to server. By the time you've become that proficient with all that stuff, apt-get install libcatalyst-perl on your desktop sounds about as easy as finding a host that supports PHP.

It's not like PHP solves any of the real problems, like how to manage upstream changes, how to automate releases, how to rollback database schemas after a bad release, and so on. The reason why nobody ever talks about those things is because everyone handles them with downtime and swearing. That's not software engineering. That's fail.


Not programming at all is easier, yes. Not programming is also much more popular than programming in PHP.

Edit: To be a bit less snarky here, you are arguing that the sunk costs of learning to use a computer justify more effort spent in getting a web site running just because the effort already sunk dwarfs the additional effort required. But in fact not only is that cost sunk but once I've learned to use a computer my time and energy is suddenly more valuable.


False dichotomy. You can do some things quickly in PHP (vs other languages), and some things in life and in programming need to be done quickly.

There's a place for doing things fast, and a place for doing things right. You're wrong to assume everything requires the latter.


If you don't have time to do things right, how are you ever going to find time to do them over and over again?


Sometimes, doing things fast opens up opportunities to do things right.


This is true. However, if you do things fast and wrong, you've got an even bigger problem in figuring it out how to do things right because now you have to do both at the same time, and usually with the same number of people.


You know, not only that, but this implies that wrong is always fast. That is wrong. Often, wrong goes slower as time goes on. I'd rather have slow, steady progress than explosive growth and eventual failure.


I've got some legacy apps I work on that prove that wrong. :)


False dichotomy too. When I was kid my parents always required me too do things "vite et bien" (fast and well) and it its only much later, with more experience and also some understanding of what is said by Zhuangzi the Taoist, that I understood that both are compatible, and even require each other. Example: if you tidy up your room, doing it slowly means focusing on ordering your Lego by size and color, while doing it fast means moving everything to their place in less than 5 mn.


This is truer than you know, but for the wrong reasons.

I worked tech support for a shell provider in the 90s and I helped a LOT of users work through the mechanics of setting up a cgi-bin. One of the most difficult concepts for users without a technical background was file permissions -- specifically the execute bit.

I believe PHP's ease of use primarily stems from what most would consider a security vulnerability: mod_php instructs apache to execute code from php files without the execute bit set. This is inherently the same sort of issue behind email worms on Windows -- exec handlers which pass code to an interpreter without honoring the lack of execute permissions.

It's a terrible idea, and also widely popular. I have personally seen users switch from Perl to PHP purely because they could not figure out how to set the execute bit in their Windows FTP program.

The rest is inertia, as far as I'm concerned.


I've seen people point it out before and I think it makes perfect sense for explaining its popularity.

I also think it's a micro-optimization for the wrong thing. It's like buying a car based solely on how close the dealership is to your house. You only have to do the initial setup once (by definition) but you have to live with the consequences of your environment of choice every single day for the rest of the project.

I'll go to a crappy coffee shop if it's the only one around, I'm willing to go very far out of my way to get to the car dealership that has the right thing for me.


People trade up cars all the time -- when you can afford to, that is.


Using PHP just because it's easy install isn't like buying a cheap car because it's cheap, it's like buying a cheap car because it's just a little bit closer to walk to than another cheap car.


To the extent that learning languages takes time (it does) and to the extent that setting up an environment takes times (it does) and to the extent that time is money (it is), I'd say using PHP in lieu of a premium language is exactly like saving money on a car when you don't have a lot of [time/money].

But in the end, what's most important is that the car/language gets you from Point A to Point B.


It's only saving money when you don't count the ongoing opportunity cost of using inferior tools and technologies, but that's a false economy. It's a short-term savings in exchange for lots and lots of serious pain going forward.


> I’ve never seen anyone point it out.

Really?

The easy of deploying a single-purpose script / hello world is always trotted out as the reason PHP ever became popular.

Yes, even in yesterday’s big item “PHP: A Fractal of Bad Design.”


PHP is just an example of worse is better (whose key is simplicity of implementation), because PHP is easy to get started with things get built in it. Then you have a lifetime of maintenance hacking around all the bad decisions at the start because of it.

Comparing the rails app config system to PHP.INI, ini_set, .htaccess and the million other ways to configure PHP and considering the app config system to be a rube goldberg machine is really unjustified, the very configuration of PHP itself pretty much non-deterministic.

http://www.jwz.org/doc/worse-is-better.html


Don't use all those ways of configuring PHP. php.ini works just fine, and if you truly need a different configuration for a specific application, a bootstrap file will serve to override the php.ini where necessary. Done.


A large number of people have previously pointed this out. You're selling the virtues of mod_php, rather than PHP itself.

As other have pointed out in this thread, you can easily configure a web server to behave like that for files in other languages like Perl or Python.


but the difference is that you don't have to configure a web server to act like that for PHP, because (almost) all of them come that way.


Yes, it just works. That's also where there are thousands of poorly written sites out there that chug down sql injections like they were going out of style.

PHP is a reasonable templating language. That's what it should be used for.

If you use a framework, you're golden, but at that point you could be using any language.


If [language of your choice] was as popular as PHP you can bet that there would be thousands of poorly written sites in that language out there too.


I sincerely doubt that. PHP has fundamental issues.

It's like the people 10 years ago saying "if [other OS] was as popular as Windows XP, it'd be overrun with malware too". No. The issue wasn't Windows marketshare, it was the completely crap security.


The issue was both Windows marketshare and crap security. If it wasn't easy to write malware for Windows not as many would write it. If there was no one to infect with the malware, also no one would write it.


True, I suppose: if PHP were invented today, I imagine the pitch would be something like "it's the Dropbox of web applications: you just put files in a directory and they run."

(...on that note, I just realized how useful it would be if Dropbox's Public folder executed PHP.)


When there are so many cases where it fails, mysteriously and/or silently, you really cannot say it "just works".


Life is filled with simple, easy, cheap, popular paths that lead to ruin. PHPs initial simplicity does not make it a good choice.

Looking for happiness? Heroine "just works".

Hungry and poor? Eating McDonald's three meals a day is cheap and easy.


Exactly that is why both Heroine and McDonald's sell.

It might sound scary. But in reality 'merit' is not the only motivating factor for adoption of anything.


PHP is like living in a big city. There are all sorts of things wrong with it, like homelessness, noise pollution, traffic, bad neighborhoods, corrupt politicians, perennially-under-funded public transit; the list goes on.

And yet there's nowhere like it. You could move to some ideal community somewhere, and maybe you visit there now and then because it doesn't have all those other problems, but all the arts and culture, all your favorite restaurants and bars, all the meetups and hangouts and friends and co-workers make your city worth the downsides.


Continuing your analogy, you see it as an interesting, rich big city, I see it as a shite big city, devoid of interesting culture, lots of poorly run bars and shops, everyone is miserable, it takes ages to get anywhere and it's always raining. Anyone with skill and the ability has abandoned it or is trying to. Python or Ruby however are cooler, slightly smaller cities which have a decent community feel, a good art scene, and are thankfully free of people who live in the big city but are too ignorant or lazy to venture out and get there.

PHP has no fucking culture, the vast majority of 3rd party libraries and classes and snippets are garbage, the vast majority of tutorials are garbage. There are some gleaming institutions like Symfony, and some little places that are trying really hard to make it a better place, but other than that it's a wasteland.

Let's not romanticise dog shit. Yes, the original guy's post was unnecessarily harsh to the development community and people who work hard to make their life in said city, but this city is a clusterfuck in comparison to pretty much anywhere else. It's one redeeming feature being that it's easy to get to and everyone's heard of it.


Yeah, or I can live in some other big city that doesn't have all the shitty parts (or at least less of them). Plus it has all the good stuff. Please stop with this insane dichotomy that I have to choose between the stuff I like and living somewhere without crap. Damnit I want it all, and I'm getting it.


I like your city analogy. I won't stoop to comparing programming languages to actual American cities, but I would counter that "PHP is like living in [a particular] big city."

Here's where I disagree: it's not enough to say "hold your nose around these parts, but it's OK because those few blocks on Main St. are worth it."

There will be flaws in any city, and sometimes due to mismanagement, the flaws will be neglected until blight sets in. Here's where the citizens of the city need to step up: they either flee the city and it continues to decay, or they acknowledge the flaws and address them. Don't just accept the downsides! Fix things. Make improvements. The city only thrives on the investments of its citizens.


I've always said somebody should fork php and polish it, getting rid of all the backward compatibility issues and leaving intact the ease of use and deployment. It is unbelievable to me how nobody sees the huge potential it has in books, blogs, docs, frameworks, etc. Like giving php a second chance, this time done right.

Rasmus himself should give it a try as a side project with a different name. I would follow him from day one.

PHP has a lot of bad parts and, like javascript, is asking for its cup of coffee. The time is ripe.


Maybe Facebook will one day as their upcoming Hiphop VM evolves. Until then, there are better options.

Then again look at what happened with Perl 5 / Perl 6 transition or specifically with the one that didn't happen.


Rasmus himself hates programming and he will put up with PHP in its current form as long as he gets his job done.


what holds you back?


Right now I am learning about compilers because if nobody does it, I will.

There are three opportunities right now in front of our eyes we are all missing: a simpler-than-node JS on the server implementation, a rectified php, and a simpler functional language for web development. Bonus point: a universal templating system, like jinja, for all programming languages.

As soon as I finish the course about compilers I'll jump head first to try to solve them all.


Is mustache.github.com not good enough as a universal templating language?

I don't agree with ever design decision made for the syntax, and I've not used jinja, but it has the universal part handled quite well.

The idea of a roasted PHP is interesting. It's not a no brainer in the way CoffeeScript is though. There's no real choice of language in the client-side, but there is on the server side.

Server side devs can just learn ruby/python/.NET/Scala. Client side devs are probs best switching to JavaScript or something very similar.


Mustache is good enough and seeing it ported to so many languages is cool. But I don't like it, I'll explain why:

I rather see a 'for' statement than imply that an object is 'loopable', or an 'if' instead of guessing if the var is boolean.

I rather see a differentiation between statements and variables like {% statement %} {{ var }} like in jinja.

I don't support the idea of logic-less templates. Everything in the right measure. Not a full-fledged language inside the template but basic loops and conditions I think are ok.

I am always complaining about syntax but I believe if it is too noisy or it makes me think about its meaning, it's too complex and should be simplified.


In the meantime, if you (or anybody) can point me to modern compiler techniques I'd appreciate it a lot. Been devouring all I can find online but nothing satisfies me.


What have you been reading that hasn't satisfied you? What are you looking for? The basics of parsing haven't changed much. . I'm still learning, too, so I don't know how much I can help.

As I've stated elsewhere on the thread, I prefer the idea of giving another language the ease of use of PHP. It is likely to be less work, especially in the case of Lua (super easy to embed in C). And the compiler is already built for you. :)


I've been reading mostly about lexers and parsers (antlr, yacc, bison, etc) that produce C code and would like to try different approaches like SML but haven't found any literature. Read also about LLVM but C++ is not my type. Haskell and GHC are cool but again C shows its ugly head.

So, I'd like to know if C is the only way or if there are new papers that I don't know of for implementing modern compilers before committing to C. I am just starting so there is a lot to read about different contexts and ideas.

(PS: Java is not an option)


Are you looking for an alternative to emitting C or to using C as the implementation language of the compiler? I'm not totally sure what you're after, and I'm a compiler noob, but I've been enjoying Appel's Modern Compiler Implementation in ML, which uses SML as the implementation language and emits RISC machine code or assembly (I think, I haven't actually gotten that far). I don't know how suitable it would be as a stepping stone to forking PHP, but it's something.


'Modern Compiler Implementation in ML' any online resource you can share?



Personally, I've been using Python for prototyping. It has lots of lexing libraries, and from there I just do recursive descent. I figure I'll switch to C for a "real" implementation, partly because what I'm going for in my current project is as much database as programming language.

I don't think you have to use C++ to target LLVM. I think you can output LLVM IR from anything and then just call LLVM from the shell to get an executable.


The problem is everyone is conflating things.

PHP the language sucks ass.

PHP the environment (part of the server + html processor + no setup or configuration for most users + page is the app + etc..) = WIN for many many people.

Not a single other environment has ever duplicated that. Until someone does they'll never displace PHP. It's ripe for the replacing but understand that it's not just the language, it's the entire environment surrounding it.


"Not a single other environment has ever duplicated that. Until someone does they'll never displace PHP"

Someone in the Rails community is trying with a small start.

http://www.kickstarter.com/projects/1397300529/railsapp

Ruby and its community are far from perfect. The biggest difference that I see between it and other communities, is that when a lot of people come about some negative aspect of using Ruby, eventually within a few months people start working on actually fixing it. X number of months later, it ships.


The thing is, the language doesn't fully suck. It has a few sucky parts that are more or less easy to ignore. As has been said elsewhere in this topic[1], the code one produces in PHP is pretty equivalent to what you do in most other languages.

[1] http://news.ycombinator.com/item?id=3824767


So, what exactly ARE the good parts?

* Syntax? Sucks * Arrays? Or wait, are they hash tables? Sucks * Stdlib? Sucks * Performance? Sucks


Syntax is awful, granted.

PHP doesn't have arrays, it has hashtables. Although PHP probably got there by accident, consensus in dynamic languages today is that the hashtable is the superior default collection datatype.

The standard library is state of the art in C, which is most of the time state of the art, full stop. The interfaces to the libraries are awful by way of being inconsistent.

Performance is more than good enough. Scaling it properly is more of an artefact of good application architecture, but this is the case for any environment.


I found myself thinking whether one could make an heir apparent to PHP that removed the suckiest aspects and left the same basic "no configuration, just a bunch of files" model in place (any inherent problems with that model notwithstanding). Sort of how SVN fixed some of the most glaring issues with CVS without forcing people to really change their habits.

But I think that the things PHP really has going for it (huge installed base of the runtime, huge installed base of legacy apps, huge developer community) aren't going to smoothly make the jump to a new language. And once you've given up that sort of backward compatibility, why not fix a few other things while you're at it?

Still, I think there might be potential for a PHP-like language that breaks some backward compatibility but fixes a lot of basic things like unicode support, modules loaded at startup or runtime rather than as a ./Configure flag, syntactic quirks, etc. Something where you could spend a few minutes to a few hours (max) refactoring a PHP script into PHQ (or whatever you want to call it) script and gradually modernize your app.


Pharen (http://scriptor.github.com/pharen/), a Lisp that compiles to PHP, might be or become such a language. It's not quite as simple to jump right into as PHP is because you need to run Pharen's compiler after editing your code, or set up a script to watch for changes and then compile. But Pharen could theoretically improve its tooling and get very close to PHP's ease of use.


Most of the gripes with PHP seem to do with its syntax, error messages, and inconsistent function naming.

It seems like it shouldn't be too difficult to write an automatic converter from "PHP" to "Improved PHP", which might solve a lot of these issues.



I don't think people replicate it because having an environment that is based on directly mapping to the filesystem tree is completely inane for modern webapps. Most decent PHP software now hands the request off to a single file (eg index.php) that handles the routing.

Yes, PHP has mass appeal for people that are happy to limit themselves to the lowest common denominator, however people that want to reach even a tiny bit further can discover other languages that have better ways of doing things.

For instance, his "Hello world" example is completely fucking inane, and just spitting out a thing like that will lead to poor app design and unmaintainable spaghetti code.


> PHP the language sucks ass.

Depends on how you define the language? Nobody is twisting your arm, you don't have to use any of the inconsistent syntax. Just write your own functions.

The core language is actually very similar to C.


The core language has a superficial similarity to C, that's all.


This is the best way to describe it.

I wrote a few tools for my IT team a month or two back. I needed a Quick and Dirty web UI. How do I write some .py files that output HTML, put them in a web directory, then goto http://server/tool.py?

It was just easier to use mod_php and rewrite the simple tools in PHP. Trust me, I REALLY wanted to use Python, but couldn't. To be fair, I didn't have superuser, but I did look for docs on how to do this for Python, and apparently isn't not easy. You have to use WSGI or something? I don't know.

My tool now works well, in PHP.


Phusion Passenger is your Apache plugin and/or standalone server. It supports Python and is really easy to setup. Flask is your quick and dirty web UI. It comes with some of the best documentation I've ever seen.

You need different knowledge than PHP, but I can't say that it's harder than PHP.


The arguments in favor of PHP that I continue to hear run along the lines of "everybody's using it" or "it's not that bad if you know what you're doing" or "it's great because it's the Swiss Army knife of languages."

It's hard to argue with those sentiments. And I think the root of the argument stems from the diverging convictions of two distinctly different camps of hackers. There are grease monkeys who love tinkering and see value in a tried-and-true tool that works everywhere. And then there are the craftsmen who strive for elegant code and choose their tools carefully. (There's truth in both of those aspirations. Let's not get carried away in value judgements between the two camps.)

But hearing "PHP sucks but I like it" sounds like Stockholm Syndrome to me. There are some great aspects to PHP that other web stacks and frameworks could learn from. Yet there are some major flaws that actually get in the way of productivity. I hope we can keep the discussion constructive and learn from both camps in building the future of web programming.


I don't think you necessarily meant it as such but in this context it appears that you just referred to PHP developers as "grease monkeys" and other developers as "craftsman". One could misinterpret that as a highly offensive remark.


I think you're misinterpreting my use of "grease monkeys" in general as offensive. (I said not to project value judgements in my original comment. There are certainly developers who see "craftsmen" as aloof purists who look down on practical matters. It cuts both ways.)


Well... The Google tells me that "grease monkey" is a derogatory term for a mechanic. I don't think it is generally meant to describe someone that you think very highly of. The Google also tells me that "craftsman" is a person who is skilled in a particular craft or art. I think this is generally used as defined. The Google never lies.

Using the two together seems to imply we have "skilled people who care about elegant code and tool selection" and "mechanics that like to tinker". Like I said, I don't think that is how you meant it... but that is how it comes off to me. And I tried really hard not to project any value judgement.


The point of the analogy is to suppose that the primary goal of the PHP developer, as with a supposed typical repair mechanic, is to dive into the work and do what needs to be done to get to having a working site (or whatever project). I believe this is similar to the sentiment expressed by the adage "Real developers ship."

The "craftsman" approach in the analogy is presumed to be more deliberate in his work, placing more emphasis on ensuring that the highest quality work is assured, and comparatively less on the practical matter of ensuring that it delivers what is needed on a short turnaround. One aspect of this analogy that may be relevant to consider is that craftsmen are considered to produce high-quality furniture and other products, but those products are quite expensive compared to the products made in factories that most people (can afford to) buy.

In professional development, software developers are generally expected to balance these concerns. Produce the highest-quality product that it is practical to deliver within a reasonable time frame.

No doubt this analogy is still an oversimplification of what PHP developers (and other developers) are like, as virtually all analogies tend to be. But it isn't intended to be derogatory toward PHP developers -- or toward developers in general whose focus is on shipping a product and not producing the perfect architecture.


I guess in order to buy into the analogy you first must accept the premise that being a craftsman and using PHP are mutually exclusive. I do not accept this premise. But maybe we can just agree to disagree on that.


That's part of what I meant by calling it an oversimplification: all of any developer pool are not going to fit some description.

Does the analogy apply to enough of the PHP developer pool to have value? My guess would be yes, but if your experience dictates otherwise, I have no problem with that assertion.


You're over-thinking this.


Every time one of these arguments pops up, I'm reminded of this:

http://i.imgur.com/pG3q7.jpg

Different people will end up enjoying different tools. I started web development with Ruby and Rails, but find that I really enjoy PHP. Then again, I don't have to maintain anyone else's crappy code. I find that when I write clean, well tested PHP, it really isn't frustrating or painful.

If you prefer something else, that's great! Use it. I guess these types of debates aren't exactly unique to this industry though. When I used to lurk around automotive message boards when I was younger, I recall some pretty epic flamewars among Chevy/Dodge/Ford/etc. fans. Everyone loved their favourite, and were certain that the others were clunky pieces of crap. Sounds a lot like programming language flamewars... :)


I really love that they used that famous photo of Andrew "Alynna \"Pookie\" Trypnotk" Beaudoin for the C as seen by PHP fanboys cell of the table.

Oddly enough, that man's programming preferences are even more hilarious: he likes to do his web development in the scripting language for his favorite furry MUCK. I'm not even kidding; he bolted it onto a Web server somehow and actually did paid contract work in this language. And since he was the only one who knew how to use it, it meant job security. Up to a point. After he got fired, he was also the only one who knew about the back door he snuck into their MUCK-based application server.

Mofo was Dennis Nedry in a dirty fox fursuit. Or not, as the picture shows.


I agree. Like religion, unless someone tries to force it on me I tend not to care as much.


Can we all just agree PHP (like many other languages) has some bad features / design choices (evolutionary features, whatever you wanna call em), yet when used properly under the right circumstances it does the job quite well?


A truely masterful carpenter could build you a pretty impressive desk with nothing but a few jagged rocks. But put better tools in his hands, and the same guy will do a much better job, faster. That was the point of the original blog post, and this one didn't really contradict it in any meaningful way.


I'll accept "does the job". I don't accept "quite well". I've seen PHP do a lot, but I've yet to see it do anything truly well.


Indeed. It lets you write verbose tangled masses of SQL, code, and HTML. That gets the job done, but when you see the power of declarative programming and good libraries, you can do a lot more with a lot less code.


What does it not do well?


Since I haven't seen PHP do anything well, I'd posit that what PHP does not do well is everything.


Agreed.


The resounding theme is: "I've only used PHP, and I like it. Therefore it's good."

Try getting good at a different programming language, then write your blog post about how PHP is awesome.


I don't buy your argument. You don't need to try all (or any) programming languages in the world in order to like a single language. I know Python, and I really like Python and think it is awesome. I don't need to have tried Ruby or Haskell or C# to say this.

Also, your comment kind of becomes moot because he goes on to say "I do know and actively use Python and server-side JS ..."


You don't need to try all (or any) programming languages in the world in order to like a single language.

No, but you appear woefully unqualified to put forth any kind of opinion as to why the language you like is a good language if you have no frame of reference.

I know Python, and I really like Python and think it is awesome.

Sure, but you have no basis to make a comparison. You just happened to luck out; Python is a great language. PHP is... not.


Languages I feel comfortable in:

-C#

-Java

-PHP

-ActionScript 3

-Javascript

-C/C++ (not so much now but did in the past)

-Objective C

and I've played around with Ruby and Python a little.

Knowing all these languages, I still think PHP can be damn good when used properly. If you look at some of the frameworks built with it, they are clean and powerful.


That's the rub, though, isn't it? "When used properly". PHP doesn't at all encourage you to use it properly. It doesn't define what "properly" is. The original article detailing PHP's fractally-bad design gave an impressive list of PHP's design flaws and all of the broken things it can do to you. If you know these things and know how to avoid them, you're golden. But who (especially new programmers) can be expected to know all those things?

I also think C++ is a pretty bad language, but you can do some very impressive and clean -- and most importantly, maintainable -- things with it if you use it properly. Unfortunately there are lots of definitions that people have come up with that detail the "proper" subsets of C++ that are safe to use, with disagreement on a bunch of things. (And for the love of $DEITY, please don't lump C++ in with C, which is really a beautiful, amazing language.)


The problem is that lack of exposure causes myopia. If all you've ever used is a hammer, every problem starts to look like a nail.

Every time I've switched languages there has been a transitional period where I've bemoaned the lack of X in the new language, and later wondered how I ever got by without Y, which lets me do in 10 minutes what took 4 hours and hundreds of lines before. Each new language or technology is a new tool in my toolbox, which allows me to make an informed decision when choosing how to build a product.

So if you've only ever used one programming language, then yes, I'm going to take your opinion with a mountain of salt.


There was a fantastic infographic a while ago here which showed a curve of the different stages a programmer goes through when learning a new language. Basically there's an initial euphoria when it feels like the new language is the best in the world because of the things it can do, that is later followed by boredom and despair when the novelty is gone and the warts are starting to bother you, and when you come out the other end, when you can see the good and the bad of a langauge, then you're a good programmer.

It's ok to have a favourite language, it's ok to love your favourite language and sing its praises, but if you can't point out the flaws of it, you're not a good programmer. Your opinion won't be taken seriously. You don't have the experience of working with it long enough to be bitten by the warts, and you don't have the breadth of working with other languages to know what you're missing.


It looks you misunderstood the whole post. The OP clearly noted that "PHP sucks" and can't do many things other languages can. But despite this, he says he likes the language.

And his reason is because of its ease of use and the fact that it works. That to me sounds nothing like "PHP is awesome." Sorry to put it this way, but it looked like you put words in his mouth.


I don't like the "tools" analogy that always comes up. For example, Robertson screws are better than Phillips head screws, which in turn are better than flatheads. All of them are tools, and they all effectively do the same thing. But the Robertson screw is better.


The best screw is the one which I have a screwdriver/drill head for! (Thus PHP is still the best language for a newbie on $5/mo or less shared web hosting!) But really I agree with your point that these metaphors and analogies into other fields hurt the discussion since it changes to being about pointing out problems with the analogy rather than about whatever the discussion was originally about.


Exactly, though I'm not sure you're making the point you want to. I have dozens of Phillips screws at home, and at least two Phillips screwdrivers. I've never heard of Robertson screws.

I could get a new set of screws and screwdrivers, but it's a lot more difficult and expensive than just using the Phillips stuff I have lying around. Depending on how important my project is (am I making a load-bearing shelf or am I putting up a poster frame?) the answer may differ.


> I've never heard of Robertson screws.

Common in Canada, where they were invented. They're square head. Nearly impossible to strip, will stay on your driver with no support at almost any angle.

Not well known in the US because of a decision Ford made nearly 100 years ago to not pay Robertson the price he was asking.

Thus, to this day, any product that comes with screws is likely to come with Phillip's head, and all of its terrible downsides (I keep a supply of Robertson heads so that I never have to deal with Phillips' inherent shittyness).

Bad legacy decision making and inertia conspire to aggravate generations, long after the original thinking behind those decisions stopped making sense. The parallels to PHP are pretty clear.


Robertson screws are nearly impossible to strip? Since when? They're just as easy to strip as Phillips screws. I've done it plenty of times. It's not fun seeing a round slot where a square slot used to be, let me tell you.


I, on the other hand, am struggling to think of the number of times that Phillips screws have aggravated me that much. Maybe my needs are not as complex as yours. Perhaps there is a PHP parallel there, too.


Wikipedia paints a different picture. It indicates that Robertson didn't name too high a price for the license, but that he refused to license at all. Maybe you can cite where you heard otherwise so Wiki can be corrected? In any case, the problem of licensing being the cause of holding back superior technologies is just another example of why patents should be abolished.


I would claim that a programming language is more like material than a tool. You can easily switch tools during the course of the project and discard them once it's done, but it's not that easy to replace faulty material. If you want good results, you should invest in quality material.

(Of course every analogy holds only up to a certain point.)


Actually, your own analogy is very apt. When correctly applied, all kinds of screws can perform the same task fine. The difference lies in how the screw is driven.


only php is a screw made out of silly putty, which is fine for extremely simple things, but would take a great deal of ingenuity and creativity to make work for larger problems


Not sure this is a valid analogy at all; PHP is a tool, not a type of problem (insert joke here), so rather it would be a choice between brands or types of screwdrivers.


And yet I have 5-6 different sized Phillips and standard screw drivers. I've never even heard of Robertson screws.


They tend to be known outside of Canada as "square drive" screws. They can't cam out, are nearly impossible to strip in normal use, and will stay on the driver tip without assistance in almost any attitude other than straight down. They're the darling of woodworkers even in the United States of Phillips.

The American bias towards towards the Phillips screwdriver has mostly to do with the gift of patent made to the government in order to support the war effort, putting them effectively into the public domain. They were better than flat screws/drivers, but that's not saying much: when I worked in aircraft maintenance, about half of all of the Phillips-head captive fasteners (Camlock or Dzus type) on inspection and access panels needed to be replaced between periodic (400-hour) major inspections due to stripped heads.


I've never encountered those but now I know why I have several square tips in my drill's driver bit set. Thanks


Well, they're good for the same reason that hex/Torx is, and I think most people have a set or two of those.


Had we waited for the development of ideal programming tools for the web, the Internet would still be struggling to get off the ground. By making the best of what we have and by continually evolving better solutions we've been able to create something that has, quite literally, changed the world.

Let's keep that in mind. The goal and the end-result isn't a monument to superb software engineering. What we create are experiences for, mostly, non-tech users. How the sausage is made almost isn't important (as long as it doesn't kill you). It's easy to get lost in the pursuit for technical excellence and ignore the realities of building a business.

The fact that Facebook is built on PHP should pretty much tell the story and put a lid on these endless arguments: You use whatever tools you have available at the time to create a good user experience. People don't pay for your choice of programming language. In fact, they couldn't care less.

That's not to say that the tech world should not strive to be on a path of continual improvement and technical evolution. Not at all. I guess what I am trying to say at one level is "quit griping and get back to building a product, nothing else matters".

That said: What might be a likely improved successor to PHP? By this I mean, a language that can gain wide adoption while dealing with a number of the issues of PHP (and other languages) and has a high likelihood of being deployed as far and wide as PHP is today.


And the fact that great books were written by hand or by typewriter should put a lid on any arguments about text editors, word processors, keyboard layouts, and so on, right?


If all the bitchy python/ruby purists out there want to build a successor to PHP, here is the roadmap: 1) make it as simple to setup a development environment as it is to install MAMP (this is somewhat done - but still hella confusing with both Ruby and Python) 2) start a web host that can offer rails/python hosting as simple AND as CHEAP as shared hosting (6$ per month or less) 3) build the Wordpress/Drupal of Rails/Django 4) make it simple for designers and "site builders" to hack the language. This includes former flash addicts.

Until then, all this anti-PHP hate just seems... pointless. As you said, we create experiences for users who ultimately don't care what is beneath the hood as long as it works and doesn't blow up.

There are a lot of PHP systems out there and there is a lot of money to be made as a developer who focuses on PHP. It may not be the prettiest language, but I know why I focus on it - it makes me money. I use other tech (rails, ObjC), but PHP is my bread and butter - and if you do it right, PHP really isn't that bad.

The only time I've seen PHP apps blow up is when they are past due for re-development anyways - a symptom that is not unique to PHP. Anyone who's seen Rails spaghetti knows what I mean.


Rails hosting: git push heroku master.

Pretty damned simple. And cheap, for the level of hosting you get for $6 per month, Heroku is free.

As far as Rails spaghetti, if you're using TDD, then it's easy to fix things if new code breaks old code.


I have no interest whatsoever in building a successor to PHP. Why would I?

What you are pitching is not a language, it is a deploy interface provided by a server. But does everyone agree that PHP has the best possible deploy model? Not at all.

I am happier with languages other than PHP. I gather you are not. That is fine, you use PHP and I won't. There is absolutely no necessity for other languages to ape PHP in an attempt to capture the attention of people who prefer PHP anyway.


I code like this in php, python, ruby, node and golang:

    include 'app';
    include 'models';
    include 'templates';

    $data = models::getCustomers()
    $view = templates::parse('customers',$data)
    app::show($view)
What's so ugly about that? I bet you I can build 90% of sites on the web with that basic snippet of code. In any language...


Agreed. My web applications maintain nearly identical structures (with slight variations due to some OO quirks across platforms) regardless of language choice. At the end of the day most imperative scripting languages are semantically equivalent.


"WSGI in Python gets you part of the way there, but you still need to import a library to talk to the server. This makes PHP just plain easier to get off the ground for web applications."

The first sentence is mostly accurate, but I disagree strongly with the assertion in the second sentence. Grouping related functionality into libraries reduces the cognitive load of programming. The same could be said for his assertion about the benefits of HTTP as a "first-class citizen."

I do agree that getting a PHP application running on a LAMP stack is easier than say getting a WSGI implementation up and running, but this has nothing to do with libraries.


My intention was the full process from creating the first file, to getting a server to serve the content is far easier to do in PHP than Python (granted, in Python it's pretty much boilerplate, but there's a lot more than needs to happen).

As far as the benefit of first-class vs libraries for handling the request, that's something to consider (as there are arguments on both sides)...


That was pretty thoroughly discussed in the original thread. Yes, PHP throws everything you can do into functions in global scope. It's "convenient" but it's messy. It's also, correct me, but an incredibly trivial distinction.


I've found that the people I know (even excellent programmers) who love PHP tend to hate Ruby and find it extremely confusing.

Maybe there is just a fundamental brain-structure difference between individuals... I don't actually think PHP is easier for a beginner than something like Sinatra, so I don't buy the explanation that PHP is easier for those new to programming.


I think there may be something to this. I'm used to programming in PHP and Objective-C and going to Ruby just throws my brain for a loop. I just can't grok it, and reading someone else's Ruby code confuses the hell out of me. I'm more of a designer than a programmer, so take this all with a grain of salt, but coming from a C-style language background I totally feel like a different part of my brain needs to turn on (or off?) to program in Ruby.


This is a warning for future you:

Objective-C, when used like Objective-C and not just C-with-classes, is a lot like Ruby. Both have a shared heritage in Smalltalk.

E.g. http://www.cocoadev.com/index.pl?HigherOrderMessaging


Have you tried Python? My own biased opinion is that Ruby is a problem for some people in the same way Perl is a problem for some people: too much syntax. (I happen to like both Perl and (more so) Python but not really Ruby for other reasons.) Edit: Oh, and PHP was my first language. My feelings about PHP are more or less expressed within this submission.


The problem is that if all you know is a C style language, getting past non c style syntax is a hard job all by itself. I had a hard time learning clojure, but once I did it was a snap to learn common lisp, scheme, and elisp. Same kind of deal (only I think, a bit more extreme), its a matter of having the right background


I would prefer a different analogy. Something like, Heavy Metal & Classical music or Dub-Step & Country.

I leave assigning these as an exercise for the reader.


I like both.


It is very interesting how, often when one haphazardly produces a language for a particular purpose, one winds with a language which both "sucks" and is orders of magnitude better for that particular purpose than any other language. Arguable examples include Php, Matlab, shell-script and many others.

I'm creating an ad-hoc language right that also has this quality. I cringe as I shoe-horn one or another crude extensions into it and then step back and realize that for its particular purpose, it would be harder to do that much better.


The biggest WTF was that "tied to Apache" section. Being running nginx + PHP-FPM for years, even before FPM was accepted as official SAPI.

I guess that people still think that they know better than their sysadmin regarding how to set up a production environment (regarding to the php.ini rant). Maybe because the sysadmins know that expose_php = off turns off those pesky easter eggs. Or they are better at Reading The F[...]riendly Manual (http://www.php.net/manual/en/ini.core.php#ini.expose-php).

Had a good laugh at the complaints about PECL libraries that provide "everything but the kitchen sink". Last time I checked, it was still "The PHP Extension Community Library". People should complain about that particular project, if they need to. It has nothing to do with the internals team.

Wondering how he could forget about the <script language="php"></script> bit.


I'm with you Anthony.

I work all day with PHP even though I love Ruby (and Rails, and Sinatra...) because practically ALL our client base wants either a static site or Wordpress, or another PHP-based CMS. Few of our clients have the budget for a custom web app with its own custom web stack to power it.

There's almost nothing faster to get bootstrapped into a functional application or script than PHP. Assuming your server is already configured with PHP you just upload the project.

PHP 5.3 and 5.4 give me great hope for the future of the language.


"rails new project-name", and I have a full app. and heroku makes deployment just a push away.

Its not like phps ease of use is not a good thing -- it is. but other languages/platforms aren't _that_ much harder


I think many like PHP because an inconsistent language full of design flaws is in many contexts better (in a less is more sense) than a good language that is backed by a complex web framework and library system that contains too many complexities, versioning issues, is slow by default or hard to tune, and so forth.

With PHP people have something that just works, reasonably, and given that an interpreter lives the lifespan of a "page view" making big errors is non trivial.

So PHP is not a good language, but many other languages should learn something from PHP. The problem is that the community backing this better dynamic languages, such as Python and Ruby, still for some (IMHO obscure) reason aren't shipping something that is PHP-alike, but just with a better base language (without trying to add tons of abstraction layers).

I no longer use PHP because after years of using better languages (I like Ruby as a "practical language") it's too hard to return back to PHP, but I often find myself fighting with the useless complexities and layers of abstractions that Ruby contains "by default". Not in the language or the implementation itself, that is good enough IHMO, but in the tons of gems around and in the integration with the web "side".


I have written, maintained and worked on gigantic PHP codebases, mainly in the realm of ecommerce (not that train wreck, magento). I have a lovehate relationship with the language, and my pet peeve is that it is so easy, we get the lowest ability developers who never take time to learn the theory or any other technologies. Having said that... If it wasn't for the LAMP infrastructure, the ease and speed of development, these codebases could not have been developed.

I think the standard libraries could do with an update, to add the consistency they deserve, and do update them to use modern features. The community for PHP is reaching a point of maturity that it has not seen before (look at composer, PSR-0, symfony2 and ZF2). I think this maturity is making the community a good place right now. I'm not leaving it anytime soon.

Take away PHP, watch the major sites of the Internet disappear. Where would we be with no Wikipedia?


> No Debugger - PHP has xdebug which works quite > well as an interactive debugger

Good god, what debuggers have you been using that makes PHP and xdebug seem like it "works quite well".


If I have learned anything during my 3-4 years of experience as a software dev it is that

a) All languages, frameworks and technologies are bad and ugly, each in many of their own horrible ways

b) Nobody has any fracking idea what they're doing (mostly)

c) Your best bet is to find something that does not hurt you as bad as other stuff and stick with it. If you enjoy php, that fine (of course it's completely beyond me how it is possible to enjoy it, but its not the point).

On a side note, after having spent most of my time programming in high-level languages, I wonder how things are down there in bare-metal-programming land. I've grown tired of web development and I wonder what it's like programming in an environment that does not have poorly designed, inconsistent frameworks and leaky abstractions, only registers, memory and pins :) Too bad it's probably too late for me to get started there.


I strongly disagree with A-C but I would encourage you to try some native development if you're curious. HTML5 is the PHP of UI stacks and it's tremendously refreshing to work instead in a well-designed stack like Cocoa Touch or even Android.


Actually I have done a fair amount of native development and I mean C++ stuff, not mobile apps (android/iphone development is actually high-level compared to that). I was really talking about going down even deeper than that, to the level where there is nothing between your code and the machine. I try to educate myself on the subject by reading books and occasionally coding something in my spare time, but it's obvious that my current skill-set does not even remotely comply with the requirements for that type of job.


I would still have to say that PHP, by all its flaws, gets the job done. And in the end of the day thats what count to me. That might be a bad view to have but I've been sticking with it for a lot of years now even though Ive flirted with a lot of other languages. Its still the girl i get home to every night


Maybe its just me, but there seems to be a bit of confusion between frameworks and language. Or many its that some languages are now rarely seen out of the frameworks that made them prominent.

Because PHP was built for a web environment and has features that make it quite useful out of the box, for that environment.

With Ruby or Phython you need to do extra work or jump into a framework to get to that "starting point". However, if you are going to start comparing Ruby/Python with a framework to PHP, then you need to look at PHP through one of the prominent frameworks out today (Symphony, ZF, Etc). Otherwise you are comparing apples to oranges.


> "You don't need a library or a framework to talk HTTP."

With 'library' typically meaning 'extension' in PHP parlance, you do. The socket methods are part of the Socket extension, cURL is an extension you have to compile in.

The only reason you'd not actually notice this is because, unless you compiled your own copy of PHP, it will have been done in the default install bundled with the OS, or in xAMP, and will have automatically been injected into the 'global' scope.

This is all just daft, though. You could go on forever with the "it can't do X but it can do Y" schtick, with any language.


I think what he meant wasn't about sockets or Curl, but the fact that PHP is integrated with the HTTP request itself. You don't need an extension for PHP to output HTML or read in query parameters.

Python developers user REPL to quickly test elements of their code or play around with the language; PHP developers hit refresh.


There are two other interpretations of the statement. One is that you don't need any import/includes, which is true of PHP but not of Python. The second is you don't need any external dependencies "out of the box", ignoring the fact that someone had to make the box[1] for you at some point which you mention here. This is true of PHP, and only half-true of Python: I remember messing with "import cgi" at some point, Flask is so so much better.

[1] Gentoo's USE flags for PHP (the ones with - are the ones I haven't compiled in for my box):

    apache2 bcmath berkdb bzip2 cgi cjk cli crypt ctype curl curlwrappers fileinfo filter ftp gd gdbm hash iconv ipv6 json mysql mysqli nls pdo phar posix postgres readline session simplexml sockets spell sqlite sqlite3 ssl threads tokenizer truetype unicode xml xmlreader xpm zip zlib -calendar -cdb -debug -doc -embed -enchant -exif -firebird -flatfile -fpm -frontbase -gmp -imap -inifile -intl -iodbc -kerberos -kolab -ldap -ldap-sasl -libedit -mhash -mssql -mysqlnd -oci8-instant-client -odbc -pcntl -pic -qdbm -recode -sharedmem -snmp -soap -suhosin -sybase-ct -sysvipc -tidy -wddx -xmlrpc -xmlwriter -xsl


This debate is always the same rehash of ye olde time story as recounted in "The rise of Worse is better"[1].

That's why we had Unix boxes instead of LISP machines, that's why we had PCs running MS-DOS and not Amigas, why we later had PCs running NT instead of SGI Octanes, and nowadays people have PCs running windows7 rather than elegant iMacs.

"Cheap and easy, quick and dirty, and get the job done" is a perfect description of PHP and the very reason for its success.

[1]: http://www.jwz.org/doc/worse-is-better.html


Hating on PHP because it has too many functions is like hating on Chinese because, instead of 26 letters that you can combine to write anything, functional literacy requires a knowledge of between three and four thousand characters and that's just sloppy language design!

Also, why not just call them an API to procedures written in C and realize that none of us scripters are coding in anything.

I code in Lua.


PHP is one of the languages I believe every web developer needs to know reasonably well. It's not my go-to language though and I don't much care for it. Let me explain.

My feelings on PHP are much the same as my feelings towards JavaScript - most of the code I've encountered in the wild was cobbled together by designers who knew nothing about programming and a lot about how to cut and paste scripts together. I find myself blaming the languages for the mess people left me.

But occasionally, much like JavaScript, I'll encounter some PHP code that was truly written by a master - someone who really knows how to use the language effectively, who doesn't intermix SQL, HTML, PHP, and JavaScript in the same 1000 line index.php page. Well-constructed code, designed with purpose.

I suppose that's the same with any language, isn't it?

PHP, like JavaScript, is everywhere, and if you solve other people's problems for a living, I think you need to know it reasonably well. At least well enough not to make it worse than the last developer.


Amen. I started my development career with PHP, and the cacophony of intermingled responsibilities and languages in most PHP scripts is deafening. It wasn't until I learned how to apply good OO design to PHP that I enjoyed using it. That being said, I still don't work with PHP unless I have to. I still don't like its mixed naming scheme for string/array functions or its clunky hash/array syntax. At least the object support is reasonable.


Used to know it just enough to 'deal with it' when there was something that needed to be fixed. Recently I started working for a place that has a few large PHP sites and projects and really dove in. Overall, I'd agree that when you see great PHP it can be nice and impressive. I don't think I'd want to do it 9 hours a day though.


It shouldn't be that hard to configure some other language to fill the ridiculously-easy-to-use niche that PHP fills. I vote for Lua, personally, though almost anything would do.

Embed in HTML, wire stdout to the web page. Add a couple functions for "first class HTTP support". Write an Apache module. You could probably make it even easier to deploy than PHP, with the benefit of a nicer language. Obviously I'm oversimplifying, but it's mainly glue code. Seems like the hardest part is getting it deployed on the $5/month hosts.

Is there some obvious reason it hasn't been done? Did they already and nobody cared? If I didn't already have a massive project backlog I might take a shot at it. It seems like a good opportunity for someone to make a difference.

Edit: Crud, they already took the name mod_lua: http://httpd.apache.org/docs/2.3/mod/mod_lua.html


I loved the original post about PHP's fractal awfulness, but this sums up my feelings about it: I like it anyway. His point about PHP being shared-nothing by default is a good one: this is indeed a big part of the admirable scalability of web apps written in PHP (Facebook, anyone?).

The one point I'd disagree with is his assertion that PHP doesn't have a templating language. Of course it doesn't: PHP is a templating language. That's what it was written to be. Many of the uglier things you have to do in PHP are related to the fact that what the language always wants to do, by default, is spit out a web page.

If what you want to do with your software is output web pages, then PHP is the best call. If you want to do basically anything else, pick another language. But at web applications, PHP just can't be beat.


I'm glad you like it, but the "shared-nothing" line is outrageous bunk. Commonly repeated bunk, so I don't blame you, but it's still bunk.

Pretty much every PHP app in the world shares a database. So you've shifted your scaling problems from an area that programmers understand and control to a 1-MLOC mystery.

I bring this up because I have a few friends who make their living saving the asses of PHP programmers who buy the notion that PHP is magically easy to scale. I hear a lot of horror stories from them about the absurd sums of money spent cleaning up the messes.

I do agree that PHP is fine for doing basic web apps. But I don't know anybody doing anything serious with PHP that only uses PHP, because serious web apps eventually need more than you can do in that language. PHP's "shared-nothing" scaling just means that when the going gets tough, some language other than PHP will be doing the work.


> Pretty much every PHP app in the world shares a database. So you've shifted your scaling problems from an area that programmers understand and control to a 1-MLOC mystery.

True, however in my experience it's pretty easy to scale the database layer. One beefy DB server can easily handle 2 or 3 front end servers with even mild caching. If you get aggressive in the caching strategy, one DB server can handle up to 10 front end boxes. And if you need to scale beyond that, replication is a well understood paradigm (sure, not by normal app developers, but there's plenty of resources out there).

> I bring this up because I have a few friends who make their living saving the asses of PHP programmers who buy the notion that PHP is magically easy to scale.

I never said that it was magically able to scale. I said that the language is easy to scale. What you do with it is on you. So if you're writing garbage code, you're going to get garbage scalability...


Not quite sure why you're jumping in to this sub-thread. I'm just taking issue with the "shared nothing" line that people hand out.

Note, though, that you've introduced another shared resource, cache servers, to fix the problems that a "shared nothing" approach introduces. Because once again, the "shared nothing" line is bunk.


You're right that the back-end often gets ported to some other language when a PHP app is scaled-up; this goes with my point that when you move away from spitting out web pages, another language is a better choice.

I'm not sure your point about a database is valid; Python and Ruby and Perl apps are all using a shared database (or newer k-v store) as well.


My point is that it's the place where all shared state is kept. "Shared nothing" is a lie because it's sweeping the sharing under the rug of the database.

I agree that most web stuff written in scripting languages is built around a database for shared state. But in more powerful languages, you have other options.


Never claimed Python/Ruby solve this problem, just that PHP doesn't (but is claimed to).


Yes, PHP can suck in many ways. Yes, everything else seems to be more elegant. And yes, newbies don't care. They just want it to work, no matter how. They don't care about creating servers (node) or including something they know nothing about (sinatra). Heck, they might do it with PHP as well, if they knew how to (Kohana?). But they don't and they never will.

On the other side, put good developers on a PHP project and you will get a good product, regardless of the haystack position and possibility to suppress errors (etc. etc. etc.). The fact that there is so much spaghetti PHP out there doesn't make it impossible to write good code with it. And that matters a lot.


I think the PHP documentation is the major thing not mentioned here for the non-programmer layman (like me, who uses PHP).

Need to know how to use in_array?

http://us.php.net/manual/en/function.in-array.php

Not only is there a quick reference on the top, but clear, concise, and diverse examples on how to use it if you don't want to spend time thinking about how to work the arguments.

Maybe the expert programmer doesn't really care about these qualities, because javadoc is "easy" to them, but it doesn't compare to this for me.

P.S. As someone who has dabbled with Ruby, Python, etc. I do acknowledge they are vastly superior languages in many respects.


If you're glad that PHP.net exists because you can always look up the order of needle and haystack, you'll love a language where the order of needle and haystack is always consistent.


I used PHP awhile back, but how much of its inconsistencies can be resolved without fundamentally changing the language's positive features? That is, not caring about backward incompatibility. Like, I can't imagine the inconsistency of "==" has any bearing on PHP's flexibility.


If you don't care about backwards compatibility you leave a lot of users in the lurch. PHP4 to PHP5 took years to migrate over and Python 3 still hasn't taken over from Python 2. Perl 5 and 6.

If you can't get syntax/semantic changes adopted in a single language then getting a whole new language adopted is a non-starter.

I think the core PHP developers should take a long look at the inconsistencies of the language and formulate a plan to reduce/eliminate them without breaking backwards compatibility. In some cases, it should be relatively easy but in others it will be very difficult. The inconsistency of "==" would be hard to fix while making sure old code still runs correctly.


I really dislike it when someone posts something controversial so a couple hours later someone posts the opposite based on their experience.

This doesn't add anything useful, post it as a link on the original thread. It is just a bunch of noise cluttering up the frontpage of HN!


A novice programmer can write dangerously horrible code in C or C++ but we don't say those languages suck (most of the time). I'd rather debug/refactor a poorly engineered PHP project than a poorly engineered C or C++ application any day of the week.


C or C++ aren't competing with PHP. You'd have to look at Python or Ruby in this case. While it's definitely possible to write shitty code in those languages it doesn't provide nearly as many ways to screw up. Besides the lack of language features like @ (error silencing), you won't find nearly as many terrible tutorials out there created by some guy who's been learning for a few weeks and decided to write a blog post.

Given a poorly engineered PHP or Python project, I will always pick the latter. However, if I were to start a project on my own I'm confident enough in my PHP that the language choice is harder to make.


C or C++ aren't competing with PHP.

That's true, but my point is that there isn't such a visceral hatred for C and C++ even though they are widespread and notorious for memory leaks, vulnerabilities, indecipherable corporate quagmires (perhaps due to an over-engineered OO architecture or 700 line functions or opaque symbol names or dependency hell, etc).

Besides the lack of language features like @ (error silencing)

Red-flag bad practices exist on all platforms. The horror story of a PHP project littered with error suppression is like opening up a C project and discovering that the control flow is guided by a 200 label GOTO architecture. It's not PHP's fault that the programmer abuses the language, it's the employer's fault for hiring a highschool student at $15/hr.


> That's true, but my point is that there isn't such a visceral hatred for C and C++ even though they are widespread and notorious for memory leaks, vulnerabilities, indecipherable corporate quagmires (perhaps due to an over-engineered OO architecture or 700 line functions or opaque symbol names or dependency hell, etc).

C is enormously more consistent, better defined and specified, and well-documented than PHP.

It's a solid enough language with a very specific use case, and not even remotely competing with PHP.

PHP is a terribly inconsistent, poorly defined, poorly documented, poorly implemented, poorly designed language that can't do anything better than any of the other languages it is competing with.

The one thing PHP has going for it is inertia. That's it.


C is enormously more consistent, better defined and specified, and well-documented than PHP.

Yes, this is a trite and negligible truth of PHP. A developer suffering any significant loss of productivity due to problems like mismatched needle/haystack parameters just isn't very competent. It's a non-issue if the developer is being paid a real salary. I'm not saying these issues aren't important enough to warrant attention, but the debate between maintaining backwards compatibility and squashing bad practices certainly isn't exclusive to PHP.

and not even remotely competing with PHP.

I already addressed this in my previous post. I'm not suggesting that PHP is in competition with C, that should be pretty obvious. I'm asserting that C, like PHP, is ridden with dangerous pitfalls for developers who don't know what they're doing. PHP is just easier to work with for a novice programmer.

The one thing PHP has going for it is inertia

And did that inertia spontaneously emerge from a vacuum? In the spirit of PHP's namesake you've devised a recursive argument to explain the only conceivable upside to using PHP.


> Yes, this is a trite and negligible truth of PHP. A developer suffering any significant loss of productivity due to problems like mismatched needle/haystack parameters just isn't very competent. It's a non-issue if the developer is being paid a real salary. I'm not saying these issues aren't important enough to warrant attention, but the debate between maintaining backwards compatibility and squashing bad practices certainly isn't exclusive to PHP.

You're just hand-waving away the issue. "Yes, you have to keep far more in your head at once to make sure you don't step on a PHP landmine, but that's why we're paid the big bucks!"

I'm sorry, but this is a false dichotomy and an inaccurate parallel with C. C's landmines are well-defined, understood, and derive from the target purpose (portable assembly). PHP's landmines are ambiguous, ill-defined, and just plain stupid, often caused by what amounts to a truly brain-dead lack of cognitive effort on behalf of the language authors. The language is poorly specified such that even if a developer should wish to invest sufficient effort, it's impossible to know where they all are.

Moreover, there are such ugly corner cases built into the language and common libraries that some landmines are entirely unavoidable. Whose brilliant plan was it to make fopen() accept URL parameters instead of defining a common stream API that arbitrary stream types could support?

Let's say I want to treat a byte array as a stream -- this is a pretty common thing to do in most languages:

  fopen('data:text/plain;base64,'.base64_encode($data), 'rb');
Are you bloody kidding me? That's just the smallest, tiniest tip of the PHP iceberg of stupid-in-action.

> And did that inertia spontaneously emerge from a vacuum? In the spirit of PHP's namesake you've devised a recursive argument to explain the only conceivable upside to using PHP.

PHP's inertia emerged out of ill-qualified individuals adopting the language as the most visible available option during a time when there was largely a dearth of options and limited understanding of the web as a platform and "what comes next" from CGI.

People -- collectively, as a group -- adopt poor solutions to their problems, simply as a matter of compounding gravitation and a lack of understanding of the long-term implications.

It's simple group decision making, and it's not reasoned, nor is it necessarily likely to produce the best possible answer, or even a good one -- especially when the group in question is ill-equipped to understand the problem space they're working in.


> indecipherable corporate quagmires (perhaps due to an over-engineered OO architecture ...)

Sounds like Java to me :-)


The difference is that in exchange for the difficulty of C/C++ you get low-level control and performance that no other language can consistently match. They are still the right tool for some jobs.

You get nothing in exchange for the extra headaches of PHP.


You get nothing in exchange for the extra headaches of PHP.

Of course you receive something in exchange. Whatever explanation you have for the ubiquity of PHP is the benefit one receives in exchange.

Besides, my point is that headaches are not inherent to PHP. Just because a community of hobbyists and novices churn out shaky code doesn't mean that developers employing best practices will.

https://github.com/symphonycms/symphony-2/tree/master/sympho...

Here is an example of quality PHP code. Clear and organized OO structure, useful comments, self documenting method and variable identifiers. Why is this inherently wrong?


No, pretty much everyone says that C++ sucks.


Well said. PHP gets a lot of crap thrown at it, but in the end, one of the biggest companies and second biggest website on the internet uses it as it's primary language.. If it's good enough for them, it's good enough for any of us to use.


Facebook pretty much has to use php, they can't afford to rewrite all of this huge codebase. They have written their own compiler that translates php to c++ and then uses g++ to compile that into native code. I'm sure they had some pretty serious reasons to do that. And they probably wouldn't have to do that sort of thing if facebook wasn't written in php in the first place. Thus, the argument "hey, facebook is written in php so let's use php" is invalid, it's a typical "cum hoc ergo propter hoc" fallacy.


That's the backend. The front end stuff that average Facebook users interact with is raw PHP.


How do you know that?


The wide adoption of PHP has nothing to do with it's actual quality, though.


It helps though. High adoption, especially with bigger companies, leads to my eyes on the code which can cause a higher quality run time. It also means there are more tools, frameworks, reference books, and ultimately jobs out there for it.


Yes. The availability of a bunch of easy-to-Google tutorials, libraries, hacks, workarounds etc should be included in the overall utility of a language.


I just followed the first half dozen search results for "php tutorial mysql". All of them resort to pasting string literals into queries, with not a prepared statement in sight. One of PHP's problems is that it quickly reached a critical mass of self-perpetuating misinformation between the ignorant and the slightly less ignorant, ensuring unforgivable security blunders for years to come. At this point I don't know how anyone could solve this, short of dramatic language changes that make those crappy old tutorials obviously unusable.


"If it's good enough for them, it's good enough for any of us to use."

This doesn't follow at all.


I think the point he's trying to make is that you can choose PHP and you're never going to hit a wall where it can no longer be used because the project is getting too big and serious.

That's a strawman argument to be sure, but I think it's reasonable to point out given the oft-repeated claimed that PHP is fine for small-scale hacking but is inadequate for "serious" software engineering.


Exactly... I hear so many people saying PHP is horrible for sites/apps that are big and serious, yet when I mention Facebook or Yahoo! Answers, they go quiet... What real time examples aren't good enough?

Way to many people jump on the "PHP is crap" bandwagon for no reason and they all repeat the same thing over and over.


Read the original post, he isn't saying that its crap with no reason, he is saying it is crap and giving a good 80 reasons that none of the alternatives have. And pointing to facebook just means it is possible to build something great with php, if you have hired the best developers in the world, and spent a ton of time writing your own toolchain. It does not mean that facebook could have done more in less time with a different platform. I have seen well written excel macros that did things I never would have thought possible, vba is still a terrible language despite that.


PHP sucks, but it will get better over time. Maybe they'll try to do a big leap like Python 2 to Python 3, which would be great.

I'm not a big fan, but I like the fact the developers seem to be trying to improve it.


I love PHP too, I can't agree more for the 'just work' point, besides unicode isn't built in. (It 's really a pain for far east users like me)


The OP says PHP doesn't have XSS filtering but that is simply not true:

http://www.php.net/filter


wait. after reading the earlier article, i started learning python. you guys cant do this.

i need to go back to php now or wait till the wwIII is over


Why not learn both?


Good point there, Gigablah


"PHP Sucks" [....] Yep, agree with that part....


Can't we all just get along?


It's often called "c++ on the internet" but C++ was never a pretty language. At the very least, it is better than ASP. Good lord, ASP is such a hunk of garbage.


ASP.net or Classic? Remember Classic was first released 14 years ago, a lot of great stuff has been built in it. I'm not sure why you would call either a hunk of garbage!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: